Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Forked from acamilo/gameController.groovy
Last active August 29, 2015 14:28
Show Gist options
  • Save madhephaestus/a139a38dacf7f0f5e487 to your computer and use it in GitHub Desktop.
Save madhephaestus/a139a38dacf7f0f5e487 to your computer and use it in GitHub Desktop.
Bowler Studio Game Controllers
import com.neuronrobotics.sdk.addons.gamepad.IJInputEventListener;
import net.java.games.input.Component;
import net.java.games.input.Event;
ServoChannel srvdrive = new ServoChannel (dyio.getChannel(9));
ServoChannel neck = new ServoChannel (dyio.getChannel(10));
IJInputEventListener listener = new IJInputEventListener() {
@Override public void onEvent(Component comp, Event event1,float value, String eventString) {
int front,drive;
//println "Event = "+eventString
if (comp.getName()=="y") {
front = 127-(127*value);
//System.out.println("front:\t"+front);
srvdrive.SetPosition(front, 0);
}
if (comp.getName().contains("slider")) {
front = 127-(127*value);
//System.out.println("front:\t"+front);
neck.SetPosition(front, 0);
}
}
}
dyio.setServoPowerSafeMode(false);
// gamepad is a BowlerJInputDevice
gamepad.addListeners(listener);
// wait while the application is not stopped
while(!Thread.interrupted());
//remove listener and exit
gamepad.removeListeners(listener);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment