Hello evilC
Thank you for this amazing tool! I just have a small issue you maybe could help me with.
I made a plugin based off of the ButtonToButton Plugin. It has 2 inputs and 1 output. If none of the inputs is on, then the output is on. (Basically, I want the off state of my joystick toggle switches as a vjoy button)
It works perfectly. Only when starting UCR, it doesn't detect if an input is already on. I have to cycle my joystick toggle to off (which should activate the output, but it doesn't) then to on again. Then it shows the input as on. Then if I toggle it off again it shows the output on (as it should).
After that it works as intended. Whats extra strange is, that only happens if any of the activated plugins in the profile has a vjoy output button selected.
It also doesn't seem to be a problem with my plugin specifically, because it also occurs with the default ButtonToButton plugin (but only if i have 2 of them in the profile with vjoy outputs).
Another small problem i was having (that's maybe connected to that) was, that at startup, if both my inputs were off, it didn't show my output as on. Again, only after cycling one button, it was off.
So i tried getting the input state with IB1.Get() in the OnActive() function. But that also didn't get the correct state of the input.
I only managed to get the state with
Code: Select all
GetKeyState(b1.DeviceID "joy" b1.Binding[1])
. It works, but seems a bit hacky to me. Is there a better way?
Here is the complete code:
Code: Select all
class 3WayToggle extends _UCR.Classes.Plugin {
Type := "Remapper (3Way Toggle off state to button)"
Description := "Remaps toggle off state to button"
Init(){
; Create the GUI
Gui, Add, GroupBox, Center xm ym w340 h60 section, On and off toggles
this.AddControl("InputButton", "IB1", 0, this.MyHkChangedState.Bind(this), "xs+5 ys+20")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB1, "x+5 yp+5")
this.AddControl("InputButton", "IB2", 0, this.MyHkChangedState.Bind(this), "xs+170 ys+20")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB2, "x+5 yp+5")
;Gui, Add, Text, y+10, % "Remap"
Gui, Add, GroupBox, Center x370 ym w170 h60 section, Output Button
this.AddControl("OutputButton", "OB1", 0, "xs+5 ys+20")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB1, "x+5 yp+5")
}
OnActive(){
b1 := this.IOControls.IB1.GetBinding()
b2 := this.IOControls.IB2.GetBinding()
this.IOControls.OB1.Set(!GetKeyState(b1.DeviceID "joy" b1.Binding[1]) && !GetKeyState(b2.DeviceID "joy" b2.Binding[1]))
}
; Called when the hotkey changes state (key is pressed or released)
MyHkChangedState(e){
this.IOControls.OB1.Set(!e)
}
}