From 658e05bf7f071721892ee976031d1da35eb1a30e Mon Sep 17 00:00:00 2001 From: Tom Seddon Date: Thu, 11 Jul 2024 23:15:24 +0100 Subject: [PATCH] Log GUID for unknown gamepads. --- src/b2/joysticks.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/b2/joysticks.cpp b/src/b2/joysticks.cpp index 76e12f9b..31fb6694 100644 --- a/src/b2/joysticks.cpp +++ b/src/b2/joysticks.cpp @@ -132,12 +132,19 @@ static void OpenJoystick(int sdl_joystick_device_index, Messages *msg) { { if (!SDL_IsGameController(sdl_joystick_device_index)) { - if (const char *name = SDL_JoystickNameForIndex(sdl_joystick_device_index)) { - msg->w.f("Not a supported game controller: %s\n", name); + char guid[1000]; + SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(sdl_joystick_device_index), guid, sizeof guid); + + std::string name; + if (const char *p = SDL_JoystickNameForIndex(sdl_joystick_device_index)) { + name = p; } else { - msg->w.f("Not a supported game controller: joystick index %d\n", sdl_joystick_device_index); + name = "joystick index " + std::to_string(sdl_joystick_device_index); } + msg->w.f("Not a supported game controller: %s\n", name.c_str()); + msg->i.f("(%s GUID: %s)\n", name.c_str(), guid); + return; }