@Override public void update() { for (final Map.Entry<Integer, GlfwJoystick> entry : joysticks.entrySet()) { // Axes final FloatBuffer axisValues = glfwGetJoystickAxes(entry.getKey()); for (final JoystickAxis axis : entry.getValue().getAxes()) { final float value = axisValues.get(axis.getAxisId()); listener.onJoyAxisEvent(new JoyAxisEvent(axis, value)); } // Buttons final ByteBuffer byteBuffer = glfwGetJoystickButtons(entry.getKey()); for (final JoystickButton button : entry.getValue().getButtons()) { final boolean pressed = byteBuffer.get(button.getButtonId()) == GLFW_PRESS; if (joyButtonPressed.get(button) != pressed) { joyButtonPressed.put(button, pressed); listener.onJoyButtonEvent(new JoyButtonEvent(button, pressed)); } } } }
int joyId = evt.getJoyIndex(); int axis = evt.getAxisIndex(); float value = evt.getValue(); float effectiveDeadZone = Math.max(globalAxisDeadZone, evt.getAxis().getDeadZone()); if (value < effectiveDeadZone && value > -effectiveDeadZone) { int hash1 = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
int joyId = evt.getJoyIndex(); int axis = evt.getAxisIndex(); float value = evt.getValue(); if (value < axisDeadZone && value > -axisDeadZone) { int hash1 = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
int joyId = evt.getJoyIndex(); int axis = evt.getAxisIndex(); float value = evt.getValue(); float effectiveDeadZone = Math.max(globalAxisDeadZone, evt.getAxis().getDeadZone()); if (value < effectiveDeadZone && value > -effectiveDeadZone) { int hash1 = JoyAxisTrigger.joyAxisHash(joyId, axis, true);
} else { if (axis.isChanged()) { JoyAxisEvent event = new JoyAxisEvent(axis, axis.getJoystickAxisValue());
public void onJoyAxisEvent( JoyAxisEvent evt ) { if( log.isTraceEnabled() ) { log.trace("onJoyAxisEvent(axis:" + evt.getAxis() + ", val:" + evt.getValue() + ")"); } JoystickAxis a = evt.getAxis(); Joystick j = a.getJoystick(); float val = evt.getValue(); // Below a certain threshold, call the value 0 float aVal = Math.abs(val); if( aVal <= 0.01 || aVal <= Math.max(a.getDeadZone(), inputManager.getAxisDeadZone()) ) { val = 0; } Axis axis = joystickAxisMap.get(a); if( axis == null ) { log.warn("No axis mapping for:" + a ); return; } StateGroupIndex index = getIndex(axis, false); if( index == null ) return; index.updateValue(val); }
JoyAxisEvent axisEvent = new JoyAxisEvent(axis, value); joyInput.addEvent(axisEvent); consumed = true;
JoyAxisEvent evt1 = new JoyAxisEvent(stick.povX, x); JoyAxisEvent evt2 = new JoyAxisEvent(stick.povY, y); listener.onJoyAxisEvent(evt1); listener.onJoyAxisEvent(evt2); JoyAxisEvent evt = new JoyAxisEvent(axis, value); listener.onJoyAxisEvent(evt); }else if (id instanceof Button){
} else { if (axis.isChanged()) { joyInput.addEvent(new JoyAxisEvent(axis, axis.getJoystickAxisValue()));
public void update() { for (final Map.Entry<Integer, GlfwJoystick> entry : joysticks.entrySet()) { // Axes final FloatBuffer axisValues = glfwGetJoystickAxes(entry.getKey()); for (final JoystickAxis axis : entry.getValue().getAxes()) { final float value = axisValues.get(axis.getAxisId()); listener.onJoyAxisEvent(new JoyAxisEvent(axis, value)); } // Buttons final ByteBuffer byteBuffer = glfwGetJoystickButtons(entry.getKey()); for (final JoystickButton button : entry.getValue().getButtons()) { final boolean pressed = byteBuffer.get(button.getButtonId()) == GLFW_PRESS; listener.onJoyButtonEvent(new JoyButtonEvent(button, pressed)); } } }
JoyAxisEvent evt1 = new JoyAxisEvent(stick.povX, x); JoyAxisEvent evt2 = new JoyAxisEvent(stick.povY, y); listener.onJoyAxisEvent(evt1); listener.onJoyAxisEvent(evt2); JoyAxisEvent evt = new JoyAxisEvent(axis, value); listener.onJoyAxisEvent(evt); }else if (id instanceof Button){