- Attempt to add support for Microsoft's SideWinder Strategic Commander.

SVN r1719 (trunk)
This commit is contained in:
Randy Heit 2009-07-16 02:45:51 +00:00
parent 00a6293952
commit 800b50ff6f
2 changed files with 28 additions and 4 deletions

View file

@ -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 - 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 and a list of all attached controllers, and a second level for configuring
an individual controller. an individual controller.

View file

@ -218,6 +218,11 @@ protected:
GUID Instance; GUID Instance;
FString Name; FString Name;
}; };
struct EnumData
{
TArray<Enumerator> *All;
bool GenericDevices;
};
TArray<FDInputJoystick *> Devices; TArray<FDInputJoystick *> Devices;
FDInputJoystick *EnumDevices(); FDInputJoystick *EnumDevices();
@ -1057,17 +1062,26 @@ void FDInputJoystickManager::GetDevices(TArray<IJoystickConfig *> &sticks)
BOOL CALLBACK FDInputJoystickManager::EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) 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 PS2 adapters if Raw PS2 Input was initialized.
// Do not add XInput devices if XInput was initialized. // Do not add XInput devices if XInput was initialized.
if ((JoyDevices[INPUT_RawPS2] == NULL || !I_IsPS2Adapter(lpddi->guidProduct.Data1)) && if ((JoyDevices[INPUT_RawPS2] == NULL || !I_IsPS2Adapter(lpddi->guidProduct.Data1)) &&
(JoyDevices[INPUT_XInput] == NULL || !IsXInputDevice(&lpddi->guidProduct))) (JoyDevices[INPUT_XInput] == NULL || !IsXInputDevice(&lpddi->guidProduct)))
{ {
TArray<Enumerator> *all = (TArray<Enumerator> *)pvRef;
Enumerator thisone; Enumerator thisone;
thisone.Instance = lpddi->guidInstance; thisone.Instance = lpddi->guidInstance;
thisone.Name = lpddi->tszInstanceName; thisone.Name = lpddi->tszInstanceName;
all->Push(thisone); data->All->Push(thisone);
} }
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
@ -1303,9 +1317,16 @@ FDInputJoystick *FDInputJoystickManager::EnumDevices()
{ {
FDInputJoystick *newone = NULL; FDInputJoystick *newone = NULL;
TArray<Enumerator> controllers; TArray<Enumerator> controllers;
EnumData data;
unsigned i, j, k; 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. // Sort by name so that devices with duplicate names can have numbers appended.
qsort(&controllers[0], controllers.Size(), sizeof(Enumerator), NameSort); qsort(&controllers[0], controllers.Size(), sizeof(Enumerator), NameSort);