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.
This commit is contained in:
parent
9bfaeb5390
commit
354f23cf3f
1 changed files with 6 additions and 6 deletions
|
@ -121,7 +121,7 @@ BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
static LPDIRECTINPUTDEVICEA device;
|
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;
|
directinput_objects->device = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -130,7 +130,7 @@ BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
|
||||||
static LPDIRECTINPUTDEVICE2A _joystick;
|
static LPDIRECTINPUTDEVICE2A _joystick;
|
||||||
HRESULT res = device->QueryInterface(IID_IDirectInputDevice2A, (LPVOID*)&_joystick);
|
HRESULT res = device->QueryInterface(IID_IDirectInputDevice2A, (LPVOID*)&_joystick);
|
||||||
|
|
||||||
if (res < 0)
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
joystick = NULL;
|
joystick = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -146,9 +146,9 @@ BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
|
||||||
|
|
||||||
char string[0x100];
|
char string[0x100];
|
||||||
#ifdef FIX_BUGS
|
#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
|
#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
|
#endif
|
||||||
OutputDebugStringA(string);
|
OutputDebugStringA(string);
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ BOOL GetJoystickStatus(JOYSTICK_STATUS *status)
|
||||||
if (joystick == NULL)
|
if (joystick == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (joystick->Poll())
|
if (joystick->Poll() != DI_OK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
HRESULT res = joystick->GetDeviceState(sizeof(DIJOYSTATE), &joystate);
|
HRESULT res = joystick->GetDeviceState(sizeof(DIJOYSTATE), &joystate);
|
||||||
|
@ -207,7 +207,7 @@ BOOL ResetJoystickStatus(void)
|
||||||
if (joystick == NULL)
|
if (joystick == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (joystick->Poll())
|
if (joystick->Poll() != DI_OK)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
HRESULT res = joystick->GetDeviceState(sizeof(DIJOYSTATE), &joystate);
|
HRESULT res = joystick->GetDeviceState(sizeof(DIJOYSTATE), &joystate);
|
||||||
|
|
Loading…
Add table
Reference in a new issue