Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


DirectInput problem when enumerating devices


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 xDS4Lx   Members   -  Reputation: 126

Like
0Likes
Like

Posted 03 October 2013 - 12:06 PM

So at work I work on an application that monitors the status of various components on a pc and keep having an issue with DirectInput and Joysticks.  When I enumerate the devices the DIDEVICEINSTANCE guidProduct and guidInstance are changing between and even in the same run. 

 

Example from single run:

Initial detect 

Joystick Product GUID: DA83AFB000000000504944564944
Joystick Instance GUID: DA83AFB0D7B211E28001444553540000

New hardware check

Joystick Product GUID: 3C6A972000000000504944564944
Joystick Instance GUID: 3C6A972097C11E38001444553540000

 Forced redetect

Joystick Product GUID: DA83AFB000000000504944564944
Joystick Instance GUID: DA83AFB0D7B211E28001444553540000

 

There is only one Joystick plugged into this system, nothing has been removed or plugged into a different port. 

 

The app works by keeping a list of components and then on restart first verifying them, then looking for any new hardware, the user can also force a redetect which basically clears the list and starts all detection over.

 

Initialization code:

if(FAILED(hr = DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&m_DirectInput, NULL)))
    return false;
 
if(FAILED(hr = m_DirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL, enumJoystickCallback,(LPVOID)this, DIEDFL_ATTACHEDONLY)))
    return false;
 

Enum code

if(SUCCEEDED(m_DirectInput->CreateDevice(DevInst->guidInstance, &m_GameDevices[m_nDeviceCount], NULL)))
{
...
store guid and product name
}

I can't get this to happen every time either, its maybe a 1 in 10 chance that it happens but when it does the joystick will not work at all in any applications unless I force a redetect of the hardware.  The app starts with bootup and detects the hardware and releases the direct input interface when the app is shutdown or when doing a new detection.  Could creating the direct input interface multiple times be causing the issue? 

 

Testing on my machine I get a different GUID, which is expected as its a different device, same brand and model, however I noticed that the last part of all the GUIDS I get are identical.

 

DA83AFB0D7B211E2 8001444553540000
3C6A972097C11E3 8001444553540000
CC43C76079E211E2 8001444553540000

 

The 8001444553540000 is the same between all the two joysticks and the same one that gets two guids, is this some version number or hardware ID?  Anyone know exactly how DirectInput gets this GUID?  From the documentation I assumed it was either from the driver or from hardware in the device.


Edited by xDS4Lx, 03 October 2013 - 02:39 PM.

"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS