-
-
Save acamilo/1adb7de96d6693b165cb 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 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