DirectInput devicetype and subtype issues.

This is a discussion on DirectInput devicetype and subtype issues. within the Game Programming forums, part of the General Programming Boards category; This is odd and I'm beginning to wonder if the dwDevType field of: Code: typedef struct DIDEVICEINSTANCE { DWORD dwSize; ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    131

    DirectInput devicetype and subtype issues.

    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?

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    131
    OK, this is going to be a "disregard." I'm going to assume it doesn't report correctly anymore, if it did ever, and just worry about the axis and buttons. I'll share what I make if anyone shows an interest. I was hoping to put out a tiny util that reported game devices capabilities so I can come up with a general purpose structure that could cover anything that exceeds the support from a c_dfDIJoystick data format.
    Last edited by Cynic; 05-03-2012 at 01:09 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. directinput DIK to VK?
    By X PaYnE X in forum Game Programming
    Replies: 3
    Last Post: 12-12-2005, 01:20 PM
  2. DirectInput
    By Lionmane in forum Windows Programming
    Replies: 4
    Last Post: 11-12-2005, 10:43 PM
  3. Subclass and subtype.
    By Mikro in forum C++ Programming
    Replies: 3
    Last Post: 12-08-2004, 10:28 PM
  4. DirectInput
    By punkrockguy318 in forum Game Programming
    Replies: 10
    Last Post: 01-06-2004, 10:46 PM
  5. Directinput
    By maes in forum Game Programming
    Replies: 0
    Last Post: 01-22-2003, 01:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21