For ages we have been able to create virtual controllers and remap a stick to that, but in the past we have not been able to stop the game from seeing the physical stick.
Well now we have a proper solution: The HidGuardian / HidCerberus components from ViGEm. HidGuardian is a device driver that you install which can hide sticks from the system. HidCerberus is a windows service that allows you to "whitelist" a process (eg your AHK script) so that your script is the ONLY thing on the system that can see through HidGuardian and read the stick. The stick even disappears from the joystick control panel in windows!
There are two tools in the zip - a ready made Auto-Whitelister app, and a library if you wish to write your own solution.
(A pre-compiled version of this is provided, you do not need AutoHotkey installed to use it)
This is used to whitelist an app of your choice (eg UJR, UCR, Joy2Key, GlovePIE maybe) with the ability to see through the HidGuardian block.
Click the button, click a window, and it will whitelist that app for you.
It keeps checking for the existence of the specified window, and tries to always keep the PID of the specified application in the whitelist up-to-date.
It will also install / uninstall HG or HC for you. It requires admin rights to run, but you will only get a UAC popup the first time.
Usage is super simple - two lines of code: One to include the library, and one to initialize:
; Load the library
; Whitelist this script
wk := new WhiteKnight()
; Check if everything went OK
MsgBox HidCerberus Whitelist failed
; Poll a stick, to make sure it worked
ToolTip % GetKeyState("1JoyX")
Download the attached ZIP and extract
Run the included WhiteKnight.ahk or WhiteKnight.exe and follow the instructions
Navigate to the
Resources\1 HidGuardianfolder from the zip
Navigate to the
Resources\2 HidCerberusfolder from the zip
Navigate to the x86 folder on a 32-bit system, or the x64 folder if your system is 64-bit
Check in your windows Services dialog if the HidCerberus service is running (Start->Services.msc)
Navigate to the HidGuardian config page (This is a link to a web server now running on your local system)
Find the stick you wish to hide from the list, and click the Hide button next to it.
Unplug the stick and plug it back in. It should now be gone from the Joystick control panel (Start->joy.cpl)
Note that in order to revert back to normal usage, you need to use this page to unhide the stick, then unplug and plug back in again.
Once a stick is hidden and you use the library from the zip, you can use normal AHK commands (eg GetKeyState) to read the state of the stick.