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!
Download
There are two tools in the zip - a ready made Auto-Whitelister app, and a library if you wish to write your own solution.
Auto-Whitelister
(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.
Instruction Video:
This video demonstrates hiding a DualShock 4 controller and allowing only the remapping app "JoyShockMapper" to see the controller
Library
Usage is super simple - two lines of code: One to include the library, and one to initialize:
Code: Select all
#NoEnv
#SingleInstance force
#Persistent
; Load the library
#Include WhiteKnight.ahk
; Whitelist this script
wk := new WhiteKnight()
; Check if everything went OK
if (!wk.WhitelistState){
MsgBox HidCerberus Whitelist failed
ExitApp
}
; Poll a stick, to make sure it worked
Loop {
ToolTip % GetKeyState("1JoyX")
Sleep 100
}
^Esc::
ExitApp
Download the attached ZIP and extract
Run the included WhiteKnight.ahk or WhiteKnight.exe and follow the instructions
Navigate to the Resources\1 HidGuardian folder from the zip
run HidGuardian Install.bat
Navigate to the Resources\2 HidCerberus folder from the zip
Navigate to the x86 folder on a 32-bit system, or the x64 folder if your system is 64-bit
run HidCerberus Install.bat
Check in your windows Services dialog if the HidCerberus service is running (Start->Services.msc)
Hiding sticks
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.