How to use glfwGetGamepadState

Started by coinklepto, May 23, 2022, 03:26:41

Previous topic - Next topic


I've been messing around with getting input from a gamepad using the joystick methods of GLFW. However I noticed that the trigger input and the joystick input are both stored as an axis value. This is a bit of a problem because I want to interpret each axis value differently. For example, the joystick as two "buttons" like a directional-pad and the trigger as a single button. Since the axis values are stored from glfwGetJoystickAxes as a FloatBuffer, I don't believe there is a way to differentiate between a trigger axis and a joystick axis. That leads me to think that the only way to do so is to use glfwGetGamepadState. However, I'm not really sure how to use this method, and I can't really find lwjgl specific examples about it. I see from the documentation that it takes a GLFWGamepadState object as an argument, but I'm not sure what the proper way to construct it is. Any help is greatly appreciated. Thanks!