/** * The button index. * * @return button index. * * @see Joystick#assignButton(java.lang.String, int) */ public int getButtonIndex() { return button.getButtonId(); }
@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)); } } } }
/** * The button index. * * @return button index. * * @see Joystick#assignButton(java.lang.String, int) */ public int getButtonIndex() { return button.getButtonId(); }
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)); } } }