diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-06-04 11:40:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-04 11:40:57 +0200 |
commit | c47a6f632557ef529f1403f512c35e8b7945e387 (patch) | |
tree | 65abbacb23e51bdb3ed47ca518dbebe243da26aa | |
parent | f1d9d50da1e2d26a77f07c4296f24a42ee37a6b0 (diff) | |
parent | a833db80d907c57630a64e449f3667489e8a0005 (diff) |
Merge pull request #39060 from madmiraal/fix-38869
Update Windows GUID to SDL uid conversion.
-rw-r--r-- | platform/windows/joypad_windows.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index a6ec95ea10..271a4e41bc 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -33,10 +33,6 @@ #include <oleauto.h> #include <wbemidl.h> -#ifndef __GNUC__ -#define __builtin_bswap32 _byteswap_ulong -#endif - #if defined(__GNUC__) // Workaround GCC warning from -Wcast-function-type. #define GetProcAddress (void *)GetProcAddress @@ -167,10 +163,13 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { const GUID &guid = instance->guidProduct; char uid[128]; - sprintf_s(uid, "%08lx%04hx%04hx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx", - __builtin_bswap32(guid.Data1), guid.Data2, guid.Data3, - guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], - guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); + + ERR_FAIL_COND_V_MSG(memcmp(&guid.Data4[2], "PIDVID", 6), false, "DirectInput device not recognised."); + WORD type = BSWAP16(0x03); + WORD vendor = BSWAP16(LOWORD(guid.Data1)); + WORD product = BSWAP16(HIWORD(guid.Data1)); + WORD version = 0; + sprintf_s(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", type, 0, vendor, 0, product, 0, version, 0); id_to_change = joypad_count; |