Followers 0

# DirectInput problem when enumerating devices

## 0 posts in this topic

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
0

## Create an account

Register a new account