Skip to content

Instantly share code, notes, and snippets.

@acamilo
Forked from madhephaestus/.gitignore
Last active August 29, 2015 14:28
Show Gist options
  • Save acamilo/1adb7de96d6693b165cb to your computer and use it in GitHub Desktop.
Save acamilo/1adb7de96d6693b165cb 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 srvfront = new ServoChannel (dyio.getChannel(0));
ServoChannel srvdrive = new ServoChannel (dyio.getChannel(11));
IJInputEventListener listener = new IJInputEventListener() {
@Override public void onEvent(Component comp, Event event1,float value, String eventString) {
int front,drive;
if (comp.getName()=="x") {
front = 110-(110*value);
System.out.println("front:\t"+front);
srvfront.SetPosition(front, 0);
}
if (comp.getName()=="y"){
drive = 112-(112*value*-1);
System.out.println("drive:\t"+drive);
srvdrive.SetPosition(drive, 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