@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)); } } } }
} else { if (axis.isChanged()) { JoyAxisEvent event = new JoyAxisEvent(axis, axis.getJoystickAxisValue());
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){