forked from agirardeau/b0xx-ahk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fairbox.ahk
1134 lines (965 loc) · 29.5 KB
/
fairbox.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Requires AutoHotkey v1.1.37
#Warn All, OutputDebug
#SingleInstance force
#NoEnv
SetBatchLines, -1
ListLines Off
#include <CvJoyInterface>
#MenuMaskKey vke8
currentTimeMS := 0
#include %A_ScriptDir%\analogZoneInfo\crouchZone
#include, crouchZone.ahk
#include, crouchZoneHistoryObject.ahk
#include, getCrouchZone.ahk
#include %A_ScriptDir%\analogZoneInfo\dashZone
#include, dashZone.ahk
#include, dashZoneHistoryObject.ahk
#include, getDashZone.ahk
#include %A_ScriptDir%\analogZoneInfo\outOfDeadzone
#include, deadzoneHistoryObjects.ahk
#include, getOutOfDeadzone.ahk
#include, outOfDeadzone.ahk
#include %A_ScriptDir%\controls
#include, addControlsWindowInstructions.ahk
#include, constructControlsWindow.ahk
#include, goToFunctionsUponGuiInteraction.ahk
#include, hkIniAutogenerator.ahk
#include, hotkeyControlHasFocus.ahk
#include, hotkeyHelpers.ahk
#include, loadHotkeysIni.ahk
#include, validateModifiedControl.ahk
#include %A_ScriptDir%\coordinates
#include, targetCoordinateValues.ahk ; you can customize the coordinates in this file
#include, targetFormatting.ahk
#include, targetObjStructure.ahk
#include, trimToCircle.ahk
#include %A_ScriptDir%\limitOutputs
#include, getFuzzyHorizontal100.ahk
#include, limitedOutputsObject.ahk
#include, limitOutputs.ahk
#include, output.ahk
#include %A_ScriptDir%\menu
#include, menu.ahk
#include %A_ScriptDir%\system
#include, fairboxConstants.ahk ; globals
#include, gameEngineConstants.ahk ; globals
#include %A_ScriptDir%\technique\pivot
#include, getCurrentPivotInfo.ahk
#include, getPivotDirection.ahk
#include, getPivotLockoutNerfedCoords.ahk
#include, pivot.ahk
#include, pivotHistoryObject.ahk
#include, pivotTrackAndNerfObject.ahk
#include %A_ScriptDir%\technique\uncrouch
#include, getUncrouch.ahk
#include, uncrouch.ahk
#include, uncrouchHistoryObject.ahk
#include, uncrouchTrackAndNerfObject.ahk
#include %A_ScriptDir%\technique
#include, getReverseNeutralBNerf.ahk
#include, timingBasedTechniqueHistoryEntry.ahk
#include %A_ScriptDir%\test
; #include, calibrationTest.ahk
#include, inputsOvertake.ahk
#include, miscTestingTools.ahk
#include, testNerfsByHand.ahk
guiFontDefault(windowName) { ; next Gui,Add or GuiControl,Font commands will have this font in their text when called
Gui, % windowName ":Font", s8 cDefault norm, Tahoma
return
}
guiFontContent(windowName) { ; next Gui,Add or GuiControl,Font commands will have this font in their text when called
Gui, % windowName ":Font", s10 cDefault norm, Arial
return
}
/*
DISCLAIMER
I (dron-link) AM NOT A DEVELOPER BY TRADE.
Other than due to a lack of alternatives, I made this with the hope that this script
contains any useful ideas for you if you're an experienced programmer that wants to
embark on a project like this.
contact info:
Discord
Aiu ; over at 20XX Discord server, specifically in #keyboard : https://discord.gg/KydHfzTbdG
; if the link doesnt work try searching for the 20XX invite https://b0xx.com/pages/more-info
GitHub
https://github.com/dron-link
sdi, uncrouch, and pivot nerfs, and history saving adapted from CarVac 's work
https://github.com/CarVac/HayBox/blob/master/src/modes/MeleeLimits.cpp
---------------------
this project started as a proof of concept of how can we implement a variety of analog stick nerfs
in Autohotkey. since then it has evolved into something of an improvement over the finalized b0xx-ahk
everything is subject to modification and may not be present in the finalized version.
+++ i'm considering helping to make a faithful b0xx v4.1-like for keyboards in the future.
rough list of remaining tasks
- TODO create a showControlsWindowOnLaunch
- TODO deleteFailingHotkey all invalid hotkeys at once. path: groundhog day of timer threads
- TODO custom IfWinActive for users to make the hotkeys only work when the emulator window is focused
- TODO reformat c-stick coordinates, make them into integers instead of floats
- TODO disable all traytip messages option
- TODO increase hotkey control width option
- TODO restore default hotkeys button
- TODO ensure that displayed hotkeys always reflect the real ones
- TODO primitive input viewer, or graphic input viewer, as a separate .exe app
- TODO b0xx example layout picture window? maybe not necessary if i do the graphic input viewer
- TODO add cx and cy entries to the output history, but for what specifically?
- TODO consider outputting 1.0 cardinals and 45° large diagonals past the analog circle?
- TODO implement SDI nerfs
- TODO use setTimer to lift nerfs without waiting for player input
¬ call updateAnalogStick and possibly lift pivot nerfs after 4 frames, 5 frames and 8 frames
¬ use setTimer to lift a 2f jump nerf 2 frames after it was forced (idea origin: CarVac HayBox)
- TODO implement coordinate target inconditional bans
- TODO write tests
- TODO make some in-game debug display by taking control of the c-stick and d-pad (idea taken from: CarVac/Haybox)
- TODO make a debug mode, debugACertainProcess? outputDebug, % expression
setTimer firing rate is apparently 15.6ms, don't expect much precision from it
(at least it's shorter than a game cube input polling interval), but I expect that most nerf lifts will be one frame late sometimes.
Maybe we can improve the script by increasing the polling frequency? solution using WinMM dll
*/
deleteFailingHotkey := true
enabledHotkeys := true
hkIniAutoGenerator() ; create hotkeys.ini if missing
target := new targetCoordinateTree
target.loadCoordinates()
target.formatCoordinates()
; reads c-stick-angle-bindings.ini and assigns coordinates according to its contents
target.bindAnglesToCStick()
; configure at test\testNerfsByHand.ahk, then set this parameter true. to test timing lockout nerfs
testNerfsByHand(false)
constructTrayMenu() ; puts the custom menu items in the tray
for i in hotkeys {
; ### for hotkey activation keys, and gui hotkey controls. create the global variables associated to:
; button name, hotkey control, the real hotkey, special bind checkbox, Prev.Def.B. checkbox
gameBtName%i% := "", HK%i% := "", savedHK%i% := "", isSpecialKey%i% := "", preventBehavior%i% := ""
}
loadHotkeysIniFail := false
loadHotkeysIni()
constructControlsWindow()
; Create an object from vJoy Interface Class.
vJoyInterface := new CvJoyInterface()
; Was vJoy installed and the DLL Loaded?
if (!vJoyInterface.vJoyEnabled()) {
; Show log of what happened
Msgbox % vJoyInterface.LoadLibraryLog
ExitApp
}
myStick := vJoyInterface.Devices[1]
; state variables
; if true, keyboard key is pressed
buttonUp := false
buttonDown := false
buttonLeft := false
buttonRight := false
buttonModX := false
buttonModY := false
buttonA := false
buttonB := false
buttonL := false
buttonR := false
buttonX := false
buttonY := false
buttonZ := false
buttonCUp := false
buttonCDown := false
buttonCLeft := false
buttonCRight := false
buttonLightShield := false
buttonMidShield := false
buttonStart := false
buttonDPadUp := false
buttonDPadDown := false
buttonDPadLeft := false
buttonDPadRight := false
; strings for when press order matters
mostRecentVertical := "" ; this pair of variables went unused because of neutral SOCD
mostRecentHorizontal := ""
mostRecentVerticalC := "" ; this pair of variables went unused because of neutral SOCD
mostRecentHorizontalC := ""
simultaneousHorizontalModifierLockout := false ; this variable went unused because of neutral SOCD
/* Debug info
this is how you read its values:
L-Q-X means
airdodge quadrant modX input
F-Y-U means
fireFox/extended modY c-up input
L airdodge H horizontal X modX U c-up
N no shield Q quadrant Y modY L c-left
Y vertical D c-down
F fireFox/ext R c-right
O [0, 0]
*/
; Debug info
lastCoordTrace := ""
; arbitrary vjoy initial status bug fix: reset all buttons on startup
if enabledHotkeys {
for index in hotkeys {
gosub Label%index%_UP
}
}
if enabledHotkeys {
; Alert User that script has started
TrayTip, % "fairbox", % "Script Started", 3, 0
} else {
TrayTip, % "FAIRBOX", % "TEST MODE", 3, 0
inputsOvertake()
}
/* ////////////////////////////////
check what directions, modifiers and buttons we should listen to,
based on things like opposite cardinal direction modes, D-Pad mode etc
*/
up() {
global
return buttonUp and not buttonDown ; here is the neutral SOCD implementation
}
down() {
global
return buttonDown and not buttonUp ; here
}
left() {
global
return buttonLeft and not buttonRight ; here
}
right() {
global
return buttonRight and not buttonLeft ; here
}
cUp() {
global
return buttonCUp and not buttonCDown and not bothMods() ; here...
}
cDown() {
global
return buttonCDown and not buttonCUp and not bothMods()
}
cLeft() {
global
return buttonCLeft and not buttonCRight and not bothMods()
}
cRight() {
global
return buttonCRight and not buttonCLeft and not bothMods() ; ... up to here
}
modX() {
global
/* deactivate if either:
- modY is also held
- both left and right are held (and were pressed after modX) while neither up or down is active
this last bullet point won't carry into the new code because of NSOCD
*/
return buttonModX and not buttonModY
}
modY() {
global
return buttonModY and not buttonModX
}
anyVert() {
global
return up() or down()
}
anyHoriz() {
global
return left() or right()
}
anyQuadrant() {
global
return anyVert() and anyHoriz()
}
anyMod() {
global
return modX() or modY()
}
bothMods() {
global
return buttonModX and buttonModY
}
anyShield() {
global
return buttonL or buttonR or buttonLightShield or buttonMidShield
}
anyVertC() {
global
return cUp() or cDown()
}
anyHorizC() {
global
return cLeft() or cRight()
}
anyC() {
global
return cUp() or cDown() or cLeft() or cRight()
}
; ///////////// Search for the analog stick coordinates that our controller asked for
getAnalogCoords() {
global buttonB
if (anyShield()) {
quadrantICoords := getAnalogCoordsAirdodge()
} else if (anyMod() and anyQuadrant() and (anyC() or buttonB)) {
quadrantICoords := getAnalogCoordsFirefox()
} else {
quadrantICoords := getAnalogCoordsWithNoShield()
}
return reflectCoords(quadrantICoords)
}
getAnalogCoordsWithNoShield() {
global
if (!anyVert() and !anyHoriz()) {
lastCoordTrace := "N-O"
return new target.normal.origin
} else if (anyQuadrant()) {
if (modX()) {
lastCoordTrace := "N-Q-X"
return new target.normal.quadrantModX
} else if (modY()) {
lastCoordTrace := "N-Q-Y"
return new target.normal.quadrantModY
} else {
lastCoordTrace := "N-Q"
return new target.normal.quadrant
}
} else if (anyVert()) {
if (modX()) {
lastCoordTrace := "N-V-X"
return new target.normal.verticalModX
} else if (modY()) {
lastCoordTrace := "N-V-Y"
return new target.normal.verticalModY
} else {
lastCoordTrace := "N-V"
return new target.normal.vertical
}
} else { ; if (anyHoriz())
if (modX()) {
lastCoordTrace := "N-H-X"
return new target.normal.horizontalModX
} else if (modY()) {
lastCoordTrace := "N-H-Y"
return new target.normal.horizontalModY
} else {
lastCoordTrace := "N-H"
return new target.normal.horizontal
}
}
}
getAnalogCoordsAirdodge() {
global
if (!anyVert() and !anyHoriz()) {
lastCoordTrace := "L-O"
return new target.normal.origin
} else if (anyQuadrant()) {
if (modX()) {
lastCoordTrace := "L-Q-X"
return new target.airdodge.quadrantModX
} else if (modY()) {
lastCoordTrace := "L-Q-Y"
return up() ? new target.airdodge.quadrant12ModY : new target.airdodge.quadrant34ModY
} else {
lastCoordTrace := "L-Q"
return up() ? new target.airdodge.quadrant12 : new target.airdodge.quadrant34
}
} else if (anyVert()) {
if (modX()) {
lastCoordTrace := "L-V-X"
return new target.airdodge.verticalModX
} else if (modY()) {
lastCoordTrace := "L-V-Y"
return new target.airdodge.verticalModY
} else {
lastCoordTrace := "L-V"
return new target.airdodge.vertical
}
} else { ; if (anyHoriz())
if (modX()) {
lastCoordTrace := "L-H-X"
return new target.airdodge.horizontalModX
} else if (modY()) {
lastCoordTrace := "L-H-Y"
return new target.airdodge.horizontalModY
} else {
lastCoordTrace := "L-H"
return new target.airdodge.horizontal
}
}
}
getAnalogCoordsFirefox() {
global
if (modX()) {
if (cUp()) {
lastCoordTrace := "F-X-U"
return buttonB ? new target.extendedB.modXCUp : new target.fireFox.modXCUp
} else if (cDown()) {
lastCoordTrace := "F-X-D"
return buttonB ? new target.extendedB.modXCDown : new target.fireFox.modXCDown
} else if (cLeft()) {
lastCoordTrace := "F-X-L"
return buttonB ? new target.extendedB.modXCLeft : new target.fireFox.modXCLeft
} else if (cRight()) {
lastCoordTrace := "F-X-R"
return buttonB ? new target.extendedB.modXCRight : new target.fireFox.modXCRight
} else {
lastCoordTrace := "F-X"
; if buttonB
return new target.extendedB.modX
}
} else if (modY()) {
if (cUp()) {
lastCoordTrace := "F-Y-U"
return buttonB ? new target.extendedB.modYCUp : new target.fireFox.modYCUp
} else if (cDown()) {
lastCoordTrace := "F-Y-D"
return buttonB ? new target.extendedB.modYCDown : new target.fireFox.modYCDown
} else if (cLeft()) {
lastCoordTrace := "F-Y-L"
return buttonB ? new target.extendedB.modYCLeft : new target.fireFox.modYCLeft
} else if (cRight()) {
lastCoordTrace := "F-Y-R"
return buttonB ? new target.extendedB.modYCRight : new target.fireFox.modYCRight
} else {
lastCoordTrace := "F-Y"
; if buttonB
return new target.extendedB.modY
}
}
}
reflectCoords(quadrantICoords) {
global xComp, global yComp
x := quadrantICoords[xComp], y := quadrantICoords[yComp]
if (down()) {
y *= -1
}
if (left()) {
x *= -1
}
return [x, y]
}
/* //////////////////////////////////////
This function is tasked to update the position on the analog stick
based on the currently seen cardinal directions and modifiers
*/
updateAnalogStick() {
global xComp, global yComp, global currentTimeMS
currentTimeMS := A_TickCount
coords := getAnalogCoords()
finalOutput := limitOutputs(coords[xComp], coords[yComp])
setAnalogStick([finalOutput.x, finalOutput.y])
return
}
/* Converts coordinates from gamecube controller integers (the fighting game engine limits the
coordinates to a circle that's centered in 0,0 and extends 80 units into all directions)
to vJoy values (whose full range is 0 to 32767 and is centered around 16384,16384).
*/
convertIntegerToVJoy(finalCoords) {
global xComp, global yComp
convertedCoords := []
convertedCoords[xComp] := 16384 + Round(128.63 * finalCoords[xComp])
convertedCoords[yComp] := 16301 - Round(128.38 * finalCoords[yComp])
return convertedCoords
}
; Send VJoy-formatted coordinates to vjoy interface
setAnalogStick(finalCoords) {
global xComp, global yComp, global myStick
convertedCoords := convertIntegerToVJoy(finalCoords)
myStick.SetAxisByIndex(convertedCoords[xComp], 1) ; control stick (leftstick, analog stick) X
myStick.SetAxisByIndex(convertedCoords[yComp], 2) ; same, Y
return
}
; //////////////// Get CStick coordinates. unit circle format
getCStickCoords() {
global
if (!anyVertC() and !anyHorizC()) {
cStickCoords := [0, 0]
} else if (anyVertC() and anyHorizC()) {
cStickCoords := [0.525, 0.85]
} else if (anyVertC()) {
cStickCoords := [0, 1]
} else {
if (modX() and up()) {
cStickCoords := [0.9, 0.5]
} else if (modX() and down()) {
cStickCoords := [0.9, -0.5]
} else {
cStickCoords := [1, 0]
}
}
return reflectCStickCoords(cStickCoords)
}
reflectCStickCoords(cStickCoords) {
global xComp, global yComp
x := cStickCoords[xComp]
y := cStickCoords[yComp]
if (cDown()) {
y *= -1
}
if (cLeft()) {
x *= -1
}
return [x, y]
}
/* //////////////////////////////////////
This function is tasked to update the position on the c-stick
based on the currently seen cardinal directions and modifiers
*/
updateCStick() {
setCStick(getCStickCoords())
return
}
setCStick(cStickCoords) {
global xComp, global yComp, global myStick
convertedCoords := convertCStickCoords(cStickCoords)
myStick.SetAxisByIndex(convertedCoords[xComp], 4) ; c-stick (rightstick) X
myStick.SetAxisByIndex(convertedCoords[yComp], 5) ; same, Y
return
}
convertCStickCoords(cStickCoords) { ; Converts coordinates from melee values (-1 to 1) to vJoy values (0 to 32767).
mx = 10271 ; Why this number? idk, I would have thought it should be 16384 * (80 / 128) = 10240, but this works
my = -10271
bx = 16448 ; 16384 + 64
by = 16320 ; 16384 - 64
return [ mx * cStickCoords[1] + bx
, my * cStickCoords[2] + by ]
}
setAnalogR(value) {
global
/* vJoy/Dolphin does something strange with rounding analog shoulder presses. In general,
it seems to want to round to odd values, so
16384 => 0.00000 (0) <-- actual value used for 0
19532 => 0.35000 (49) <-- actual value used for 49
22424 => 0.67875 (95) <-- actual value used for 94
22384 => 0.67875 (95)
22383 => 0.66429 (93)
But, *extremely* inconsistently, I have seen the following:
22464 => 0.67143 (94)
Which no sense and I can't reproduce.
*/
convertedValue := 16384 * (1 + (value / 255))
myStick.SetAxisByIndex(convertedValue, 3)
Return
}
; /////////////////////// hotkeys, and the functions and subroutines that handle hotkeys
; when a hotkey has the checkbox Special Bind, these hotkey labels take priority over the others
#If currentControlVarNameSp := HotkeyCtrlHasFocusIsSpecial()
LControl & RAlt::
LControl::
RControl::
LShift::
RShift::
LAlt::
RAlt::
LWin::
RWin::
+::
Critical
Gui, controlsWindow:Submit, NoHide
;Get the index of the hotkey control. example: "HK20" -> 20 is Start
hotkeyNum := SubStr(currentControlVarNameSp, 3)
If (A_ThisHotkey = "LControl & RAlt") {
GuiControl, controlsWindow:, HK%hotkeyNum%, % "^RAlt" ; make the control display altgr activation key.
}
else {
GuiControl,controlsWindow:, HK%hotkeyNum%, % A_ThisHotkey ; make the control display the hotkey.
}
validateModifiedControl(hotkeyNum)
Critical Off
return
*BackSpace::
Critical
modifier := ""
If GetKeyState("Shift","P")
modifier .= "+"
If GetKeyState("Ctrl","P")
modifier .= "^"
If GetKeyState("Alt","P")
modifier .= "!"
Gui, controlsWindow:Submit, NoHide
; overwrite the control content
GuiControl, controlsWindow:, %currentControlVarNameSp%, % modifier "BackSpace"
;Get the index of the hotkey control. example: "HK20" -> 20 is Start
hotkeyNum := SubStr(currentControlVarNameSp, 3)
validateModifiedControl(hotkeyNum)
Critical Off
return
#If
#If currentControlVarName := HotkeyCtrlHasFocus() ; expr evaluated every time we press one of these keys
*AppsKey:: ; Add support for these keys,
*Delete:: ; which the hotkey control does not normally allow.
*Enter::
*Escape::
*Pause::
*PrintScreen::
*Space::
*Tab::
Critical
modifier := ""
If GetKeyState("Shift","P")
modifier .= "+"
If GetKeyState("Ctrl","P")
modifier .= "^"
If GetKeyState("Alt","P")
modifier .= "!"
Gui, controlsWindow:Submit, NoHide
; overwrite the control content
GuiControl, controlsWindow:, %currentControlVarName%, % modifier SubStr(A_ThisHotkey,2)
; overwrite the control content
hotkeyNum := SubStr(currentControlVarName, 3)
validateModifiedControl(hotkeyNum)
Critical Off
return
#If ; end of conditional hotkeys
;-------macros
Pause::Suspend
^!r:: Reload ; Ctrl+Alt+R
SetKeyDelay, 0
#MaxHotkeysPerInterval 200
^!s:: ; Ctrl+Alt+S
Suspend, Toggle
If A_IsSuspended
TrayTip, % "Rectangle Controller Script:", % "Hotkeys Disabled (''Suspend'' Mode)", 2, 0
Else
TrayTip, % "Rectangle Controller Script:", % "Hotkeys Enabled", 2, 0
Return
; Analog Up
Label1:
Critical
buttonUp := true, updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
Label1_UP:
Critical
buttonUp := false, updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
; Analog Down
Label2:
Critical
buttonDown := true, updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
Label2_UP:
Critical
buttonDown := false, updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
; Analog Left
Label3:
Critical
buttonLeft := true, updateAnalogStick()
Critical Off
Sleep -1
return
Label3_UP:
Critical
buttonLeft := false, updateAnalogStick()
Critical Off
Sleep -1
return
; Analog Right
Label4:
Critical
buttonRight := true, updateAnalogStick()
Critical Off
Sleep -1
return
Label4_UP:
Critical
buttonRight := false, updateAnalogStick()
Critical Off
Sleep -1
return
; ModX
Label5:
Critical
buttonModX := true, updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
Label5_UP:
Critical
buttonModX := false, updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
; ModY
Label6:
Critical
buttonModY := true, updateAnalogStick()
Critical Off
Sleep -1
return
Label6_UP:
Critical
buttonModY := false, updateAnalogStick()
Critical Off
Sleep -1
return
; A
Label7:
buttonA := true, myStick.SetBtn(1,5)
return
Label7_UP:
buttonA := false, myStick.SetBtn(0,5)
return
; B
Label8:
Critical
buttonB := true, myStick.SetBtn(1, 4), updateAnalogStick()
Critical Off
Sleep -1
return
Label8_UP:
Critical
buttonB := false, myStick.SetBtn(0, 4), updateAnalogStick()
Critical Off
Sleep -1
return
; L
Label9:
Critical
buttonL := true, myStick.SetBtn(1, 1), updateAnalogStick()
Critical Off
Sleep -1
return
Label9_UP:
Critical
buttonL := false, myStick.SetBtn(0, 1), updateAnalogStick()
Critical Off
Sleep -1
return
; R
Label10:
Critical
buttonR := true, myStick.SetBtn(1, 3), updateAnalogStick()
Critical Off
Sleep -1
return
Label10_UP:
Critical
buttonR := false, myStick.SetBtn(0, 3), updateAnalogStick()
Critical Off
Sleep -1
return
; X
Label11:
buttonX := true, myStick.SetBtn(1, 6)
return
Label11_UP:
buttonX := false, myStick.SetBtn(0, 6)
return
; Y
Label12:
buttonY := true, myStick.SetBtn(1, 2)
return
Label12_UP:
buttonY := false, myStick.SetBtn(0, 2)
return
; Z
Label13:
buttonZ := true, myStick.SetBtn(1, 7)
return
Label13_UP:
buttonZ := false, myStick.SetBtn(0, 7)
return
; C Up
Label14:
Critical
buttonCUp := true
if (bothMods()) {
; Pressing ModX and ModY simultaneously changes C buttons to D pad
myStick.SetBtn(1, 9)
} else {
updateAnalogStick(), updateCStick()
}
Critical Off
Sleep -1
return
Label14_UP:
Critical
buttonCUp := false, myStick.SetBtn(0, 9), updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
; C Down
Label15:
Critical
buttonCDown := true
if (bothMods()) {
; Pressing ModX and ModY simultaneously changes C buttons to D pad
myStick.SetBtn(1, 11)
} else {
updateAnalogStick(), updateCStick()
}
Critical Off
Sleep -1
return
Label15_UP:
Critical
buttonCDown := false, myStick.SetBtn(0, 11), updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
; C Left
Label16:
Critical
buttonCLeft := true
if (bothMods()) {
; Pressing ModX and ModY simultaneously changes C buttons to D pad
myStick.SetBtn(1, 10)
} else {
updateAnalogStick(), updateCStick()
}
Critical Off
Sleep -1
return
Label16_UP:
Critical
buttonCLeft := false, myStick.SetBtn(0, 10), updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
; C Right
Label17:
Critical
buttonCRight := true
if (bothMods()) {
; Pressing ModX and ModY simultaneously changes C buttons to D pad
myStick.SetBtn(1, 12)
} else {
updateAnalogStick(), updateCStick()
}
Critical Off
Sleep -1
return
Label17_UP:
Critical
buttonCRight := false, myStick.SetBtn(0, 12), updateAnalogStick(), updateCStick()
Critical Off
Sleep -1
return
; Lightshield (Light)
Label18:
buttonLightShield := true, setAnalogR(49)
return
Label18_UP:
buttonLightShield := false, setAnalogR(0)
return
; Lightshield (Medium)
Label19:
buttonMidShield := true, setAnalogR(94)
return
Label19_UP:
buttonMidShield := false, setAnalogR(0)
return
; Start
Label20:
buttonStart := true, myStick.SetBtn(1, 8)
return
Label20_UP:
buttonStart := false, myStick.SetBtn(0, 8)
return
; D Up
Label21:
buttonDPadUp := true, myStick.SetBtn(1, 9)
return
Label21_UP: