// Slork 2013 // Week 2 ChucK Tutorial // GameTrak / Joystick control // Spencer Salazar - spencer@ccrma.stanford.edu // open the joystick Hid joystick; joystick.openJoystick(0); HidMsg msg; // loop forever (or until the program is exited) while(true) { // wait for new joystick data joystick => now; // receive the data while(joystick.recv(msg)) { // a button was pressed if(msg.type == Hid.BUTTON_DOWN) { <<< "button down:", msg.which >>>; } // a button was released else if(msg.type == Hid.BUTTON_UP) { <<< "button up:", msg.which >>>; } // an "axis" was moved // gametrak has 3 axes per string: forward/back, left/right, up/down // normal joysticks usually only have 2: forward/back, left/right else if(msg.type == Hid.AXIS_MOTION) { <<< "axis motion:", msg.which, msg.axisPosition >>>; } } }