From 36a51a8359f07233e9d94e453d880e7e226627d3 Mon Sep 17 00:00:00 2001 From: Shenjoku Date: Tue, 28 May 2013 20:52:45 -0700 Subject: [PATCH] Fixed some problems introduced in ba0d2d1 that were causing certain gamepads to not get detected due to passing and checking the wrong constants when enumerating the devices. --- .../InputHandler/InputHandler_DirectInput.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/arch/InputHandler/InputHandler_DirectInput.cpp b/src/arch/InputHandler/InputHandler_DirectInput.cpp index c74a6bef19..9016db6412 100644 --- a/src/arch/InputHandler/InputHandler_DirectInput.cpp +++ b/src/arch/InputHandler/InputHandler_DirectInput.cpp @@ -25,12 +25,18 @@ static BOOL CALLBACK EnumDevicesCallback( const DIDEVICEINSTANCE *pdidInstance, { DIDevice device; - switch( pdidInstance->dwDevType & 0xFF ) + switch( GET_DIDEVICE_TYPE(pdidInstance->dwDevType) ) { - case DI8DEVTYPE_KEYBOARD: device.type = device.KEYBOARD; break; - case DI8DEVTYPE_JOYSTICK: device.type = device.JOYSTICK; break; - case DI8DEVTYPE_MOUSE: device.type = device.MOUSE; break; - default: return DIENUM_CONTINUE; + case DI8DEVTYPE_JOYSTICK: + case DI8DEVTYPE_GAMEPAD: + { + device.type = device.JOYSTICK; + break; + } + + case DI8DEVTYPE_KEYBOARD: device.type = device.KEYBOARD; break; + case DI8DEVTYPE_MOUSE: device.type = device.MOUSE; break; + default: return DIENUM_CONTINUE; } device.JoystickInst = *pdidInstance; @@ -109,18 +115,18 @@ InputHandler_DInput::InputHandler_DInput() RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: DirectInputCreate") ); LOG->Trace( "InputHandler_DInput: IDirectInput::EnumDevices(DIDEVTYPE_KEYBOARD)" ); - hr = g_dinput->EnumDevices( DI8DEVTYPE_KEYBOARD, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY ); + hr = g_dinput->EnumDevices( DI8DEVCLASS_KEYBOARD, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY ); if( hr != DI_OK ) RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: IDirectInput::EnumDevices") ); LOG->Trace( "InputHandler_DInput: IDirectInput::EnumDevices(DIDEVTYPE_JOYSTICK)" ); - hr = g_dinput->EnumDevices( DI8DEVTYPE_JOYSTICK, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY ); + hr = g_dinput->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY ); if( hr != DI_OK ) RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: IDirectInput::EnumDevices") ); // mouse LOG->Trace( "InputHandler_DInput: IDirectInput::EnumDevices(DIDEVTYPE_MOUSE)" ); - hr = g_dinput->EnumDevices( DI8DEVTYPE_MOUSE, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY ); + hr = g_dinput->EnumDevices( DI8DEVCLASS_POINTER, EnumDevicesCallback, NULL, DIEDFL_ATTACHEDONLY ); if( hr != DI_OK ) RageException::Throw( hr_ssprintf(hr, "InputHandler_DInput: IDirectInput::EnumDevices") );