summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2022-08-19 01:09:34 +1000
committer Vas Crabb <vas@vastheman.com>2022-08-19 01:09:34 +1000
commit91fb8e8e11869180df27f2a8ed435519187e7287 (patch)
tree91a9f7b51d595ad96d95df8814da33113025697d /src/osd/modules
parent201b0936bbd2d2ed85b7ab02e28a1a51c71815f0 (diff)
osd/modules/input: Include device serial number in ID when available for SDL joysticks.
Diffstat (limited to 'src/osd/modules')
-rw-r--r--src/osd/modules/input/input_sdl.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp
index a3bbe494194..2c8f604c9a2 100644
--- a/src/osd/modules/input/input_sdl.cpp
+++ b/src/osd/modules/input/input_sdl.cpp
@@ -1039,6 +1039,13 @@ public:
char guid_str[256];
guid_str[0] = '\0';
SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str) - 1);
+ char const *serial = nullptr;
+#if SDL_VERSION_ATLEAST(2, 0, 14)
+ serial = SDL_JoystickGetSerial(joy);
+#endif
+ std::string id(guid_str);
+ if (serial)
+ id.append(1, '-').append(serial);
sdl_joystick_device *const devinfo = m_sixaxis_mode
? &devicelist().create_device<sdl_sixaxis_joystick_device>(machine, name ? name : guid_str, guid_str, *this)
@@ -1053,20 +1060,16 @@ public:
devinfo->sdl_state.device = joy;
devinfo->sdl_state.joystick_id = SDL_JoystickInstanceID(joy);
devinfo->sdl_state.hapdevice = SDL_HapticOpenFromJoystick(joy);
-#if SDL_VERSION_ATLEAST(2, 0, 14)
- char const *const serial = SDL_JoystickGetSerial(joy);
if (serial)
devinfo->sdl_state.serial = serial;
- else
-#endif // SDL_VERSION_ATLEAST(2, 0, 14)
- devinfo->sdl_state.serial = std::nullopt;
- osd_printf_verbose("Joystick: %s [GUID %s] Vendor ID %04X, Product ID %04X, Revision %04X\n",
+ osd_printf_verbose("Joystick: %s [GUID %s] Vendor ID %04X, Product ID %04X, Revision %04X, Serial %s\n",
name ? name : "<nullptr>",
guid_str,
SDL_JoystickGetVendor(joy),
SDL_JoystickGetProduct(joy),
- SDL_JoystickGetProductVersion(joy));
+ SDL_JoystickGetProductVersion(joy),
+ serial ? serial : "<nullptr>");
osd_printf_verbose("Joystick: ... %d axes, %d buttons %d hats %d balls\n",
SDL_JoystickNumAxes(joy),
SDL_JoystickNumButtons(joy),