From 354f23cf3f568b147fb5a480dcc9467f7a866216 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 5 Jan 2020 03:48:02 +0000 Subject: [PATCH] Improved accuracy of Input.cpp Applied some missing constants/macros, and corrected an ASM-inaccuracy. I always wondered why the original code only passed the first member of the GUID struct, but it turned out it didn't: it actually passed the whole thing. Also, it's starting to bother me how many ASM-inaccuracies have sneaked-through. v2.0 was *meant* to have fixed all this already. --- src/Input.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Input.cpp b/src/Input.cpp index c5911123..605ad4f9 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -121,7 +121,7 @@ BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) } static LPDIRECTINPUTDEVICEA device; - if (directinput_objects->lpDI->CreateDevice(lpddi->guidInstance, &device, NULL)) + if (directinput_objects->lpDI->CreateDevice(lpddi->guidInstance, &device, NULL) != DI_OK) { directinput_objects->device = NULL; return TRUE; @@ -130,7 +130,7 @@ BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) static LPDIRECTINPUTDEVICE2A _joystick; HRESULT res = device->QueryInterface(IID_IDirectInputDevice2A, (LPVOID*)&_joystick); - if (res < 0) + if (FAILED(res)) { joystick = NULL; return TRUE; @@ -146,9 +146,9 @@ BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) char string[0x100]; #ifdef FIX_BUGS - sprintf(string, "DeviceGUID = %lx\n", lpddi->guidInstance.Data1); + sprintf(string, "DeviceGUID = %lx-%hx-%hx-%hhx%hhx-%hhx%hhx%hhx%hhx%hhx%hhx\n", lpddi->guidInstance.Data1, lpddi->guidInstance.Data2, lpddi->guidInstance.Data3, lpddi->guidInstance.Data4[0], lpddi->guidInstance.Data4[1], lpddi->guidInstance.Data4[2], lpddi->guidInstance.Data4[3], lpddi->guidInstance.Data4[4], lpddi->guidInstance.Data4[5], lpddi->guidInstance.Data4[6], lpddi->guidInstance.Data4[7]); #else - sprintf(string, "DeviceGUID = %x\n", (unsigned int)lpddi->guidInstance.Data1); + sprintf(string, "DeviceGUID = %x\n", lpddi->guidInstance); // Tries to print a struct as an int #endif OutputDebugStringA(string); @@ -162,7 +162,7 @@ BOOL GetJoystickStatus(JOYSTICK_STATUS *status) if (joystick == NULL) return FALSE; - if (joystick->Poll()) + if (joystick->Poll() != DI_OK) return FALSE; HRESULT res = joystick->GetDeviceState(sizeof(DIJOYSTATE), &joystate); @@ -207,7 +207,7 @@ BOOL ResetJoystickStatus(void) if (joystick == NULL) return FALSE; - if (joystick->Poll()) + if (joystick->Poll() != DI_OK) return FALSE; HRESULT res = joystick->GetDeviceState(sizeof(DIJOYSTATE), &joystate);