net.java.games.input.Controller Java Examples
The following examples show how to use
net.java.games.input.Controller.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JogWidget.java From BowlerStudio with GNU General Public License v3.0 | 5 votes |
public void setGameController(BowlerJInputDevice gameController) { this.gameController = gameController; if(gameController!=null){ getGameController().clearListeners(); getGameController().addListeners(this); game.setText("Remove Game Controller"); controllerLoop(); Controller hwController = gameController.getController(); paramsKey = hwController.getName(); HashMap<String, Object> map = ConfigurationDatabase.getParamMap(paramsKey); boolean hasmap = false; if(map.containsKey("jogKinx")&& map.containsKey("jogKiny") && map.containsKey("jogKinz") && map.containsKey("jogKinslider") ){ hasmap=true; } if(!hasmap){ runControllerMap(); } } }
Example #2
Source File: JInputJoyInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void loadIdentifiers(int controllerIdx, Controller c){ Component[] ces = c.getComponents(); int numButtons = 0; int numAxes = 0; xAxis = -1; yAxis = -1; for (Component comp : ces){ Identifier id = comp.getIdentifier(); if (id instanceof Button){ buttonIdsToIndices[controllerIdx].put((Button)id, numButtons); numButtons ++; }else if (id instanceof Axis){ Axis axis = (Axis) id; if (axis == Axis.X){ xAxis = numAxes; }else if (axis == Axis.Y){ yAxis = numAxes; } axisIdsToIndices[controllerIdx].put((Axis)id, numAxes); numAxes ++; } } }
Example #3
Source File: GamepadListener.java From haxademic with MIT License | 5 votes |
public GamepadListener() { new Thread(new Runnable() { public void run() { // look for controllers via JInput Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers(); if (controllers.length == 0) { P.error("JInput Found no controllers."); } else { P.out("Gamepads found:"); for (int i = 0; i < controllers.length; i++) { P.out("["+i+"] " + controllers[i].getName(), " | ", controllers[i].getType()); } } while (true) { // poll each device for (int i = 0; i < controllers.length; i++) { // On OS X, Gamepad showed up as GAMEPAD, and on Windows, UNKNOWN if(controllers[i].getType() != Controller.Type.MOUSE && controllers[i].getType() != Controller.Type.KEYBOARD) { // get input updates controllers[i].poll(); EventQueue queue = controllers[i].getEventQueue(); Event event = new Event(); while (queue.getNextEvent(event)) { Component comp = event.getComponent(); float value = event.getValue(); GamepadState.instance().setControlValue(comp.getName(), value); } } } } }}).start(); }
Example #4
Source File: JInputTest.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
/** * Figure out which input just changed. Requires human input. */ //@Test public void detectSingleInputChangeB() { int i,j; while(true) { // get the latest state InputManager.update(true); Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers(); for(i=0;i<ca.length;i++) { Component[] components = ca[i].getComponents(); for(j=0;j<components.length;j++) { float diff = components[j].getPollData(); if(diff>0.5) { // change to state System.out.println("Found "+ca[i].getName()+"."+components[j].getName()+"="+diff); //return; } } } } }
Example #5
Source File: InputManager.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
/** * output all controllers, their components, and some details about those components. */ static public void listAllControllers() { ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment(); Log.message("supported="+ce.isSupported()); Controller[] ca = ce.getControllers(); for(int i =0;i<ca.length;i++){ Component[] components = ca[i].getComponents(); Log.message("Controller "+i+":"+ca[i].getName()+" "+ca[i].getType().toString()); Log.message("Component Count: "+components.length); // Get this controllers components (buttons and axis) for(int j=0;j<components.length;j++){ Log.message("\t"+j+": "+components[j].getName() + " " + components[j].getIdentifier().getName() +" (" + (components[j].isRelative() ? "Relative" : "Absolute") + " " + (components[j].isAnalog()? "Analog" : "Digital") + ")"); } } }
Example #6
Source File: LinkSliderWidget.java From BowlerStudio with GNU General Public License v3.0 | 5 votes |
public void setGameController(BowlerJInputDevice controller) { this.controller = controller; if (controller != null && jogTHreadHandle == null) { jogTHreadHandle = new jogThread(); jogTHreadHandle.start(); } if (controller != null) { Controller hwController = controller.getController(); paramsKey = hwController.getName(); System.err.println("Controller key: " + paramsKey); getGameController().clearListeners(); getGameController().addListeners(this); controllerLoop(); } }
Example #7
Source File: JInputManager.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Init */ public static void initKeyboard() { controllerEnvironment = ControllerEnvironment.getDefaultEnvironment(); controllers = controllerEnvironment.getControllers(); for(int i = 0; i < controllers.length; i++) { Controller c = controllers[i]; if((c.getType() == Controller.Type.KEYBOARD) && (c instanceof Keyboard)) { if(NullpoMinoSlick.useJInputKeyboard) { log.debug("initKeyboard: Keyboard found"); } keyboard = (Keyboard)c; } } if((keyboard == null) && (NullpoMinoSlick.useJInputKeyboard)) { log.error("initKeyboard: Keyboard NOT FOUND"); // Linux if(System.getProperty("os.name").startsWith("Linux")) { log.error("If you can use sudo, try the following command and start NullpoMino again:"); log.error("sudo chmod go+r /dev/input/*"); } } }
Example #8
Source File: GameControllerPanel.java From zxpoly with GNU General Public License v3.0 | 5 votes |
GadapterRecord(final Controller controller, final List<Gadapter> activeGadapters) { super(new GridBagLayout()); this.controller = controller; this.selected = new JCheckBox(); this.name = new JLabel(controller.getName()); this.type = new JComboBox<>(GadapterType.values()); final Optional<Gadapter> activeForController = activeGadapters.stream().filter(x -> x.getController() == controller).findFirst(); if (activeForController.isPresent()) { this.selected.setSelected(true); this.type.setSelectedItem(activeForController.get().getType()); } final GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0); this.add(this.selected, constraints); constraints.gridx = 1; constraints.weightx = 1000; this.add(this.name, constraints); constraints.gridx = 2; constraints.weightx = 1; this.add(this.type, constraints); }
Example #9
Source File: InputManager.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
static public void updateMouse(Controller controller) { //* Component[] components = controller.getComponents(); for(int j=0;j<components.length;j++){ Component c = components[j]; /*/ EventQueue queue = controller.getEventQueue(); Event event = new Event(); while(queue.getNextEvent(event)) { Component c = event.getComponent(); //*/ /* Log.message("\t"+c.getName()+ ":"+c.getIdentifier().getName()+ ":"+(c.isAnalog()?"Abs":"Rel")+ ":"+(c.isAnalog()?"Analog":"Digital")+ ":"+(c.getDeadZone())+ ":"+(c.getPollData()));//*/ if(c.isAnalog()) { double v = c.getPollData(); if(c.getIdentifier()==Identifier.Axis.X) setRawValue(Source.MOUSE_X,v); if(c.getIdentifier()==Identifier.Axis.Y) setRawValue(Source.MOUSE_Y,v); if(c.getIdentifier()==Identifier.Axis.Z) setRawValue(Source.MOUSE_Z,v); } else { // digital if(c.getPollData()==1) { if(c.getIdentifier()==Identifier.Button.LEFT ) setRawValue(Source.MOUSE_LEFT,1); if(c.getIdentifier()==Identifier.Button.MIDDLE) setRawValue(Source.MOUSE_MIDDLE,1); if(c.getIdentifier()==Identifier.Button.RIGHT ) setRawValue(Source.MOUSE_RIGHT,1); } } } }
Example #10
Source File: JInputJoyInput.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setJoyRumble(int joyId, float amount){ Controller c = indicesToController.get(joyId); if (c == null) throw new IllegalArgumentException(); for (Rumbler r : c.getRumblers()){ r.rumble(amount); } }
Example #11
Source File: JInputTest.java From halfnes with GNU General Public License v3.0 | 4 votes |
@Test public void testJInput() { ControllerEnvironment controllerEnvironment = ControllerEnvironment.getDefaultEnvironment(); Controller[] controllers = controllerEnvironment.getControllers(); System.out.println(String.format("%s controllers found.", controllers.length)); Arrays.asList(controllers).forEach(controller -> { System.out.println(String.format(" %s (%s)", controller, controller.getType())); }); }
Example #12
Source File: ControllerImpl.java From halfnes with GNU General Public License v3.0 | 4 votes |
public final void setButtons() { Preferences prefs = PrefsSingleton.get(); //reset the buttons from prefs m.clear(); switch (controllernum) { case 0: m.put(prefs.getInt("keyUp1", KeyEvent.VK_UP), BIT4); m.put(prefs.getInt("keyDown1", KeyEvent.VK_DOWN), BIT5); m.put(prefs.getInt("keyLeft1", KeyEvent.VK_LEFT), BIT6); m.put(prefs.getInt("keyRight1", KeyEvent.VK_RIGHT), BIT7); m.put(prefs.getInt("keyA1", KeyEvent.VK_X), BIT0); m.put(prefs.getInt("keyB1", KeyEvent.VK_Z), BIT1); m.put(prefs.getInt("keySelect1", KeyEvent.VK_SHIFT), BIT2); m.put(prefs.getInt("keyStart1", KeyEvent.VK_ENTER), BIT3); break; case 1: default: m.put(prefs.getInt("keyUp2", KeyEvent.VK_W), BIT4); m.put(prefs.getInt("keyDown2", KeyEvent.VK_S), BIT5); m.put(prefs.getInt("keyLeft2", KeyEvent.VK_A), BIT6); m.put(prefs.getInt("keyRight2", KeyEvent.VK_D), BIT7); m.put(prefs.getInt("keyA2", KeyEvent.VK_G), BIT0); m.put(prefs.getInt("keyB2", KeyEvent.VK_F), BIT1); m.put(prefs.getInt("keySelect2", KeyEvent.VK_R), BIT2); m.put(prefs.getInt("keyStart2", KeyEvent.VK_T), BIT3); break; } Controller[] controllers = getAvailablePadControllers(); if (controllers.length > controllernum) { this.gameController = controllers[controllernum]; PrefsSingleton.get().put("controller" + controllernum, gameController.getName()); System.err.println(controllernum + 1 + ". " + gameController.getName()); this.buttons = getButtons(controllers[controllernum]); } else { PrefsSingleton.get().put("controller" + controllernum, ""); this.gameController = null; this.buttons = null; } }
Example #13
Source File: ControllerImpl.java From halfnes with GNU General Public License v3.0 | 4 votes |
/** * Return the available buttons on this controller (by priority order). */ private static Component[] getButtons(Controller controller) { List<Component> buttons = new ArrayList<>(); // Get this controllers components (buttons and axis) Component[] components = controller.getComponents(); for (Component component : components) { if (component.getIdentifier() instanceof Component.Identifier.Button) { buttons.add(component); } } return buttons.toArray(new Component[0]); }
Example #14
Source File: ControllerImpl.java From halfnes with GNU General Public License v3.0 | 4 votes |
/** * This method detects the available joysticks / gamepads on the computer * and return them in a list. * * @return List of available joysticks / gamepads connected to the computer */ private static Controller[] getAvailablePadControllers() { List<Controller> gameControllers = new ArrayList<>(); // Get a list of the controllers JInput knows about and can interact // with Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers(); // Check the useable controllers (gamepads or joysticks with at least 2 // axis and 2 buttons) for (Controller controller : controllers) { if ((controller.getType() == Controller.Type.GAMEPAD) || (controller.getType() == Controller.Type.STICK)) { int nbOfAxis = 0; // Get this controllers components (buttons and axis) Component[] components = controller.getComponents(); // Check the availability of X/Y axis and at least 2 buttons // (for A and B, because select and start can use the keyboard) for (Component component : components) { if ((component.getIdentifier() == Component.Identifier.Axis.X) || (component.getIdentifier() == Component.Identifier.Axis.Y)) { nbOfAxis++; } } if ((nbOfAxis >= 2) && (getButtons(controller).length >= 2)) { // Valid game controller gameControllers.add(controller); } } } return gameControllers.toArray(new Controller[0]); }
Example #15
Source File: GameControllerPanel.java From zxpoly with GNU General Public License v3.0 | 4 votes |
public GameControllerPanel(final KeyboardKempstonAndTapeIn module) { super(new GridBagLayout()); this.module = module; final List<Controller> controllers = module.getDetectedControllers().stream() .sorted(comparing(Controller::getName)) .collect(toList()); final List<Gadapter> activeGadapters = module.getActiveGadapters(); final GridBagConstraints constraints = new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); for (final Controller c : controllers) { final GadapterRecord newRecord = new GadapterRecord(c, activeGadapters); this.add(newRecord, constraints); } }
Example #16
Source File: KeyboardKempstonAndTapeIn.java From zxpoly with GNU General Public License v3.0 | 4 votes |
public Gadapter makeGadapter(final Controller controller, final GadapterType type) { switch (type) { case KEMPSTON: return new GadapterKempston(this, controller); case INTERFACEII_PLAYER1: return new GadapterInterface2(0, this, controller); case INTERFACEII_PLAYER2: return new GadapterInterface2(1, this, controller); default: throw new Error("Unexpected destination: " + type); } }
Example #17
Source File: InputManager.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
static public void update(boolean isMouseIn) { Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers(); advanceKeyStates(); int numMice=0; //int numSticks=0; //int numKeyboard=0; for(int i=0;i<ca.length;i++){ // poll all controllers once per frame if(!ca[i].poll()) { // TODO poll failed, device disconnected? return; } //Log.message(ca[i].getType()); if(ca[i].getType()==Controller.Type.MOUSE) { if(numMice==0) { if(isMouseIn) updateMouse(ca[i]); } ++numMice; } else if(ca[i].getType()==Controller.Type.STICK) { //if(numSticks==0) { updateStick(ca[i]); //} //++numSticks; } else if(ca[i].getType()==Controller.Type.KEYBOARD) { //if(numKeyboard==0) { updateKeyboard(ca[i]); //} //++numKeyboard; } } //Log.message(numSticks+"/"+numMice+"/"+numKeyboard); }
Example #18
Source File: GadapterInterface2.java From zxpoly with GNU General Public License v3.0 | 3 votes |
public GadapterInterface2(final int index, KeyboardKempstonAndTapeIn keyboardModule, Controller controller) { super(keyboardModule, controller, GadapterType.INTERFACEII_PLAYER1); this.playerIndex = index; }
Example #19
Source File: GadapterKempston.java From zxpoly with GNU General Public License v3.0 | 3 votes |
public GadapterKempston(KeyboardKempstonAndTapeIn keyboardModule, Controller controller) { super(keyboardModule, controller, GadapterType.KEMPSTON); }
Example #20
Source File: Gadapter.java From zxpoly with GNU General Public License v3.0 | 3 votes |
public Controller getController() { return this.controller; }
Example #21
Source File: Gadapter.java From zxpoly with GNU General Public License v3.0 | 3 votes |
Gadapter(final KeyboardKempstonAndTapeIn keyboardModule, final Controller controller, final GadapterType destination) { this.parent = keyboardModule; this.controller = controller; this.destination = destination; }
Example #22
Source File: KeyboardKempstonAndTapeIn.java From zxpoly with GNU General Public License v3.0 | 3 votes |
public List<Controller> getDetectedControllers() { return this.detectedControllers == null ? Collections.emptyList() : this.detectedControllers; }
Example #23
Source File: KeyboardKempstonAndTapeIn.java From zxpoly with GNU General Public License v3.0 | 3 votes |
private boolean isControllerTypeAllowed(final Controller.Type type) { return type == Controller.Type.FINGERSTICK || type == Controller.Type.STICK || type == Controller.Type.RUDDER || type == Controller.Type.GAMEPAD; }
Example #24
Source File: InputManager.java From Robot-Overlord-App with GNU General Public License v2.0 | 2 votes |
static public void updateKeyboard(Controller controller) { //* Component[] components = controller.getComponents(); for(int j=0;j<components.length;j++){ Component c = components[j]; /*/ EventQueue queue = controller.getEventQueue(); Event event = new Event(); while(queue.getNextEvent(event)) { Component c = event.getComponent(); //*/ /* Log.message("\t"+c.getName()+ ":"+c.getIdentifier().getName()+ ":"+(c.isAnalog()?"Abs":"Rel")+ ":"+(c.isAnalog()?"Analog":"Digital")+ ":"+(c.getDeadZone())+ ":"+(c.getPollData()));//*/ if(!c.isAnalog()) { // digital if(c.getPollData()==1) { //Log.message(c.getIdentifier().getName()); if(c.getIdentifier()==Identifier.Key.DELETE ) setRawValue(Source.KEY_DELETE,1); if(c.getIdentifier()==Identifier.Key.RETURN ) setRawValue(Source.KEY_RETURN,1); if(c.getIdentifier()==Identifier.Key.LSHIFT ) setRawValue(Source.KEY_LSHIFT,1); if(c.getIdentifier()==Identifier.Key.RSHIFT ) setRawValue(Source.KEY_RSHIFT,1); if(c.getIdentifier()==Identifier.Key.RALT ) setRawValue(Source.KEY_RALT,1); if(c.getIdentifier()==Identifier.Key.LALT ) setRawValue(Source.KEY_LALT,1); if(c.getIdentifier()==Identifier.Key.RCONTROL) setRawValue(Source.KEY_RCONTROL,1); if(c.getIdentifier()==Identifier.Key.LCONTROL) setRawValue(Source.KEY_LCONTROL,1); if(c.getIdentifier()==Identifier.Key.BACK ) setRawValue(Source.KEY_BACKSPACE,1); if(c.getIdentifier()==Identifier.Key.Q ) setRawValue(Source.KEY_Q,1); if(c.getIdentifier()==Identifier.Key.E ) setRawValue(Source.KEY_E,1); if(c.getIdentifier()==Identifier.Key.W ) setRawValue(Source.KEY_W,1); if(c.getIdentifier()==Identifier.Key.A ) setRawValue(Source.KEY_A,1); if(c.getIdentifier()==Identifier.Key.S ) setRawValue(Source.KEY_S,1); if(c.getIdentifier()==Identifier.Key.D ) setRawValue(Source.KEY_D,1); if(c.getIdentifier()==Identifier.Key.NUMPADENTER) setRawValue(Source.KEY_ENTER,1); if(c.getIdentifier()==Identifier.Key.TAB) setRawValue(Source.KEY_TAB,1); if(c.getIdentifier()==Identifier.Key._0) setRawValue(Source.KEY_0,1); if(c.getIdentifier()==Identifier.Key._1) setRawValue(Source.KEY_1,1); if(c.getIdentifier()==Identifier.Key._2) setRawValue(Source.KEY_2,1); if(c.getIdentifier()==Identifier.Key._3) setRawValue(Source.KEY_3,1); if(c.getIdentifier()==Identifier.Key._4) setRawValue(Source.KEY_4,1); if(c.getIdentifier()==Identifier.Key._5) setRawValue(Source.KEY_5,1); if(c.getIdentifier()==Identifier.Key._6) setRawValue(Source.KEY_6,1); if(c.getIdentifier()==Identifier.Key._7) setRawValue(Source.KEY_7,1); if(c.getIdentifier()==Identifier.Key._8) setRawValue(Source.KEY_8,1); if(c.getIdentifier()==Identifier.Key._9) setRawValue(Source.KEY_9,1); if(c.getIdentifier()==Identifier.Key.ESCAPE) setRawValue(Source.KEY_ESCAPE,1); if(c.getIdentifier()==Identifier.Key.SLASH) setRawValue(Source.KEY_FRONTSLASH,1); if(c.getIdentifier()==Identifier.Key.BACKSLASH) setRawValue(Source.KEY_BACKSLASH,1); if(c.getIdentifier()==Identifier.Key.EQUALS) setRawValue(Source.KEY_PLUS,1); if(c.getIdentifier()==Identifier.Key.ADD) setRawValue(Source.KEY_PLUS,1); if(c.getIdentifier()==Identifier.Key.COMMA) setRawValue(Source.KEY_LESSTHAN,1); if(c.getIdentifier()==Identifier.Key.PERIOD) setRawValue(Source.KEY_GREATERTHAN,1); if(c.getIdentifier()==Identifier.Key.SPACE) setRawValue(Source.KEY_SPACE,1); if(c.getIdentifier()==Identifier.Key.GRAVE) setRawValue(Source.KEY_TILDE,1); if(c.getIdentifier()==Identifier.Key.F1) setRawValue(Source.KEY_F1,1); if(c.getIdentifier()==Identifier.Key.F2) setRawValue(Source.KEY_F2,1); if(c.getIdentifier()==Identifier.Key.F3) setRawValue(Source.KEY_F3,1); if(c.getIdentifier()==Identifier.Key.F4) setRawValue(Source.KEY_F4,1); if(c.getIdentifier()==Identifier.Key.F5) setRawValue(Source.KEY_F5,1); if(c.getIdentifier()==Identifier.Key.F6) setRawValue(Source.KEY_F6,1); if(c.getIdentifier()==Identifier.Key.F7) setRawValue(Source.KEY_F7,1); if(c.getIdentifier()==Identifier.Key.F8) setRawValue(Source.KEY_F8,1); if(c.getIdentifier()==Identifier.Key.F9) setRawValue(Source.KEY_F9,1); if(c.getIdentifier()==Identifier.Key.F10) setRawValue(Source.KEY_F10,1); if(c.getIdentifier()==Identifier.Key.F11) setRawValue(Source.KEY_F11,1); if(c.getIdentifier()==Identifier.Key.F12) setRawValue(Source.KEY_F12,1); } } } }
Example #25
Source File: InputManager.java From Robot-Overlord-App with GNU General Public License v2.0 | 1 votes |
static public void updateStick(Controller controller) { //* Component[] components = controller.getComponents(); for(int j=0;j<components.length;j++){ Component c = components[j]; /*/ EventQueue queue = controller.getEventQueue(); Event event = new Event(); while(queue.getNextEvent(event)) { Component c = event.getComponent(); //*/ /* Log.message("\t"+c.getName()+ ":"+c.getIdentifier().getName()+ ":"+(c.isAnalog()?"Abs":"Rel")+ ":"+(c.isAnalog()?"Analog":"Digital")+ ":"+(c.getDeadZone())+ ":"+(c.getPollData()));//*/ if(c.isAnalog()) { double v = c.getPollData(); final double DEADZONE=0.1; double deadzone = DEADZONE; // c.getDeadZone() is very small? if(v> deadzone) v=(v-deadzone)/(1.0-deadzone); // scale 0....1 else if(v<-deadzone) v=(v+deadzone)/(1.0-deadzone); // scale 0...-1 else continue; // inside dead zone, ignore. if(c.getIdentifier()==Identifier.Axis.Z ) setRawValue(Source.STICK_RX,v); // right analog stick, + is right -1 is left if(c.getIdentifier()==Identifier.Axis.RZ) setRawValue(Source.STICK_RY,v); // right analog stick, + is down -1 is up if(c.getIdentifier()==Identifier.Axis.RY) setRawValue(Source.STICK_R2,v); // R2, +1 is pressed -1 is unpressed if(c.getIdentifier()==Identifier.Axis.RX) setRawValue(Source.STICK_L2,v); // L2, +1 is pressed -1 is unpressed if(c.getIdentifier()==Identifier.Axis.X ) setRawValue(Source.STICK_LX,v); // left analog stick, +1 is right -1 is left if(c.getIdentifier()==Identifier.Axis.Y ) setRawValue(Source.STICK_LY,v); // left analog stick, -1 is up +1 is down } else { // digital if(c.getPollData()==1) { if(c.getIdentifier()==Identifier.Button._0 ) setRawValue(Source.STICK_SQUARE,1); // square if(c.getIdentifier()==Identifier.Button._1 ) setRawValue(Source.STICK_X,1); // x if(c.getIdentifier()==Identifier.Button._2 ) setRawValue(Source.STICK_CIRCLE,1); // circle if(c.getIdentifier()==Identifier.Button._3 ) setRawValue(Source.STICK_TRIANGLE,1); // triangle if(c.getIdentifier()==Identifier.Button._4 ) setRawValue(Source.STICK_L1,1); // L1? if(c.getIdentifier()==Identifier.Button._5 ) setRawValue(Source.STICK_R1,1); // R1? if(c.getIdentifier()==Identifier.Button._8 ) setRawValue(Source.STICK_SHARE,1); // share button if(c.getIdentifier()==Identifier.Button._9 ) setRawValue(Source.STICK_OPTIONS,1); // option button if(c.getIdentifier()==Identifier.Button._13) setRawValue(Source.STICK_TOUCHPAD,1); // touch pad } if(c.getIdentifier()==Identifier.Axis.POV) { // D-pad buttons float pollData = c.getPollData(); if(pollData == Component.POV.DOWN ) setRawValue(Source.STICK_DPADY,-1); else if(pollData == Component.POV.UP ) setRawValue(Source.STICK_DPADY,1); else if(pollData == Component.POV.LEFT ) setRawValue(Source.STICK_DPADX,-1); else if(pollData == Component.POV.RIGHT) setRawValue(Source.STICK_DPADX,1); } } } }