Discussion:
WiiMote event triggering issue
rev
2014-09-15 08:49:34 UTC
Permalink
Hi list,

I was working on a project involving a Wii when I've encountered a strange
behaviour of the event responders.
In brief, although WiiMote packet requires to specify with a key the button
to associate to any single event, I see upon defining different events to
different keys they are all activated together when any button on the Wii is
pressed (I'm using a standard WiiMote without nunchuck).

Example based on help file (initialization not shown):

w.setAction( \bA, { |v| v.postln; } );
w.setAction( \bB, { |v| v.postln; } );

This will post both A and B buttons status when ANY button on the WiiMote is
pressed (A,B, home, +, -,... You get it, all of them. Accelerometer has no
effect, though). So it seems the action is triggered not by the specified
button being pressed, but by any modification in the buttonData array. In my
very limited understanding, I'd suggest that's because of this chunk in
WII.sc :

prHandleButtonEvent{ |buttonData|
// buttonData are bits that decode to separate buttons (do in
Primitive internally, and pass on Array?
//("handle button Event"+buttonData).postln;
remote_buttons = buttonData;
[ \bA, \bB, \bOne, \bTwo, \bMinus, \bHome, \bPlus, \bUp, \bDown,
\bLeft, \bRight ].do{ |key|
actionSpec.at( key ).value( spec.at(key).value );
if ( dumpEvents, { (key +
spec.at(key).value.round(0.00001)).postln; });
}
}

it seems to be triggered by the whole array and then it launches an action
for any single button, regardless it has been pressed or not.

I don't know if this effect is wanted or not, nor I am an expert on actions,
but should this is a bug I'd like to point it out, should this be normal I'd
ask how I could define an action to be triggered only when a particular
button is pressed.

Thank You and
regards,

rev





--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/WiiMote-event-triggering-issue-tp7613407.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
rev
2014-09-16 17:05:12 UTC
Permalink
Dear list,
(especially nescivi, timblechmann and lijon who seems to be contributing to
the WII.sc file on Github)

I've edit the WII.sc file in order to have each WiiMote button to trigger
only its action. I'd propose this new code as a possible substitution,
fixing the issue I've pointed out in my previous message. That seems to work
on my PC. Anyway, I'm unable to edit the file on GitHub, so if accepted one
of the official contributors should check and possibly add it.

Instead of this code:

//--BEGIN (line 426, file: supercollider / SCClassLibrary / Common /
Control / WII.sc)

prHandleButtonEvent{ |buttonData|
// buttonData are bits that decode to separate buttons (do in
Primitive internally, and pass on Array?
//("handle button Event"+buttonData).postln;
remote_buttons = buttonData;
[ \bA, \bB, \bOne, \bTwo, \bMinus, \bHome, \bPlus, \bUp, \bDown,
\bLeft, \bRight ].do{ |key|
actionSpec.at( key ).value( spec.at(key).value );
if ( dumpEvents, { (key +
spec.at(key).value.round(0.00001)).postln; });
}
}

//--END

I've put this one:

//--BEGIN

prHandleButtonEvent{ |buttonData|
// buttonData are bits that decode to separate buttons (do in Primitive
internally, and pass on Array?
//("handle button Event"+buttonData).postln;

[ \bA, \bB, \bOne, \bTwo, \bMinus, \bHome, \bPlus, \bUp, \bDown, \bLeft,
\bRight ].do{ |key,i|
if ( buttonData[i]!=remote_buttons[i], { remote_buttons[i]=buttonData[i];
actionSpec.at( key ).value( spec.at(key).value ); });
if ( dumpEvents, { (key + spec.at(key).value.round(0.00001)).postln; });
}
}

//--END

Basically before throwing actions, it parses the buttonData array and find
the buttons for which state was changed, then goes on putting new values in
remote_buttons array and throwing only the actions needed.
My programming skill is poor, so it's likely someone would need to provide
some changes. What caused the problem in the original version was the
acceptance of the whole buttonData array and the subsequent launch of the
actions defined for any button, not only those whose state actually changed.

Regards,
rev



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/WiiMote-event-triggering-issue-tp7613407p7613428.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
nescivi
2014-09-18 16:41:07 UTC
Permalink
Hiho,

Thanks for the report and the fix!

can you file this mail as an issue on github?
then it is less likely to be forgotten, and I can take a look at it once
I am back home.

sincerely,
Marije
Post by rev
Dear list,
(especially nescivi, timblechmann and lijon who seems to be contributing to
the WII.sc file on Github)
I've edit the WII.sc file in order to have each WiiMote button to trigger
only its action. I'd propose this new code as a possible substitution,
fixing the issue I've pointed out in my previous message. That seems to work
on my PC. Anyway, I'm unable to edit the file on GitHub, so if accepted one
of the official contributors should check and possibly add it.
//--BEGIN (line 426, file: supercollider / SCClassLibrary / Common /
Control / WII.sc)
prHandleButtonEvent{ |buttonData|
// buttonData are bits that decode to separate buttons (do in
Primitive internally, and pass on Array?
//("handle button Event"+buttonData).postln;
remote_buttons = buttonData;
[ \bA, \bB, \bOne, \bTwo, \bMinus, \bHome, \bPlus, \bUp, \bDown,
\bLeft, \bRight ].do{ |key|
actionSpec.at( key ).value( spec.at(key).value );
if ( dumpEvents, { (key +
spec.at(key).value.round(0.00001)).postln; });
}
}
//--END
//--BEGIN
prHandleButtonEvent{ |buttonData|
// buttonData are bits that decode to separate buttons (do in Primitive
internally, and pass on Array?
//("handle button Event"+buttonData).postln;
[ \bA, \bB, \bOne, \bTwo, \bMinus, \bHome, \bPlus, \bUp, \bDown, \bLeft,
\bRight ].do{ |key,i|
if ( buttonData[i]!=remote_buttons[i], { remote_buttons[i]=buttonData[i];
actionSpec.at( key ).value( spec.at(key).value ); });
if ( dumpEvents, { (key + spec.at(key).value.round(0.00001)).postln; });
}
}
//--END
Basically before throwing actions, it parses the buttonData array and find
the buttons for which state was changed, then goes on putting new values in
remote_buttons array and throwing only the actions needed.
My programming skill is poor, so it's likely someone would need to provide
some changes. What caused the problem in the original version was the
acceptance of the whole buttonData array and the subsequent launch of the
actions defined for any button, not only those whose state actually changed.
Regards,
rev
--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/WiiMote-event-triggering-issue-tp7613407p7613428.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
rev
2014-09-19 10:13:59 UTC
Permalink
Thank You for Your feedback nescivi.

Published as an issue as requested. I hope I've done that right as it's the
first time I sign in GitHub.
Guess I'm a geek now.

Regards,
rev



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/WiiMote-event-triggering-issue-tp7613407p7613469.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Loading...