I’m making a program in which I would like to include support for joysticks/controllers and since I’m using glfw for it I was looking to implement it with the methods provided by glfw. Every of the provided methods do work as intended (axis/button polling, joystick name) but it seems there is nothing to obtain Axis/Button names. When binding joystick buttons to actions in the settings screen, I’m searching for a way to obtain a name for the pressed button in order to display it to the user (instead of displaying button 1, button 2…). Is there any way to do this with glfw?
There’s no direct method for doing this. You could get the joystick name and then use that to determine the controller type and use a table similar to this one for Xbox 360 controller, or let users name their buttons. The Xbox 360 controller names are set here for example.
This has always been a tricky issue in PC development - I’m not aware of a general approach to solving this. XInput on PC does specify the names of inputs but that’s only one of many APIs GLFW sits on.
Note: for reference see the documentation for Joystick/controllers.
Thanks for the fast reply!
I see. The “xbox 360 controller names” page was helpful, I guess I can use button names for xbox360 controllers and indexes for the rest of controllers.