I'd really like to setup an Autohotkey script that essentially makes each button click reconfigure the hotkeys of the hatswitch to simulate all the different hat switches of fighter jets and things like that. Basically I'd like to do something like this:
Press Joy1 = Hat switch Up, Down, Left, Right, becomes keys 1, 2, 3, 4
Press Joy2 = Hat switch Up, Down, Left, Right, becomes keys 5, 6, 7, 8
...and so on for about 5 different joystick buttons, with one of those buttons returning the hat switch to standard function. I found this script online that allows me to simply change the bindings of the hat switch statically, but I'd love to know how I can apply this to setup dynamic bindings depending on which "modifier" joystick button I press before hand. Here's the script I found:
Code: Select all
#Persistent ; Keep this script running until the user explicitly exits it.
SetTimer, WatchPOV, 5
return
WatchPOV:
GetKeyState, POV, JoyPOV ; Get position of the POV control.
KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any).
; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, use a range:
if POV < 0 ; No angle to report
KeyToHoldDown =
else if POV > 31500 ; 315 to 360 degrees: Forward
KeyToHoldDown = Up
else if POV between 0 and 4500 ; 0 to 45 degrees: Forward
KeyToHoldDown = Up
else if POV between 4501 and 13500 ; 45 to 135 degrees: Right
KeyToHoldDown = Right
else if POV between 13501 and 22500 ; 135 to 225 degrees: Down
KeyToHoldDown = Down
else ; 225 to 315 degrees: Left
KeyToHoldDown = Left
if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down (or no key is needed).
{
if KeyToHoldDown
Send, {%KeyToHoldDown% down} ; Auto-repeat the keystroke.
return
}
; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1 ; Avoid delays between keystrokes.
if KeyToHoldDownPrev ; There is a previous key to release.
Send, {%KeyToHoldDownPrev% up} ; Release it.
if KeyToHoldDown ; There is a key to press down.
Send, {%KeyToHoldDown% down} ; Press it down.
return
This script does remap the hat switch, but I'm not sure how to make it work in the way I'm trying to make it work.