From a594b850314f2fda4bef5f2880dd655059005da1 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Mon, 4 Jan 2021 10:00:30 +0300 Subject: [PATCH] use WIN_StringToUTF8W macro instead of WIN_StringToUTF8, where needed: i.e. where the string is known guaranteed to be WCHAR*, in: - SDL_dinputjoystick.c (WIN_IsXInputDevice): VARIANT->var is BSTR (WCHAR*) - SDL_rawinputjoystick.c (RAWINPUT_AddDevice): string is WCHAR* - SDL_windows_gaming_input.c (IEventHandler_CRawGameControllerVtbl_InvokeAdded): string is WCHAR* There should be more of these.. --- src/joystick/windows/SDL_dinputjoystick.c | 2 +- src/joystick/windows/SDL_rawinputjoystick.c | 4 ++-- src/joystick/windows/SDL_windows_gaming_input.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index a31b79a77..380fd46dd 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -315,7 +315,7 @@ WIN_IsXInputDevice(const TCHAR *name, const GUID* pGuidProductFromDirectInput) // Check if the device ID contains "IG_". If it does, then it's an XInput device // This information can not be found from DirectInput if (SDL_wcsstr(var.bstrVal, L"IG_")) { - char *bstrVal = WIN_StringToUTF8(var.bstrVal); + char *bstrVal = WIN_StringToUTF8W(var.bstrVal); // If it does, then get the VID/PID from var.bstrVal DWORD dwPid = 0, dwVid = 0, dwVidPid; diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 7b0c987e3..27c67a82f 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -733,10 +733,10 @@ RAWINPUT_AddDevice(HANDLE hDevice) WCHAR string[128]; if (SDL_HidD_GetManufacturerString(hFile, string, sizeof(string))) { - manufacturer_string = WIN_StringToUTF8(string); + manufacturer_string = WIN_StringToUTF8W(string); } if (SDL_HidD_GetProductString(hFile, string, sizeof(string))) { - product_string = WIN_StringToUTF8(string); + product_string = WIN_StringToUTF8W(string); } device->name = SDL_CreateJoystickName(device->vendor_id, device->product_id, manufacturer_string, product_string); diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index bf522b4c8..2fd36cd50 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -197,7 +197,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde if (SUCCEEDED(hr)) { PCWSTR string = WindowsGetStringRawBufferFunc(hString, NULL); if (string) { - name = WIN_StringToUTF8(string); + name = WIN_StringToUTF8W(string); } WindowsDeleteStringFunc(hString); }