// // JoyInput // class JoyInput extends Event { Hid joystick; HidMsg joystickMsg; 0 => int defaultJoystick; 0 => int DEBUG;; 0 => int axis => int buttonDown => int buttonUp => int dpad => int dpadPosition; 0.0 => float axisPosition; fun void listen( int j ) { j => defaultJoystick; listen(); } fun void listen() { if( !joystick.openJoystick( defaultJoystick ) ) me.exit(); <<< "joystick '" + joystick.name() + "' ready", "" >>>; while( true ) { joystick => now; 0 => axis => buttonDown => buttonUp => dpad => dpadPosition; 0.0 => axisPosition; while( joystick.recv( joystickMsg ) ) { if( joystickMsg.isAxisMotion() ) { if(DEBUG) <<< "joystick axis", joystickMsg.which, ":", joystickMsg.axisPosition >>>; joystickMsg.which + 1 => axis; joystickMsg.axisPosition => axisPosition; } else if( joystickMsg.isButtonDown() ) { if(DEBUG) <<< "joystick button", joystickMsg.which, "down" >>>; joystickMsg.which + 1 => buttonDown; } else if( joystickMsg.isButtonUp() ) { if(DEBUG) <<< "joystick button", joystickMsg.which, "up" >>>; joystickMsg.which + 1 => buttonUp; } else if( joystickMsg.isHatMotion() ) { if(DEBUG) <<< "joystick hat", joystickMsg.which, ":", joystickMsg.idata >>>; joystickMsg.which + 1 => dpad; joystickMsg.idata + 1 => dpadPosition; } this.broadcast(); me.yield(); } } } } // JoyInput ji; // spork ~ ji.listen(); // // while(true) // { // ji => now; // <<< ji.axis, ji.axisPosition, ji.buttonDown, ji.buttonUp, ji.dpad, ji.dpadPosition >>>; // me.yield(); // }