Skip to content

Commit

Permalink
Log GUID for unknown gamepads.
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-seddon committed Jul 11, 2024
1 parent 459468c commit 658e05b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/b2/joysticks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 658e05b

Please sign in to comment.