Rémi Bernon (@rbernon) commented about dlls/winebus.sys/bus_sdl.c:
+ int offset_name_length = snprintf(NULL, 0, " %d", i+1); + /* If there is not enough place to append " %d" replace some of the last characters. */ + int offset_name_start = min(strlen(str), ARRAY_SIZE(desc.product) - 1 - offset_name_length); + /* Ensure we only write in desc.product and not past it. + * Otherwise just keep the name as is. */ + if (offset_name_length < 12 && offset_name_start >= 0 && offset_name_start + offset_name_length < ARRAY_SIZE(desc.product)) + { + snprintf(offset_name, 12, " %d", i+1); + ntdll_umbstowcs(offset_name, 12, desc.product + offset_name_start, 12); + } + TRACE("%s id %d, split for axis %d-%d.\n", controller ? "controller" : "joystick", id, 6*i, min(axis_count, 6*(i+1)-1)); + } + + bus_event_queue_device_created(&event_queue, &impl->unix_device, &desc); + ++i; + } while (options.split_controllers && !desc.is_gamepad && 6*i < axis_count); This could be simpler, without needing a special i != 0 case. You can fill the product buffer with something like that in the loop, before the `hid_device_create` and original `TRACE` call:
```C++ char buffer[ARRAY_SIZE(desc.product)]; if (axis_offset) snprintf(buffer, ARRAY_SIZE(buffer), "%s %u", product, axis_offset / 6); else snprintf(buffer, ARRAY_SIZE(buffer), "%s", product); ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc.product, ARRAY_SIZE(desc.product)); ``` With `product` the string retrieved from pSDL_JoystickName, replaced with a default value if it was `NULL`. Imho you could use a for loop there, and replace i with an axis_offset variable. The increment would depend on `options.split_controllers`. The `desc.is_gamepad` case above should set `axis_count = 6`, so you don't have to bother about afterwards. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/181#note_1650