Joystick Callback Functions?


Hi everyone,

I have been reading the documentation regarding joystick input and it sounds like if I want to use gamepads/joysticks in my application, I must manually check the state of each button/axis for each connected joystick every time my input handling method is called. This seems inneficient and I cannot help but wonder if I missed something in the docs. I see that you can set a callback method to be triggered when keyboard keys are pressed via glfwSetKeyCallback(). Is there any equivalent of this for joysticks? The only slightly related method I can find is for a callback function to be triggered when joysticks are connected/disconnected.


An issue for Joystick callbacks exists on the GLFW github site. This is currently tabled for the 3.3 milestone, but I don’t know what the progress status is on this individual item.


Facing the same issue, I customized the latest master to add joystick events, and it’s actually a pretty simple change. But it’s only for X11. (Since I’ll also need this on Windows and Wayland, I’ll probably customize those at some point as well.)

Here’s the patch if you’re interested: