I call this plugin, ButtonsToButtons
This will allow assigning one button or key as a "shift" and reassigning up to 16 shifted and non-shifted buttons to the vJoy virtual joystick (which has over 64 buttons).
You can load more than one plugin at once and assign a different shift button, but there is some overlap and it needs to be experimented to get the right outcome. Hat buttons seem happy to duplicate, others not.
You can get combinations happening if you load the same plugin twice and assign either the same keys or others. These side effects may or may not be desirable.
It's possible in some cases to assign two output against one input if you have more than one plugin loaded.
The "Ignore if other proc shifted" checkbox is to help overcome the situation where you have 2 plugins loaded, and the first plugin sees your shift key, but the second only sees your output key. You might have 2 virtual buttons activate at one time which may not be desirable. It's kinda hard to explain. Only way to understand is to just experiment.
I used the original ButtonToButton plugin as a template. Thanks go to the original author.
Code: Select all
/*
A sample plugin to map a digital input to a digital output
When UCR is finished, valid inputs will be:
Keyboard*, Mouse Buttons/Wheel*, Joystick Buttons, Joystick Hat directions
Modes supported (Key / Mouse only): Block, Wild, Repeat Supression
Valid outputs will be:
Keyboard, Mouse Buttons/Wheel, Virtual Joystick Buttons / Hat directions
*/
Global GlobalShiftingFlag = 0 ; Lets us know if another instance is currently in shift mode.
; All plugins must derive from the _Plugin class
class ButtonsToButtons extends _UCR.Classes.Plugin {
Type := "Remapper (Buttons To Buttons)"
Description := "Remaps 16 buttons as well as a shift button to assign another 16 virtual buttons"
LocalShiftingFlag := 0 ; Use this and the GlobalShiftingFlag to know whether this or other instances
; are in shift mode and avoid holding down 2 buttons at once if possible.
; The Init() method of a plugin is called when one is added. Use it to create your Gui etc
Init(){
; Create the GUI
iow := 125
Gui, Add, GroupBox, Center xm ym w165 h60 section, Shift Button
this.AddControl("InputButton", "IB1", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+15")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB1, "x+5 yp+5")
Gui, Add, GroupBox, Center x175 ym w165 h730 section, Input Button .
this.AddControl("InputButton", "IB2", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+15")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB2, "x+5 yp+5")
this.AddControl("InputButton", "IB3", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB3, "x+5 yp+5")
this.AddControl("InputButton", "IB4", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB4, "x+5 yp+5")
this.AddControl("InputButton", "IB5", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB5, "x+5 yp+5")
this.AddControl("InputButton", "IB6", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB6, "x+5 yp+5")
this.AddControl("InputButton", "IB7", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB7, "x+5 yp+5")
this.AddControl("InputButton", "IB8", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB8, "x+5 yp+5")
this.AddControl("InputButton", "IB9", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB9, "x+5 yp+5")
this.AddControl("InputButton", "IB10", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB10, "x+5 yp+5")
this.AddControl("InputButton", "IB11", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB11, "x+5 yp+5")
this.AddControl("InputButton", "IB12", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB12, "x+5 yp+5")
this.AddControl("InputButton", "IB13", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB13, "x+5 yp+5")
this.AddControl("InputButton", "IB14", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB14, "x+5 yp+5")
this.AddControl("InputButton", "IB15", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB15, "x+5 yp+5")
this.AddControl("InputButton", "IB16", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB16, "x+5 yp+5")
this.AddControl("InputButton", "IB17", 0, this.MyHkChangedState.Bind(this), "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.IB17, "x+5 yp+5")
Gui, Add, GroupBox, Center x340 ym w170 h730 section, Non-Shifted Output Button .
this.AddControl("OutputButton", "OB1", 0, "xs+5 yp+15")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB1, "x+5 yp+5")
this.AddControl("OutputButton", "OB3", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB3, "x+5 yp+5")
this.AddControl("OutputButton", "OB5", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB5, "x+5 yp+5")
this.AddControl("OutputButton", "OB7", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB7, "x+5 yp+5")
this.AddControl("OutputButton", "OB9", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB9, "x+5 yp+5")
this.AddControl("OutputButton", "OB11", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB11, "x+5 yp+5")
this.AddControl("OutputButton", "OB13", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB13, "x+5 yp+5")
this.AddControl("OutputButton", "OB15", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB15, "x+5 yp+5")
this.AddControl("OutputButton", "OB17", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB17, "x+5 yp+5")
this.AddControl("OutputButton", "OB19", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB19, "x+5 yp+5")
this.AddControl("OutputButton", "OB21", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB21, "x+5 yp+5")
this.AddControl("OutputButton", "OB23", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB23, "x+5 yp+5")
this.AddControl("OutputButton", "OB25", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB25, "x+5 yp+5")
this.AddControl("OutputButton", "OB27", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB27, "x+5 yp+5")
this.AddControl("OutputButton", "OB29", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB29, "x+5 yp+5")
this.AddControl("OutputButton", "OB31", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB31, "x+5 yp+5")
Gui, Add, GroupBox, Center x510 ym w170 h730 section, Shifted Output Button .
this.AddControl("OutputButton", "OB2", 0, "xs+5 ys+15")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB2, "x+5 yp+5")
this.AddControl("OutputButton", "OB4", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB4, "x+5 yp+5")
this.AddControl("OutputButton", "OB6", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB6, "x+5 yp+5")
this.AddControl("OutputButton", "OB8", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB8, "x+5 yp+5")
this.AddControl("OutputButton", "OB10", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB10, "x+5 yp+5")
this.AddControl("OutputButton", "OB12", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB12, "x+5 yp+5")
this.AddControl("OutputButton", "OB14", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB14, "x+5 yp+5")
this.AddControl("OutputButton", "OB16", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB16, "x+5 yp+5")
this.AddControl("OutputButton", "OB18", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB18, "x+5 yp+5")
this.AddControl("OutputButton", "OB20", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB20, "x+5 yp+5")
this.AddControl("OutputButton", "OB22", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB22, "x+5 yp+5")
this.AddControl("OutputButton", "OB24", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB24, "x+5 yp+5")
this.AddControl("OutputButton", "OB26", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB26, "x+5 yp+5")
this.AddControl("OutputButton", "OB28", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB28, "x+5 yp+5")
this.AddControl("OutputButton", "OB30", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB30, "x+5 yp+5")
this.AddControl("OutputButton", "OB32", 0, "xs+5 yp+40")
this.AddControl("ButtonPreview", "", 0, this.IOControls.OB32, "x+5 yp+5")
;If another copy of this plugin is loaded, don't produce non-shifted button if other shift key is pressed.
Gui, Add, GroupBox, Center xm ym+60 w165 h60 section, Settings
this.AddControl("Checkbox", "Toggle", 0, "xs+5 yp+30", "Ignore If Other Proc Shifted")
; Clear the controls , otherwise they sometimes initialize with a '-1'
this.IOControls.IB1.Set(0)
this.IOControls.IB2.Set(0)
this.IOControls.IB3.Set(0)
this.IOControls.IB4.Set(0)
this.IOControls.IB5.Set(0)
this.IOControls.IB6.Set(0)
this.IOControls.IB7.Set(0)
this.IOControls.IB8.Set(0)
this.IOControls.IB9.Set(0)
this.IOControls.IB10.Set(0)
this.IOControls.IB11.Set(0)
this.IOControls.IB12.Set(0)
this.IOControls.IB13.Set(0)
this.IOControls.IB14.Set(0)
this.IOControls.IB15.Set(0)
this.IOControls.IB16.Set(0)
this.IOControls.IB17.Set(0)
}
; The main code is here. Called when a key or button changes state (pressed or released)
MyHkChangedState(e){
;OutputDebug, % "UCR| Plugin" this.Name " changed state to: " (e ? "Down" : "Up")
;OutputDebug, % "GlobalShiftingFlag = " GlobalShiftingFlag
;OutputDebug, % "LocalShiftingFlag = " this.localShiftingFlag
if(this.IOControls.IB1.Get()){
this.ClearRealOutputs()
this.UpdateVirtualOutputs()
GlobalShiftingFlag = 1
this.LocalShiftingFlag := 1
}else {
if(GlobalShiftingFlag == 1){
this.ClearRealOutputs()
}
if(this.GuiControls.Toggle.Get()){ ; If checked and another process shift key is pressed, don't produce non-shifted button
if(GlobalShiftingFlag == 0 || this.LocalShiftingFlag == 1) { ;If only my shift key is pressed
this.ClearVirtualOutputs()
this.UpdateRealOutputs()
GlobalShiftingFlag = 0
this.LocalShiftingFlag := 0
}
}else{
this.ClearVirtualOutputs()
this.UpdateRealOutputs()
GlobalShiftingFlag = 0
this.LocalShiftingFlag := 0
}
}
}
ClearVirtualOutputs()
{
this.IOControls.OB2.Set(0)
this.IOControls.OB4.Set(0)
this.IOControls.OB6.Set(0)
this.IOControls.OB8.Set(0)
this.IOControls.OB10.Set(0)
this.IOControls.OB12.Set(0)
this.IOControls.OB14.Set(0)
this.IOControls.OB16.Set(0)
this.IOControls.OB18.Set(0)
this.IOControls.OB20.Set(0)
this.IOControls.OB22.Set(0)
this.IOControls.OB24.Set(0)
this.IOControls.OB26.Set(0)
this.IOControls.OB28.Set(0)
this.IOControls.OB30.Set(0)
this.IOControls.OB32.Set(0)
}
ClearRealOutputs()
{
this.IOControls.OB1.Set(0)
this.IOControls.OB3.Set(0)
this.IOControls.OB5.Set(0)
this.IOControls.OB7.Set(0)
this.IOControls.OB9.Set(0)
this.IOControls.OB11.Set(0)
this.IOControls.OB13.Set(0)
this.IOControls.OB15.Set(0)
this.IOControls.OB17.Set(0)
this.IOControls.OB19.Set(0)
this.IOControls.OB21.Set(0)
this.IOControls.OB23.Set(0)
this.IOControls.OB25.Set(0)
this.IOControls.OB27.Set(0)
this.IOControls.OB29.Set(0)
this.IOControls.OB31.Set(0)
}
UpdateVirtualOutputs()
{
this.IOControls.OB2.Set(this.IOControls.IB2.Get())
this.IOControls.OB4.Set(this.IOControls.IB3.Get())
this.IOControls.OB6.Set(this.IOControls.IB4.Get())
this.IOControls.OB8.Set(this.IOControls.IB5.Get())
this.IOControls.OB10.Set(this.IOControls.IB6.Get())
this.IOControls.OB12.Set(this.IOControls.IB7.Get())
this.IOControls.OB14.Set(this.IOControls.IB8.Get())
this.IOControls.OB16.Set(this.IOControls.IB9.Get())
this.IOControls.OB18.Set(this.IOControls.IB10.Get())
this.IOControls.OB20.Set(this.IOControls.IB11.Get())
this.IOControls.OB22.Set(this.IOControls.IB12.Get())
this.IOControls.OB24.Set(this.IOControls.IB13.Get())
this.IOControls.OB26.Set(this.IOControls.IB14.Get())
this.IOControls.OB28.Set(this.IOControls.IB15.Get())
this.IOControls.OB30.Set(this.IOControls.IB16.Get())
this.IOControls.OB32.Set(this.IOControls.IB17.Get())
}
UpdateRealOutputs()
{
this.IOControls.OB1.Set(this.IOControls.IB2.Get())
this.IOControls.OB3.Set(this.IOControls.IB3.Get())
this.IOControls.OB5.Set(this.IOControls.IB4.Get())
this.IOControls.OB7.Set(this.IOControls.IB5.Get())
this.IOControls.OB9.Set(this.IOControls.IB6.Get())
this.IOControls.OB11.Set(this.IOControls.IB7.Get())
this.IOControls.OB13.Set(this.IOControls.IB8.Get())
this.IOControls.OB15.Set(this.IOControls.IB9.Get())
this.IOControls.OB17.Set(this.IOControls.IB10.Get())
this.IOControls.OB19.Set(this.IOControls.IB11.Get())
this.IOControls.OB21.Set(this.IOControls.IB12.Get())
this.IOControls.OB23.Set(this.IOControls.IB13.Get())
this.IOControls.OB25.Set(this.IOControls.IB14.Get())
this.IOControls.OB27.Set(this.IOControls.IB15.Get())
this.IOControls.OB29.Set(this.IOControls.IB16.Get())
this.IOControls.OB31.Set(this.IOControls.IB17.Get())
}
}
The plugin is named .. ButtonsToButtons.ahk
The above goes in the UCR/plugins/user/folder
Main programs are here ...
https://autohotkey.com/boards/viewtopic ... cr+plugins
http://vjoystick.sourceforge.net/site/i ... l/download
You set up all the virtual buttons and then assign in your game. You can merge several joysticks into one, have a mixture of your physical, virtual and shifted virtual buttons depending on what you assign in UCR and your game.