Commit b57f635f authored by Evan Tang's avatar Evan Tang Committed by Alexandre Julliard

winebus.sys: Report unique serial numbers for SDL devices.

parent 90149034
...@@ -120,6 +120,7 @@ static Uint16 (*pSDL_JoystickGetProduct)(SDL_Joystick * joystick); ...@@ -120,6 +120,7 @@ static Uint16 (*pSDL_JoystickGetProduct)(SDL_Joystick * joystick);
static Uint16 (*pSDL_JoystickGetProductVersion)(SDL_Joystick * joystick); static Uint16 (*pSDL_JoystickGetProductVersion)(SDL_Joystick * joystick);
static Uint16 (*pSDL_JoystickGetVendor)(SDL_Joystick * joystick); static Uint16 (*pSDL_JoystickGetVendor)(SDL_Joystick * joystick);
static SDL_JoystickType (*pSDL_JoystickGetType)(SDL_Joystick * joystick); static SDL_JoystickType (*pSDL_JoystickGetType)(SDL_Joystick * joystick);
static const char *(*pSDL_JoystickGetSerial)(SDL_Joystick * joystick);
/* internal bits for extended rumble support, SDL_Haptic types are 16-bits */ /* internal bits for extended rumble support, SDL_Haptic types are 16-bits */
#define WINE_SDL_JOYSTICK_RUMBLE 0x40000000 /* using SDL_JoystickRumble API */ #define WINE_SDL_JOYSTICK_RUMBLE 0x40000000 /* using SDL_JoystickRumble API */
...@@ -936,9 +937,8 @@ static void sdl_add_device(unsigned int index) ...@@ -936,9 +937,8 @@ static void sdl_add_device(unsigned int index)
SDL_Joystick* joystick; SDL_Joystick* joystick;
SDL_JoystickID id; SDL_JoystickID id;
SDL_JoystickGUID guid;
SDL_GameController *controller = NULL; SDL_GameController *controller = NULL;
const char *product; const char *product, *sdl_serial;
char guid_str[33], buffer[ARRAY_SIZE(desc.product)]; char guid_str[33], buffer[ARRAY_SIZE(desc.product)];
int axis_count, axis_offset; int axis_count, axis_offset;
...@@ -969,9 +969,19 @@ static void sdl_add_device(unsigned int index) ...@@ -969,9 +969,19 @@ static void sdl_add_device(unsigned int index)
desc.version = 0; desc.version = 0;
} }
guid = pSDL_JoystickGetGUID(joystick); if (pSDL_JoystickGetSerial && (sdl_serial = pSDL_JoystickGetSerial(joystick)))
pSDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); {
ntdll_umbstowcs(guid_str, strlen(guid_str) + 1, desc.serialnumber, ARRAY_SIZE(desc.serialnumber)); ntdll_umbstowcs(sdl_serial, strlen(sdl_serial) + 1, desc.serialnumber, ARRAY_SIZE(desc.serialnumber));
}
else
{
/* Overcooked! All You Can Eat only adds controllers with unique serial numbers
* Prefer keeping serial numbers unique over keeping them consistent across runs */
pSDL_JoystickGetGUIDString(pSDL_JoystickGetGUID(joystick), guid_str, sizeof(guid_str));
snprintf(buffer, sizeof(buffer), "%s.%d", guid_str, index);
TRACE("Making up serial number for %s: %s\n", product, buffer);
ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc.serialnumber, ARRAY_SIZE(desc.serialnumber));
}
if (controller) if (controller)
{ {
...@@ -1126,6 +1136,7 @@ NTSTATUS sdl_bus_init(void *args) ...@@ -1126,6 +1136,7 @@ NTSTATUS sdl_bus_init(void *args)
pSDL_JoystickGetProductVersion = dlsym(sdl_handle, "SDL_JoystickGetProductVersion"); pSDL_JoystickGetProductVersion = dlsym(sdl_handle, "SDL_JoystickGetProductVersion");
pSDL_JoystickGetVendor = dlsym(sdl_handle, "SDL_JoystickGetVendor"); pSDL_JoystickGetVendor = dlsym(sdl_handle, "SDL_JoystickGetVendor");
pSDL_JoystickGetType = dlsym(sdl_handle, "SDL_JoystickGetType"); pSDL_JoystickGetType = dlsym(sdl_handle, "SDL_JoystickGetType");
pSDL_JoystickGetSerial = dlsym(sdl_handle, "SDL_JoystickGetSerial");
if (pSDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) < 0) if (pSDL_Init(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) < 0)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment