From 800b50ff6feadac7659f2ba7294e91822ae7e4d0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 16 Jul 2009 02:45:51 +0000 Subject: [PATCH] - Attempt to add support for Microsoft's SideWinder Strategic Commander. SVN r1719 (trunk) --- docs/rh-log.txt | 5 ++++- src/win32/i_dijoy.cpp | 27 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index bbb8d79ad1..992c656248 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ -July 14, 2009 +July 15, 2009 +- Attempt to add support for Microsoft's SideWinder Strategic Commander. + +July 14, 2009 - Split the joystick menu into two parts: A top level with general options and a list of all attached controllers, and a second level for configuring an individual controller. diff --git a/src/win32/i_dijoy.cpp b/src/win32/i_dijoy.cpp index f9eda133d3..be035c22fa 100644 --- a/src/win32/i_dijoy.cpp +++ b/src/win32/i_dijoy.cpp @@ -218,6 +218,11 @@ protected: GUID Instance; FString Name; }; + struct EnumData + { + TArray *All; + bool GenericDevices; + }; TArray Devices; FDInputJoystick *EnumDevices(); @@ -1057,17 +1062,26 @@ void FDInputJoystickManager::GetDevices(TArray &sticks) BOOL CALLBACK FDInputJoystickManager::EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) { + EnumData *data = (EnumData *)pvRef; + + // Special check for the Microsoft SideWinder Strategic Commander, + // which for some odd reason reports itself as a generic device and + // not a game controller. + if (data->GenericDevices && lpddi->guidProduct.Data1 != MAKELONG(0x45e, 0x0033)) + { + return DIENUM_CONTINUE; + } + // Do not add PS2 adapters if Raw PS2 Input was initialized. // Do not add XInput devices if XInput was initialized. if ((JoyDevices[INPUT_RawPS2] == NULL || !I_IsPS2Adapter(lpddi->guidProduct.Data1)) && (JoyDevices[INPUT_XInput] == NULL || !IsXInputDevice(&lpddi->guidProduct))) { - TArray *all = (TArray *)pvRef; Enumerator thisone; thisone.Instance = lpddi->guidInstance; thisone.Name = lpddi->tszInstanceName; - all->Push(thisone); + data->All->Push(thisone); } return DIENUM_CONTINUE; } @@ -1303,9 +1317,16 @@ FDInputJoystick *FDInputJoystickManager::EnumDevices() { FDInputJoystick *newone = NULL; TArray controllers; + EnumData data; unsigned i, j, k; - g_pdi->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallback, &controllers, DIEDFL_ALLDEVICES); + // Find all game controllers + data.All = &controllers; + data.GenericDevices = false; + g_pdi->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallback, &data, DIEDFL_ALLDEVICES); + // Again, just for the Strategic Commander + data.GenericDevices = true; + g_pdi->EnumDevices(DI8DEVCLASS_DEVICE, EnumCallback, &data, DIEDFL_ALLDEVICES); // Sort by name so that devices with duplicate names can have numbers appended. qsort(&controllers[0], controllers.Size(), sizeof(Enumerator), NameSort);