From 0353b8b3ffcbaa102d36fa7e8f2bb218a1374820 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 26 Jan 2016 01:57:30 +0100 Subject: pkgs: Add a small utility to dump joystick GUIDs SDL 2 has an environment variable called SDL_GAMECONTROLLERCONFIG, which lists button/axis mappings of various game controllers attached to the system. The game controllers are themselves identified using a GUID which is SDL 2 specific and this tool is there to just dump the name of a particular game controller along with the GUID so it's easier to get the GUID. Signed-off-by: aszlig --- pkgs/list-gamecontrollers/list-gc.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pkgs/list-gamecontrollers/list-gc.c (limited to 'pkgs/list-gamecontrollers/list-gc.c') diff --git a/pkgs/list-gamecontrollers/list-gc.c b/pkgs/list-gamecontrollers/list-gc.c new file mode 100644 index 00000000..f40b7da6 --- /dev/null +++ b/pkgs/list-gamecontrollers/list-gc.c @@ -0,0 +1,31 @@ +#include + +void dump_guid(SDL_Joystick *js) { + SDL_JoystickGUID guid; + const char *name; + char guidstr[33]; + + guid = SDL_JoystickGetGUID(js); + name = SDL_JoystickName(js); + SDL_JoystickGetGUIDString(guid, guidstr, sizeof(guidstr)); + + printf("%s: %s\n", name, guidstr); +} + +int main() +{ + int i; + SDL_Joystick *js; + + SDL_Init(SDL_INIT_JOYSTICK); + atexit(SDL_Quit); + + for (i = 0; i < SDL_NumJoysticks(); ++i) { + if ((js = SDL_JoystickOpen(i)) != NULL) { + dump_guid(js); + SDL_JoystickClose(js); + } + } + + return EXIT_SUCCESS; +} -- cgit 1.4.1