This is odd and I'm beginning to wonder if the dwDevType field of:
Code:
typedef struct DIDEVICEINSTANCE {
DWORD dwSize;
GUID guidInstance;
GUID guidProduct;
DWORD dwDevType;
TCHAR tszInstanceName[MAX_PATH];
TCHAR tszProductName[MAX_PATH];
GUID guidFFDriver;
WORD wUsagePage;
WORD wUsage;
} DIDEVICEINSTANCE, *LPDIDEVICEINSTANCE;
Still works.
I have a Saitek X-52 with pedals and I'm making a small bit of code to enumerate everything since the basic GUID only allows 6 axis and 32 buttons whereas my Saitek has 9 axis and 34 buttons.
When generating a report, I'm clearing the DIDEVTYPE_HID bit to get a value for a loopup table of device type and subtype.
Well, my stick is registering as a 1st Person, 6DOF and my pedals as a limited joystick, so now I'm wondering if the type and subtype can't be trusted or if I'm doing it wrong.
The lookup table:
Code:
struct DevType
{
DWORD dwType;
wchar_t *cType;
} devtype[] =
{
{ DI8DEVTYPE_DEVICE, L"General Purpose Device" },
{ DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_UNKNOWN << 8), L"Mouse, Uknown" },
{ DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8), L"Mouse, Traditional" },
.
.
.
The whole table is there for all the values in dinput.h.
The loop code so far:
Code:
for( std::list<IDData>::iterator idit = id_list.begin(); idit != id_list.end(); idit++ )
{
IDData inputdevice = *idit;
BOOL bHIDBool = inputdevice.di_InputDeviceData.dwDevType && DIDEVTYPE_HID;
DWORD dwTypeAndSubType = inputdevice.di_InputDeviceData.dwDevType & ~DIDEVTYPE_HID;
wprintf( L"Product name: %s\n", inputdevice.di_InputDeviceData.tszProductName );
if( inputdevice.di_InputDeviceData.dwDevType && DIDEVTYPE_HID )
wprintf( L"HID: %-15s", HID(inputdevice.di_InputDeviceData.dwDevType));
for( int i = 0; devtype[i].dwType != 0; i++ )
if( devtype[i].dwType == dwTypeAndSubType )
wprintf( L"Device Type: %s\n", devtype[i].cType );
}
Am I screwing up the value of dwTypeAndSubType with a bad operation or is the problem elsewhere?