mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-21 10:48:14 +00:00
Added custom names for some controllers
This commit is contained in:
@@ -521,6 +521,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
||||
Uint16 product = 0;
|
||||
Uint16 version = 0;
|
||||
WCHAR hidPath[MAX_PATH];
|
||||
const char *name;
|
||||
|
||||
if (devtype == DI8DEVTYPE_SUPPLEMENTAL) {
|
||||
/* Add any supplemental devices that should be ignored here */
|
||||
@@ -605,14 +606,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
||||
|
||||
SDL_zerop(pNewJoystick);
|
||||
SDL_wcslcpy(pNewJoystick->hidPath, hidPath, SDL_arraysize(pNewJoystick->hidPath));
|
||||
pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName);
|
||||
if (!pNewJoystick->joystickname) {
|
||||
SDL_free(pNewJoystick);
|
||||
return DIENUM_CONTINUE; /* better luck next time? */
|
||||
}
|
||||
|
||||
SDL_memcpy(&pNewJoystick->dxdevice, pdidInstance, sizeof(DIDEVICEINSTANCE));
|
||||
|
||||
SDL_memset(pNewJoystick->guid.data, 0, sizeof(pNewJoystick->guid.data));
|
||||
|
||||
guid16 = (Uint16 *)pNewJoystick->guid.data;
|
||||
@@ -635,6 +629,17 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
||||
SDL_strlcpy((char*)guid16, pNewJoystick->joystickname, sizeof(pNewJoystick->guid.data) - 4);
|
||||
}
|
||||
|
||||
name = SDL_GetCustomJoystickName(vendor, product);
|
||||
if (name) {
|
||||
pNewJoystick->joystickname = SDL_strdup(name);
|
||||
} else {
|
||||
pNewJoystick->joystickname = WIN_StringToUTF8(pdidInstance->tszProductName);
|
||||
}
|
||||
if (!pNewJoystick->joystickname) {
|
||||
SDL_free(pNewJoystick);
|
||||
return DIENUM_CONTINUE; /* better luck next time? */
|
||||
}
|
||||
|
||||
if (SDL_strstr(pNewJoystick->joystickname, " XINPUT ") != NULL) {
|
||||
/* This is a duplicate interface for a controller that will show up with XInput,
|
||||
e.g. Xbox One Elite Series 2 in Bluetooth mode.
|
||||
|
Reference in New Issue
Block a user