Skip to content

Commit 9ce3912

Browse files
committed
Add support for Joystick buttons
1 parent c8d1663 commit 9ce3912

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

lib/TapHoldManager.ahk

+22-2
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,34 @@ class KeyManager {
7070

7171
this.HoldWatcherFn := this.HoldWatcher.Bind(this)
7272
this.TapWatcherFn := this.TapWatcher.Bind(this)
73+
this.JoyReleaseFn := this.JoyButtonRelease.Bind(this)
74+
this.JoyWatcherFn := this.JoyButtonWatcher.Bind(this)
7375
this.DeclareHotkeys()
7476
}
7577

7678
DeclareHotkeys(){
7779
fn := this.KeyEvent.Bind(this, 1)
7880
hotkey, % this.prefixes this.keyName, % fn
79-
fn := this.KeyEvent.Bind(this, 0)
80-
hotkey, % this.prefixes this.keyName " up", % fn
81+
if (SubStr(this.keyName, 2, 3) = "joy"){
82+
fn := this.JoyReleaseFn
83+
hotkey, % this.keyName " up", % fn
84+
} else {
85+
fn := this.KeyEvent.Bind(this, 0)
86+
hotkey, % this.prefixes this.keyName " up", % fn
87+
}
88+
}
89+
90+
JoyButtonRelease(){
91+
fn := this.JoyWatcherFn
92+
SetTimer, % fn, 10
93+
}
94+
95+
JoyButtonWatcher(){
96+
if (!GetKeyState(this.keyName)){
97+
fn := this.JoyWatcherFn
98+
SetTimer, % fn, Off
99+
this.KeyEvent(0)
100+
}
81101
}
82102

83103
KeyEvent(state){

0 commit comments

Comments
 (0)