4

I'm looking to support a custom joystick device, and due to project requirements I can no longer use the DirectInput API. I've switched to using the "classic" Windows multimedia API (e.g. joyGetDevCaps and family), and it all works with one exception.

The DirectInput DeviceInstance had two fields, InstanceName and ProductName which returned the correct "custom" name of the device.

The corresponding joyGetDevCaps product name field, szPname, returns a generic "Microsoft PC-joystick driver".

In searching the registry on a system with the device installed, I found that there is a REG_SZ OEMName entry in this node that has the string I want:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MediaProperties\PrivateProperties\Joystick\OEM\VID_07C0&PID_1128

There are two fields returned in the JOYCAPS, wMid (Manufacturer ID) and wPid (Product ID), which map to the two hex values in the keyname: wMid = 0x07c0, wPid = 0x1128.

Additionally, I can use the SetupDiEnumDeviceInfo API on GUID_DEVINTERFACE_HID and find a matching controller (although this step may not be necessary):

HID\VID_07C0&PID_1128&REV_1032, HID-compliant game controller

Question: Is there an API for enumerating the MediaProperties\PrivateProperties that I should be using, or is it "safe" to use this information and query the registry directly? If there's an API please answer with references and/or sample code! I can't find anything related.

holtavolt
  • 4,378
  • 1
  • 26
  • 40

1 Answers1

0

You should be using the szRegName value to get the following key: (in this case, szRegName is "DINPUT.DLL"):

HKCU\System\CurrentControlSet\Control\MediaResources\Joystick\DINPUT.DLL\CurrentJoystickSettings

It contains values like "Joystick1OEMName", which will contain strings like "VID_07C0&PID_1128" that can be used to look up the appropriate key under PrivateProperties.

Some example code can be found here: https://github.com/google/liquidfun/blob/master/freeglut/src/mswin/fg_joystick_mswin.c

rdb
  • 1,488
  • 1
  • 14
  • 24