From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winebus.sys/bus_sdl.c | 13 +------------ dlls/winebus.sys/main.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 91cb785fdff..3cf34b000d5 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -941,7 +941,7 @@ static void sdl_add_device(unsigned int index) SDL_JoystickType joystick_type; SDL_GameController *controller = NULL; const char *product, *sdl_serial; - char guid_str[33], buffer[ARRAY_SIZE(desc.product)]; + char buffer[ARRAY_SIZE(desc.product)]; int axis_count, axis_offset;
if ((joystick = pSDL_JoystickOpen(index)) == NULL) @@ -975,18 +975,7 @@ static void sdl_add_device(unsigned int index) }
if (pSDL_JoystickGetSerial && (sdl_serial = pSDL_JoystickGetSerial(joystick))) - { 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) { diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index ba8603204d4..0a871269fa9 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -289,6 +289,18 @@ static void remove_pending_irps(DEVICE_OBJECT *device) } }
+static void make_unique_serial(struct device_extension *device) +{ + struct device_extension *ext; + + LIST_FOR_EACH_ENTRY(ext, &device_list, struct device_extension, entry) + if (!wcscmp(device->desc.serialnumber, ext->desc.serialnumber)) break; + if (&ext->entry == &device_list && *device->desc.serialnumber) return; + + swprintf(device->desc.serialnumber, ARRAY_SIZE(device->desc.serialnumber), L"%04x%08x%04x%04x", + device->index, device->desc.input, device->desc.pid, device->desc.vid); +} + static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, UINT64 unix_device) { struct device_extension *ext; @@ -333,6 +345,10 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, UINT64 uni InitializeCriticalSectionEx(&ext->cs, 0, RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO); ext->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": cs");
+ /* Overcooked! All You Can Eat only adds controllers with unique serial numbers + * Prefer keeping serial numbers unique over keeping them consistent across runs */ + make_unique_serial(ext); + /* add to list of pnp devices */ if (before) list_add_before(before, &ext->entry);