WhiteMagic / JoystickGremlin

A tool for configuring and managing joystick devices.
http://whitemagic.github.io/JoystickGremlin/
GNU General Public License v3.0
307 stars 45 forks source link

HidGuardian Reload Devices When Hidden/UnHidden #86

Open nlvw opened 6 years ago

nlvw commented 6 years ago

Currently when joystick gremlin hides/unhides a device the user has to manually unplug and replug in the usb cable. I present to you a fix to automate this!!

Basically all we have to do is disable and the reenable the Hid device. This can be accomplished using 2 different tools. Devcon.exe which is provided by microsoft in their driver kit sdk and devmanview by NirSoft which is freeware. The tools would need to be included with the JoystickGremlin release so whichever one fits your licensing better. Idk the licensing for Devcon but DevManView is a well known digital forensics tool and their licensing allows for redistribution (https://www.nirsoft.net/utils/device_manager_view.html licensing is towards the bottom).

Devcon Example (cmd/batch): devcon.exe disable "HID\VID_044f&PID_b10a" devcon.exe enable "HID\VID_044f&PID_b10a"

DevManView Example (cmd/batch): DevManView.exe /disable_enable "HID\VID_044f&PID_b10a???_*" /use_wildcard

This would allow for JoystickGremlin to hide devices when it starts (per set options) and then unhide them when the program closes.

A really good implementation of a HidGuardian wrapper that I found this method from is here https://github.com/samehb/HIDer. "HIDer/HIDer/HIDGuardianAPI.cs" is the file you'll want to look at.

WhiteMagic commented 6 years ago

Sounds good, I'll have to see about doing those things when v2 of Hidguardian gets more stable, and maybe it starts doing that already on it's own then. But it's definitely good to know that there are ways around this.

There might even be normal windows or winapi calls to enable disable devices which wouldn't require additional executable. I'm also assuming that they will always require admin access which I'd like to avoid when redoing the hidguardian stuff, but I'll see about that when the time comes.