-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExample.ahk
55 lines (47 loc) · 1.48 KB
/
Example.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include Lib\WootingAHK.AHK
Wooting := new WootingAHK()
last := A_TickCount
wootingKey := Wooting.AddKey(GetKeySC("A")) ; Create a WootingKey for the A key using the Scan Code
.OnAnalog(Func("AxisChanged")) ; Call the Function "AxisChanged" and pass it Analog value
.SetBlock(true) ; Enable blocking for the hotkey
.SetHotkey(true) ; Turn on the hotkey
GoSub, InitToggleBlock
return
; Toggle disabling of key, even if in Notepad
F1::
wootingKey.ToggleBlock() ; Toggle blocking
InitToggleBlock:
if (wootingKey.Blocked()){
Wooting.SetKeyRgb(GetKeySC("F1"), 255, 0, 0) ; Turn F1 Red to indicate key is disabled
} else {
Wooting.SetKeyRgb(GetKeySC("F1"), 0, 255, 0) ; Turn F1 Green to indicate key is enabled
}
return
; Called and passed analog value when key changes state
AxisChanged(value){
static threshold := 100
static oldVal := 0
static lastEvent := "NONE"
Global Wooting
;~ OutputDebug % "AHK| IsDigital: " isDigital ", Value: " value
if (oldVal == 0 && value){
; Press
lastEvent := "INITIAL PRESS"
}
if (oldval < threshold && value >= threshold){
; Press past 50 %
lastEvent := "PRESS PAST THRESH"
} else if (oldval >= threshold && value < threshold){
; Release past 50 %
lastEvent := "RELEASE PAST THRESH"
}
if (oldVal && value == 0){
; Full release
lastEvent := "FULL RELEASE"
}
ToolTip % "Axis Changed. Old Value: " oldVal ", New Value: " value ", Last Event: " lastEvent
oldVal := value
}
^Esc::
Wooting.Dispose() ; Reset RGB
ExitApp