SDL2 button name+colour library

SDL2 button name+colour library

Postby c_xong » 06 Nov 2015, 01:13

I've recently created a small C library intended to work with SDL2, which gives you button/axis names and colours. So if you want to tell your player in-game to "press the A button", but the player has a PS4 controller, the library can tell you that "their A button is actually teal and named X".

https://github.com/cxong/SDL_JoystickButtonNames

Controller handling is hard because usually the buttons and axes are referenced by index, e.g. button 0 or axis 3, and their layout is all inconsistent. SDL2's method is to map all controllers to an "ideal controller" - the Xbox 360 - so it doesn't matter what your controller is, the right face button is always B, for example. The problem with this is, the right face button is not always called "B", so if you use SDL2's names in your game, you'll confuse players who aren't using the Xbox 360 controller. That's where this library comes in: it can tell you what the real name (and colour) of the B button is.

Check out the project page for more details; there's a sample program you can build with CMake to detect all the buttons/axes on your controllers.

This project needs your help! So far I only have 2 controllers in the database because that's all I have access to. If you have controllers, please try the examples out and see if the button names and colours match, and if not let me know so I can add them to the database.

Also, let me know if this is useful or how it can be improved. I know that ideally you would display an image or sprite representing the button but that seems too high level for an SDL2 library, so this was the next best thing.
Attachments
out_screen.png
out_screen.png (27.21 KiB) Viewed 3246 times
User avatar
c_xong
 
Posts: 234
Joined: 06 Sep 2013, 04:33

Who is online

Users browsing this forum: No registered users and 1 guest