Sign in to follow this  
Headkaze

Virtual Joystick Driver

Recommended Posts

Unfortunately microsoft.public.development.device.drivers is not available on my ISP's news server so I'm posting here because it does relate to DirectInput in many ways. I am developing a Virtual Joystick driver (based on the vhidmini example in the DDK) and am simulating two joysticks. The problem is because the driver has a single VID and PID when DirectInput enumerates the two joysticks it names them both "Virtual Joystick 1". I need to change it so joystick two is called "Virtual Joystick 2". Looking in the registry I found a key in HKLM\SYSTEM\CurrentControlSet\Control\MediaProperties\PrivateProperties\Joystick\OEM that holds the joystick name in OEMName. It seems changing this value changes the name of both joysticks. Looking at the following DirectInput struct I was hoping I could use tszInstanceName to name the joysticks differently
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;
I couldn't find anything in the registry that related to "InstanceName" apart from HKLM\SYSTEM\CurrentControlSet\Control\MediaProperties\PrivateProperties\DirectInput\VID_xxxx&PID_xxxx\DeviceInstances but it didn't seem to have an entry for a "friendly name". It actually appears that tszInstanceName uses the same OEMName entry that tszProductName uses! The only way I could see to set this was in DirectInput using LPDIRECTINPUTDEVICE2->SetProperty with DIPROP_INSTANCENAME. Attempting that I received an error of E_NOTIMPL (not implemented). It seems a simple goal to have the two joysticks (which share a PID/VID) uniquely named but I am seriously having doubts as to if it's even possible. Incidently I have two Logitech gamepads that when plugged in have the same PID/VID and also share the same name. It seems odd there is no built in mechanism to uniquely name them. Is there a way around it? Any registry entries, hacks or anything?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this