Difference between revisions of "Joysticks"

From CCRMA Wiki
Jump to: navigation, search
(Mapping Joysticks)
Line 1: Line 1:
 
== Mapping Joysticks ==
 
== Mapping Joysticks ==
 +
 +
<source lang="c">
 +
Hid js;
 +
HidMsg msg;
 +
 +
if( !js.openJoystick( 0 ) ) me.exit();
 +
<<< "Ready?", "" >>>;
 +
 +
while(true)
 +
  {
 +
    // wait for event
 +
    js => now;
 +
    while( js.recv( msg ) )
 +
      {
 +
js => now;
 +
<<< "\n\nI LIKE TO","MOVE IT MOVE IT" >>>;
 +
while( js.recv(msg))
 +
  {
 +
    if( msg.isAxisMotion())
 +
      {
 +
<<< "axismotion" >>>;
 +
<<< "axis: ", msg.which, " position: ", msg.axisPosition >>>;
 +
      }
 +
    if( msg.isButtonDown())
 +
      {
 +
<<< "buttondown: ", msg.which >>>;
 +
      }
 +
    if( msg.isButtonUp())
 +
      {
 +
<<< "buttonup: ", msg.which >>>;
 +
      }
 +
    if(msg.isHatMotion() )
 +
      {
 +
<<< "hat: ", msg.idata >>>;
 +
      }
 +
  }
 +
      }
 +
  }
 +
 +
</source>

Revision as of 17:37, 15 March 2009

Mapping Joysticks

<source lang="c"> Hid js; HidMsg msg;

if( !js.openJoystick( 0 ) ) me.exit(); <<< "Ready?", "" >>>;

while(true)

 {
   // wait for event
   js => now;
   while( js.recv( msg ) )
     {

js => now; <<< "\n\nI LIKE TO","MOVE IT MOVE IT" >>>; while( js.recv(msg)) { if( msg.isAxisMotion()) { <<< "axismotion" >>>; <<< "axis: ", msg.which, " position: ", msg.axisPosition >>>; } if( msg.isButtonDown()) { <<< "buttondown: ", msg.which >>>; } if( msg.isButtonUp()) { <<< "buttonup: ", msg.which >>>; } if(msg.isHatMotion() ) { <<< "hat: ", msg.idata >>>; } }

     }
 }

</source>