net.java.games.input.Component.Identifier Java Examples
The following examples show how to use
net.java.games.input.Component.Identifier.
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: JInputJoyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void addButton( Component comp ) { logger.log(Level.FINE, "Adding button: \"{0}\" id:" + comp.getIdentifier(), comp); Identifier id = comp.getIdentifier(); if( !(id instanceof Button) ) { throw new IllegalArgumentException( "Component is not an button:" + comp ); } String name = comp.getName(); String original = id.getName(); try { Integer.parseInt(original); } catch (NumberFormatException e){ original = String.valueOf(buttonIndex.size()); } String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); if( logicalId != original ) { logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId); } JoystickButton button = new DefaultJoystickButton( getInputManager(), this, getButtonCount(), name, logicalId ); addButton(button); buttonIndex.put( comp, button ); }
Example #2
Source File: JInputJoyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void addComponent( Component comp ) { Identifier id = comp.getIdentifier(); if( id instanceof Button ) { addButton(comp); } else if( id instanceof Axis ) { addAxis(comp); } else { logger.log(Level.FINE, "Ignoring: \"{0}\"", comp); } }
Example #3
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 #4
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 #5
Source File: JInputJoyInput.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void addAxis( Component comp ) { logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + comp.getIdentifier(), comp ); Identifier id = comp.getIdentifier(); if( !(id instanceof Axis) ) { throw new IllegalArgumentException( "Component is not an axis:" + comp ); } String name = comp.getName(); String original = id.getName(); String logicalId = JoystickCompatibilityMappings.remapComponent( controller.getName(), original ); if( logicalId != original ) { logger.log(Level.FINE, "Remapped:" + original + " to:" + logicalId); } JoystickAxis axis = new DefaultJoystickAxis( getInputManager(), this, getAxisCount(), name, logicalId, comp.isAnalog(), comp.isRelative(), comp.getDeadZone() ); addAxis(axis); axisIndex.put( comp, axis ); // Support the X/Y axis indexes if( id == Axis.X ) { xAxis = axis; } else if( id == Axis.Y ) { yAxis = axis; } else if( id == Axis.POV ) { // Add two fake axes for the JME provided convenience // axes: AXIS_POV_X, AXIS_POV_Y povX = new DefaultJoystickAxis( getInputManager(), this, getAxisCount(), JoystickAxis.POV_X, id.getName() + "_x", comp.isAnalog(), comp.isRelative(), comp.getDeadZone() ); logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + id.getName() + "_x", povX.getName() ); addAxis(povX); povY = new DefaultJoystickAxis( getInputManager(), this, getAxisCount(), JoystickAxis.POV_Y, id.getName() + "_y", comp.isAnalog(), comp.isRelative(), comp.getDeadZone() ); logger.log(Level.FINE, "Adding axis: \"{0}\" id:" + id.getName() + "_y", povY.getName() ); addAxis(povY); } }
Example #6
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 #7
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); } } } }