From f09e0af7aa1da70343ae27fee79db9acbe3f3701 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Mon, 4 Jan 2021 01:23:50 +0300 Subject: [PATCH] SDL_dinputjoystick.c (IsXInputDevice): adjust to be ANSI/UNICODE-agnostic cf. bug #5435. --- src/joystick/windows/SDL_dinputjoystick.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index bc86e8be1..0c4ffe161 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -232,6 +232,12 @@ SetDIerror(const char *function, HRESULT code) return SDL_SetError("%s() DirectX error 0x%8.8lx", function, code); } +#ifdef UNICODE +#define SDL_tcsstr SDL_wcsstr +#else +#define SDL_tcsstr SDL_strstr +#endif + #if 0 /* Microsoft recommended implementation, but slower than checking raw devices */ #define COBJMACROS #include @@ -241,7 +247,7 @@ static const IID CLSID_WbemLocator = { 0x4590f811, 0x1d3a, 0x11d0,{ 0x89, 0x1f, static const IID IID_IWbemLocator = { 0xdc12a687, 0x737f, 0x11cf,{ 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } }; static SDL_bool -WIN_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) +WIN_IsXInputDevice(const TCHAR *name, const GUID* pGuidProductFromDirectInput) { IWbemLocator* pIWbemLocator = NULL; IEnumWbemClassObject* pEnumDevices = NULL; @@ -260,7 +266,7 @@ WIN_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) return SDL_FALSE; } - if (SDL_wcsstr(name, L" XINPUT ") != NULL) { + if (SDL_tcsstr(name, TEXT(" 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. */ @@ -371,7 +377,7 @@ LCleanup: #endif /* 0 */ static SDL_bool -SDL_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) +SDL_IsXInputDevice(const TCHAR *name, const GUID* pGuidProductFromDirectInput) { UINT i; @@ -379,7 +385,7 @@ SDL_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) return SDL_FALSE; } - if (SDL_wcsstr(name, L" XINPUT ") != NULL) { + if (SDL_tcsstr(name, TEXT(" 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. */