Last active
January 3, 2023 05:50
-
-
Save Araeos/a35e2abb4a9e31c9380998972660668e to your computer and use it in GitHub Desktop.
UCR Plugin to emulate an H-shifter device. Add this file to "UCR\Plugins\User\"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; All plugins must derive from the _Plugin class | |
class HShifter extends _UCR.Classes.Plugin { | |
Type := "H-Shifter" | |
Description := "Emulate an H-Shifter output, controlled by any (non-toggling) input" | |
CurrentPosition := 0 | |
; The Init() method of a plugin is called when one is added. Use it to create your Gui etc | |
Init(){ | |
PositionCount := 7 | |
Loop % PositionCount { | |
; Create the GUI | |
yPos := (A_Index - 1) * 70 | |
if (A_Index == 1) { | |
name := "Neutral" | |
} else { | |
name := "Gear " . (A_Index - 1) | |
} | |
Gui, Add, GroupBox, Center xm y%yPos% w170 h60 section, %name% Input | |
IB := "IB" . A_Index | |
this.AddControl("InputButton", IB, 0, this.MyHkChangedState.Bind(this, A_Index), "xs+5 ys+20") | |
this.AddControl("ButtonPreview", "", 0, this.IOControls[IB], "x+5 yp+5") | |
;Gui, Add, Text, y+10, % "Remap" | |
Gui, Add, GroupBox, Center x190 y%yPos% w170 h60 section, %name% Output | |
OB := "OB" . A_Index | |
this.AddControl("OutputButton", OB, 0, "xs+5 ys+20") | |
this.AddControl("ButtonPreview", "", 0, this.IOControls[OB], "x+5 yp+5") | |
} | |
} | |
SetPosition(i) { | |
if (this.CurrentPosition != i) { | |
if (this.CurrentPosition > 0) { | |
this.IOControls["OB" . this.CurrentPosition].Set(FAlSE) | |
} | |
this.CurrentPosition := i | |
if (this.CurrentPosition > 0) { | |
this.IOControls["OB" . this.CurrentPosition].Set(TRUE) | |
} | |
} | |
} | |
; Called when the hotkey changes state (key is pressed or released) | |
MyHkChangedState(i, e){ | |
;OutputDebug, % "UCR| Plugin" this.Name " changed state to: " (e ? "Down" : "Up") | |
if (e) { | |
this.SetPosition(1) | |
} else { | |
this.SetPosition(i) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment