-
-
Save madhephaestus/a139a38dacf7f0f5e487 to your computer and use it in GitHub Desktop.
Bowler Studio Game Controllers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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