Universal Control Remapper (UCR) - v0.1.22 28th Oct 2018

Post gaming related scripts
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

25 Jan 2017, 16:15

I sat down tonight and tried to write what I think these users are asking for.
I managed to get it working, but if you tap keys too quickly it goes nuts :(
I have a friend coming around so won't be able to spend any more time on it tonight...

Still, I found the writing of the logic a lot more challenging than I had anticipated, but it was fun to solve, and I feel I learned something.
A dynamic operator function (pass two params and a string of operator(s)) plus a {-1: "<", 1: ">"} style associative array can be very powerful

Such as:

Code: Select all

MoveTick(dir, amt, stopat){
	static ops := {-1: "<=", 1: ">="}
	
	out := this.AxisState + amt
	if (this.Expression(out, ops[dir], stopat)){
Anyway, enough waffle. Copy this text, paste it into a file called ButtonsToAxisSoft.ahk and place it in <UCR Folder>\Plugins\User
Glitches aside, @azerty and @guest - is this the kind of behavior you want?

Code: Select all

/*
	POC plugin for "Soft" keyboard to joystick mapping.
*/
class ButtonsToAxisSoft extends _UCR.Classes.Plugin {
	Type := "Remapper (Buttons To Axis - SOFT)"
	Description := "Remaps two InputButtons to one OutputAxis"
	
	AxisButtonStates := [0,0]

	AxisState := 0
	TickAmount := 0
	TickRate := 0
	TickFn := 0
	
	;~ MoveTickTimerStatus := [0, 0]

	Init(){
		iow := 125
		Gui, Add, GroupBox, Center xm ym w270 h85 section, Input Buttons
		Gui, Add, Text, % "Center xs+5 yp+30 w" iow, Low
		Gui, Add, Text, % "Center x+10 w" iow " yp", High
		this.AddControl("InputButton", "IB1", 0, this.ButtonInput.Bind(this, -1), " xs+5 yp+15")
		this.AddControl("InputButton", "IB2", 0, this.ButtonInput.Bind(this, 1), "x+10 yp")

		Gui, Add, GroupBox, Center x410 ym w260 h85 section, Output Axis
		Gui, Add, Text, % "Center xs+5 yp+30 w" iow, Axis
		Gui, Add, Text, % "Center x+0 w" iow " yp", Preview
		this.AddControl("OutputAxis", "OA1", 0, "xs+5 yp+15")
		Gui, Add, Slider, % "hwndhwnd x+0 yp", 50
		this.hSlider := hwnd
		
		Gui, Add, Text, % "Center xm w80", Tick Amount
		this.AddControl("Edit", "TickAmount", this.DecayChanged.Bind(this, 1), "x+5 yp w50", 10)
		Gui, Add, Text, % "Center x+20 yp w80", Tick Rate
		this.AddControl("Edit", "TickRate", this.DecayChanged.Bind(this, 2), "x+5 yp w50", 20)

	}
	
	OnActive(){
		this.SetState(50)
	}
	
	DecayChanged(whichvalue, value){
		if (whichvalue == 1){
			this.TickAmount := value
		} else {
			this.TickRate := value
		}
	}
	
	; One of the input buttons was pressed or released
	ButtonInput(dir, state){
		static limits := {-1: 0, 1: 100}
		;OutputDebug % "UCR| Axis: " axis ", Direction: " direction ", state: " state
		if (this.AxisButtonStates[direction] == state)
			return	; filter repeats if not in Incremental Mode
		this.AxisButtonStates[direction] := state

		if (fn := this.TickFn != 0){
			try {
				SetTimer, % fn, Off
			}
			this.TickFn := 0
		}
		
		if (state){
			d := dir
		} else {
			d := dir * -1
		}
		limit := (state ? limits[dir] : 50)
		fn := this.MoveTick.Bind(this, d, this.TickAmount * d, limit)
		this.TickFn := fn
		fn.Call()
		SetTimer, % fn, % this.TickRate
		;~ this.SetMoveTickTimerState(direction, state)
	}
	
	SetState(out){
		this.AxisState := out
		this.IOControls.OA1.Set(out)
		GuiControl, , % this.hSlider, % out
	}
	
	;         1    25    100    Press Right
	;        -1   -25     0     Press Left
	;        -1   -25    50     Release Right
	;         1    25    50     Release Left
	MoveTick(dir, amt, stopat){
		static ops := {-1: "<=", 1: ">="}
		
		out := this.AxisState + amt
		if (this.Expression(out, ops[dir], stopat)){
			out := stopat
			if (fn := this.TickFn){
				try {
					SetTimer, % fn, Off
				}
				this.TickFn := 0
			}
		}
		this.SetState(out)
	}
	
	DisableMoveTimer(){
		
	}

	Expression( B, O, A ) {
		Return, O="=" ? B=A:O="==" ? B==A:O=">" ? B>A:O=">=" ? B>=A:O="<" ? B<A:O="<=" ? B<=A:O="<>" || O="!=" ? B<>A:"ERROR"
	}
}
Edit #1: Added labels
Last edited by evilC on 25 Jan 2017, 16:29, edited 1 time in total.
keem85
Posts: 25
Joined: 03 Aug 2016, 03:14

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

25 Jan 2017, 16:16

Hi! Chiming in here! I'd just like to say thanks! All your troubleshooting steps helped, but I actually had to uninstall vJoy completely before I got it to work. Works now!
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

25 Jan 2017, 16:21

If UCR is not working when vJoy is installed, then there is likely something wrong with your vJoy install. There have been a slew of bad releases lately, but even with good releases the installer sometimes seems to get something wrong. Would advise something like CCleaner etc to clean all traces of vjoy (registry, dlls etc), then try again with the latest version.
Also maybe try something like Joystick Gremlin, and see if that drives vJoy OK.

As previously mentioned, long-term, vJoy is being replaced with ViGEm, so if vJoy just won't play ball on your system, maybe vigem will.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

26 Jan 2017, 15:31

Here is a fixed version of the "Soft" key to joystick plugin:

Code: Select all

/*
	POC plugin for "Soft" keyboard to joystick mapping.
*/
class ButtonsToAxisSoft extends _UCR.Classes.Plugin {
	Type := "Remapper (Buttons To Axis - SOFT)"
	Description := "Remaps two InputButtons to one OutputAxis"
	
	AxisButtonStates := [0,0]

	AxisState := 0
	TickAmount := 0
	TickRate := 0
	TickFn := 0
	
	Init(){
		iow := 125
		Gui, Add, GroupBox, Center xm ym w270 h85 section, Input Buttons
		Gui, Add, Text, % "Center xs+5 yp+30 w" iow, Low
		Gui, Add, Text, % "Center x+10 w" iow " yp", High
		this.AddControl("InputButton", "IB1", 0, this.ButtonInput.Bind(this, -1), " xs+5 yp+15")
		this.AddControl("InputButton", "IB2", 0, this.ButtonInput.Bind(this, 1), "x+10 yp")

		Gui, Add, GroupBox, Center x410 ym w260 h85 section, Output Axis
		Gui, Add, Text, % "Center xs+5 yp+30 w" iow, Axis
		Gui, Add, Text, % "Center x+0 w" iow " yp", Preview
		this.AddControl("OutputAxis", "OA1", 0, "xs+5 yp+15")
		Gui, Add, Slider, % "hwndhwnd x+0 yp", 50
		this.hSlider := hwnd
		
		Gui, Add, Text, % "Center xm w80", Tick Amount
		this.AddControl("Edit", "TickAmount", this.DecayChanged.Bind(this, 1), "x+5 yp w50", 10)
		Gui, Add, Text, % "Center x+20 yp w80", Tick Rate
		this.AddControl("Edit", "TickRate", this.DecayChanged.Bind(this, 2), "x+5 yp w50", 20)

	}
	
	OnActive(){
		this.SetState(50)
	}
	
	DecayChanged(whichvalue, value){
		if (whichvalue == 1){
			this.TickAmount := value
		} else {
			this.TickRate := value
		}
	}
	
	; One of the input buttons was pressed or released
	ButtonInput(dir, state){
		static limits := {-1: 0, 1: 100}
		;OutputDebug % "UCR| Axis: " axis ", Direction: " direction ", state: " state
		if (this.AxisButtonStates[direction] == state)
			return	; filter repeats if not in Incremental Mode
		this.AxisButtonStates[direction] := state

		this.StopMoveTimer()
		
		d := state ? dir : dir * -1
		limit := (state ? limits[dir] : 50)
		fn := this.MoveTick.Bind(this, d, this.TickAmount * d, limit)
		this.TickFn := fn
		fn.Call()
		SetTimer, % fn, % this.TickRate
	}
	
	SetState(out){
		this.AxisState := out
		this.IOControls.OA1.Set(out)
		GuiControl, , % this.hSlider, % out
	}
	
	;         1    25    100    Press Right
	;        -1   -25     0     Press Left
	;        -1   -25    50     Release Right
	;         1    25    50     Release Left
	MoveTick(dir, amt, stopat){
		static ops := {-1: "<=", 1: ">="}
	
		out := this.AxisState + amt
		if (this.Expression(out, ops[dir], stopat)){
			out := stopat
			this.StopMoveTimer()
		}
		this.SetState(out)
	}
	
	StopMoveTimer(){
		if ((fn := this.TickFn) != 0){
			try {
				SetTimer, % fn, Off
			}
			this.TickFn := 0
		}
	}

	Expression( B, O, A ) {
		Return, O="=" ? B=A:O="==" ? B==A:O=">" ? B>A:O=">=" ? B>=A:O="<" ? B<A:O="<=" ? B<=A:O="<>" || O="!=" ? B<>A:"ERROR"
	}
}
thieftheodore
Posts: 9
Joined: 31 Dec 2016, 12:39

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

27 Jan 2017, 01:14

I have a silly idea regarding games taking dual input from virtual and physical joystick, dunno if this works or not. How about making the virtual joystick inputting twice or more as fast as possible when pushing pushing button once from the physical joystick
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

27 Jan 2017, 10:49

evilC wrote: Here is a fixed version of the "Soft" key to joystick plugin:
I see how that would be nice for a (for example) driving game.
Consider removing fn.Call() towards the end of ButtonInput(...), quickliy alternateing low/high direction seems to get you stuck at the center if this is present. As long as the tick rate is at a quite low value, like below 100, you wouldn't notice the slight loss of responsiveness from removing it.

Cheers!
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

27 Jan 2017, 11:11

thieftheodore wrote:I have a silly idea regarding games taking dual input from virtual and physical joystick, dunno if this works or not. How about making the virtual joystick inputting twice or more as fast as possible when pushing pushing button once from the physical joystick
If I understand you correctly, it's impossible.
You can never make the virtual stick send it's output before the physical stick.

Fear not, a proper solution for the "dual input" issue is coming - The HidGuardian component of ViGEm will allow us to completely hide physical sticks from games. We just need to wait for Nefarius to finish it.
Helgef wrote:
evilC wrote: Here is a fixed version of the "Soft" key to joystick plugin:
I see how that would be nice for a (for example) driving game.
Consider removing fn.Call() towards the end of ButtonInput(...), quickliy alternateing low/high direction seems to get you stuck at the center if this is present. As long as the tick rate is at a quite low value, like below 100, you wouldn't notice the slight loss of responsiveness from removing it.

Cheers!
I could make a check, and only call it if the rate is >100 or something.
Snoothy
Posts: 2
Joined: 19 Jan 2017, 17:18
Contact:

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

31 Jan 2017, 12:15

Is there any plans to implement profile switching from command line parameters any time soon so, for example, rlauncher can control UCR?

If not, do you have any plans regarding it? Because I would like to implement it if you don't have anything in the works.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

31 Jan 2017, 12:34

What do you mean - launch a new instance of UCR and change profile, or change profile in an existingly running instance of UCR?

The former would be pretty easy, the latter would probably require a fair amount of work.
azerty55
Posts: 13
Joined: 28 Nov 2016, 17:34
Contact:

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

31 Jan 2017, 14:51

ok sorry but i bring outdated news
first i test helgef plugin about acceleration decay and finally it works ; i feel acceleration when i put 0 in inertia but i didn t understand that before
But there is a problem ; when i pressed key it has a delay to move so i have to hold key longer than i expected to move, i try to fix this with cap or timeout setting but i fail

i hope your plugin fix this ,i will test soon but now i have little time
Snoothy
Posts: 2
Joined: 19 Jan 2017, 17:18
Contact:

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

31 Jan 2017, 15:37

evilC wrote:What do you mean - launch a new instance of UCR and change profile, or change profile in an existingly running instance of UCR?

The former would be pretty easy, the latter would probably require a fair amount of work.
Changing profile of an existing running instance would be the preferable way. This means vBox controllers won't be replugged during restart (could possibly cause some problems) and profile switching would be considerably faster.
But is this something you have in the pipeline?
billyisms
Posts: 10
Joined: 06 Jul 2016, 19:38

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

31 Jan 2017, 15:40

I was forced to reinstall ScpVbus before the virtual Xbox controller showed up in Windows on my PC. I just wanted to give the heads-up if anyone else is not able to get the Xbox controller to show up despite everything looking correct in UCR and vJoy. I might have had the wrong version of ScpVbus installed.

Thanks for all your work evilC. I see that you added the Toggle mode in the latest version :dance:
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

31 Jan 2017, 18:32

azerty55 wrote: when i pressed key it has a delay to move so i have to hold key longer than i expected to move
It is due to the time it takes for your keyboard to start autorepeat a pressed key, it is easy to fix this, by re-calling the input function via SetTimer. There is one new parameter, rate, lower values means quicker. You can get a lot of different behaviour with this, you'll need to tweak until you find something suitable.

Code: Select all

class ButtonsToAxisAccAndDecay extends _UCR.Classes.Plugin {
	Type := "Remapper (Buttons To Axis) (Acceleration and Decay)"
	Description := "Remaps two InputButtons to one OutputAxis - Added acceleration and decay options"
	
	AxisButtonStates := [0,0]
	DeflectionValues := []
	IncrementalMode := 0
	
	Init(){
		iow := 125
		Gui, Add, GroupBox, Center xm ym w270 h70 section, Input Buttons
		Gui, Add, Text, % "Center xs+5 yp+15 w" iow, Low
		Gui, Add, Text, % "Center x+10 w" iow " yp", High
		this.AddControl("InputButton", "IB1", 0, this.ButtonInput.Bind(this, 1), " xs+5 yp+15")
		this.AddControl("InputButton", "IB2", 0, this.ButtonInput.Bind(this, 2), "x+10 yp")

		Gui, Add, GroupBox, Center x285 ym w120 h70 section, Settings
		Gui, Add, Text, % "Center xs+5 yp+15 w110", Deflection `%
		this.AddControl("Edit", "DeflectionAmount", this.DeflectionChanged.Bind(this), "xs+5 w110 yp+15 center", 100)
		this.AddControl("CheckBox", "IncrementalMode", this.IncrementalModeChanged.Bind(this), "xp y+3", "Incremental Mode")
		
		
		Gui, Add, GroupBox, Center x410 ym w260 h70 section, Output Axis
		Gui, Add, Text, % "Center xs+5 yp+15 w" iow, Axis
		Gui, Add, Text, % "Center x+2 w" iow " yp", Preview
		this.AddControl("OutputAxis", "OA1", 0, "xs+5 yp+15")
		Gui, Add, Slider, % "hwndhwnd x+2 yp", 50
		this.hSlider := hwnd
		
		; Acceleration settings
		Gui, Add, GroupBox, Center xm y80 w325 h45 section, Acceleration
		this.AddControl("CheckBox", "accMode", this.AccModeChanged.Bind(this), "xp+4 yp+20", "Enable")
		
		Gui, Add, Text, % "Center x+3 hwndinertiaText", % "Inertia:"
		this.inertiaText:=inertiaText
		this.AddControl("Edit", "inertiaEdit", this.inertiaChanged.Bind(this), "x+3 yp-3 w20 center number disabled", 3)
		
		Gui, Add, Text, % "Center x+3 yp+3 hwndrateText", % "Rate:"
		this.rateText:=rateText
		this.AddControl("Edit", "incrementRateEdit", this.incrementRateChanged.Bind(this), "x+3 yp-3 w25 center number disabled", 30)
		
		this.AddControl("CheckBox", "accCapCB", this.AccCapCBChanged.Bind(this), "x+3 yp+3 disabled", "Cap")
		this.AddControl("Edit", "accCapEdit", this.AccCapChanged.Bind(this), "x+3 yp-3 w20 center number disabled", 5)
		
		Gui, Add, Text, % "Center x+3 yp+3 hwndresetText", % "Timeout:"
		this.resetText:=resetText
		this.AddControl("Edit", "resetEdit", this.resetChanged.Bind(this), "x+3 yp-3 w30 center number disabled", 150)
		
		this.tic:=0, this.acc:=0, pAccdir:=0, this.inertiaCtr:=0											 ;  Acceleration handling parameters
		
		; Decay settings
		Gui, Add, GroupBox, Center x+5 y80 w340 h45 section, Decay
		this.AddControl("CheckBox", "decayMode", this.DecayModeChanged.Bind(this), "xs+10 yp+20", "Enable")
		Gui, Add, Text, % "Center x+5 hwnddecayRateText", % "Rate:"
		this.decayRateText:=decayRateText
		this.AddControl("Edit", "decayRateEdit", this.DecayRateChanged.Bind(this), "x+5 yp-3 w30 center number disabled", 25)
		Gui, Add, Text, % "Center x+5 yp+2 hwnddecayStepText", % "Step:"
		this.decayStepText:=decayStepText
		this.AddControl("Edit", "decayStepEdit", this.DecayStepChanged.Bind(this), "x+5 yp-3 w30 center number disabled", 3)
		Gui, Add, Text, % "Center x+5 yp+3 hwnddecayDelayText", % "Delay:"
		this.decayDelayText:=decayDelayText
		this.AddControl("Edit", "decayDelayEdit", this.DecayDelayChanged.Bind(this), "x+5 yp-3 w30 center number disabled", 200)
		this.AddControl("CheckBox", "linearDecayCB", this.LinearDecayCBChanged.Bind(this), "x+5 yp+4 checked disabled", "Linear")
	}
	
	OnClose(){
		if (this.decayTimer){
			timerFunc:=this.decayTimer
			try
				SetTimer, % timerFunc, delete
			this.decayTimer:=""
		}
		if (this.incrementTimer){
			timerFunc:=this.incrementTimer
			try
				SetTimer, % timerFunc, delete
			this.incrementTimer:=""
		}
		base.OnClose() ; ?
	}
	
	DeflectionChanged(pc){
		value := 50 * (pc / 100)
		this.IncrementalDeflectionValues[1] := value * -1
		this.IncrementalDeflectionValues[2] := value
		this.DeflectionValues[1] := UCR.Libraries.StickOps.InternalToAHK(value * -1)
		this.DeflectionValues[2] := UCR.Libraries.StickOps.InternalToAHK(value)
	}
	
	IncrementalModeChanged(state){
		this.IncrementalMode := state
	}
	
	; Decay settings functions
	
	DecayModeChanged(state){
		this.decayMode:=state
		if (state && !this.decayTimer)
			this.decayTimer:=ObjBindMethod(this,"decay")
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.linearDecayCB.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.decayRateEdit.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.decayRateText
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.decayStepEdit.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.decayStepText
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.decayDelayEdit.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.decayDelayText
	}
	
	LinearDecayCBChanged(state){
		this.linDecay:=state
	}
	
	DecayRateChanged(val){
		this.decayRate:=val
	}
	
	DecayStepChanged(val){
		this.decayStep:=val
	}
	
	DecayDelayChanged(val){
		this.decayDelay:=val?val:1 ; Not sure 0 is a good idea, test.
	}
	
	; Acceleration settings functions
	
	AccModeChanged(state){
		this.accMode := state
		; This is a bit over the top I guess...
		GuiControl, % state && this.capAccEnabled ? "Enable" : "Disable", % this.GuiControls.accCapEdit.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.accCapCB.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.inertiaEdit.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.inertiaText
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.incrementRateEdit.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.rateText
		GuiControl, % state ? "Enable" : "Disable", % this.GuiControls.resetEdit.hwnd
		GuiControl, % state ? "Enable" : "Disable", % this.resetText
	}
	
	incrementRateChanged(value){
		return this.incrementRate:=value
	}
	
	AccCapCBChanged(state){
		this.capAccEnabled:=state
		GuiControl, % state && this.accMode ? "Enable" : "Disable", % this.GuiControls.accCapEdit.hwnd
	}
	
	AccCapChanged(val){
		this.accCapVal:=val
	}
	
	inertiaChanged(val){
		this.inertiaChanged:=true
		this.inertiaVal:=val
	}
	
	resetChanged(val){
		this.timeout:=val
	}
	; End acceleration funtionc
	
	; One of the input buttons was pressed or released
	ButtonInput(direction, value){
		;OutputDebug % "UCR| Axis: " axis ", Direction: " direction ", value: " value
		
		if (!this.IncrementalMode && this.AxisButtonStates[direction] = value)
			return	; filter repeats if not in Incremental Mode
		
		if (this.IncrementalMode && !value && this.incrementTimer)
		{
			fn:=this.incrementTimer
			SetTimer, % fn, Delete
			this.incrementTimer:=""
		}
		
		this.AxisButtonStates[direction] := value
		
		if (this.IncrementalMode){
			; Incremental Mode - alter current axis by deflection value on press
			if (!value){
				this.decayMode ? this.setDecayTimer() : ""
				return	; Do nothing on release
			}
			if (this.accMode) {
				this.inertiaChanged ? (this.inertiaChanged:=false, this.inertiaCtr:=this.inertiaVal) : ""
				this.inertiaCtr && this.pAccdir==direction ? --this.inertiaCtr : this.inertiaCtr:=this.inertiaVal
				A_TickCount-this.tic < this.timeout && this.pAccdir==direction ? (this.capAccEnabled ? (this.acc<this.accCapVal && !this.inertiaCtr ? ++this.acc : "") : !this.inertiaCtr ? ++this.acc : "" ) : this.acc:=0	; Determine acceleration
			}
			out := this.IOControls.OA1.Get() + this.IncrementalDeflectionValues[direction] + (direction==1?-1:1)*this.acc
			this.accMode ? (this.tic:=A_TickCount, this.pAccdir:=direction) : this.acc:=0					; Update acceleration parameters
			this.decayMode ? this.stopDecayTimer() : ""
		} else {
			; Normal Mode - Set axis to deflection value on press, set to middle on release
			if (this.AxisButtonStates[1] == this.AxisButtonStates[2]){
				if (this.decayMode) {
					this.setDecayTimer()
					return
				}
				else {
					out:=50
				}
			} else {
				this.decayMode ? this.stopDecayTimer() : ""
				if (this.AxisButtonStates[1]){
					out := this.DeflectionValues[1]
				} else {
					out := this.DeflectionValues[2]
				}
			}
		}
		this.IOControls.OA1.Set(out)
		GuiControl, , % this.hSlider, % out
		if (this.IncrementalMode && value && !this.incrementTimer)
		{
			fn:=ObjBindMethod(this,"ButtonInput",direction,value)
			this.incrementTimer:=fn
			
			SetTimer, % fn, % this.incrementRate
		}
	}
	
	stopDecayTimer(){
		if !this.timerIsRunning
			return
		this.timerIsRunning:=0
		timerFunc:=this.decayTimer
		try
			SetTimer, % timerFunc , Delete
	}
	
	setDecayTimer(){
		this.startDecay:=1
		this.timerIsRunning:=1
		timerFunc:=this.decayTimer
		SetTimer, % timerFunc, % -this.decayDelay
	}
	
	decay(){
		static nonLinearFactor:=1.3 ; Internal setting, could be optional if one even wants non linear decay. Set <1 for decreasing rate, >1 for increasing.
		state:=this.IOControls.OA1.Get()
		dir:=this.calcDirection(state)
		if (this.startDecay) {
			this.pStep:=this.decayStep, this.pDir:=dir, this.startDecay:=0  ; Reset vars
		}
		step:=state+dir*(this.linDecay ? this.decayStep : abs(this.pStep)*nonLinearFactor + (nonLinearFactor<1?1:0))	; abs(pStep)*nonLinearFactor+(?:) is the nonLinearFactor formula, it is just taken out of the blue for testing.
		out:= (abs(state-50)<0.01 || dir!=this.pDir) ? out:=50 : step
		out := this.calcDirection(out)!=dir ? 50 : out ; guard against overshoot
		this.pStep:=step-state
		SetTimer,, % out==50 && ((this.timerIsRunning:=0) || true) ? "Off" : this.decayRate
		this.IOControls.OA1.Set(out)
		GuiControl, , % this.hSlider, % out
		this.pDir:=dir
	}
	
	calcDirection(state){
		return (state<50)-(state>=50)
	}
	
}
For reference, with these settings, the behaviour of these two plugins are quite similar,
plgn.png
plgn.png (19.21 KiB) Viewed 6391 times
SBald
Posts: 2
Joined: 01 Feb 2017, 14:53

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

01 Feb 2017, 15:05

Hi everyone! Is it still possible to select the mouse I want to take input from? When I open the drop-down list in the "Input" section of the remapper plugin (mouse axis to joystick axis), I can only see "Any Mouse" and "Clear".
SBald
Posts: 2
Joined: 01 Feb 2017, 14:53

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

02 Feb 2017, 05:50

Oh, thanks! I took a look at the GitHub history and indeed I saw that this feature was lost in the refactoring process, good to hear that you will add it again!
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.9 26th Dec 2016

04 Feb 2017, 08:36

@SBald: Added as issue #156 so I do not forget.
I have not worked on UCR for a bit and the issue tracker is getting pretty full, but I plan to resume work on UCR soon, now that we are through the busy period at work.

@Keem85: I have just implemented a fix for the "vJoy menu already exists" error. Will be releasing at some point this weekend, whenever I can get someone to confirm the fix. You need to replace your copy of this file: https://github.com/evilC/UCR/blob/f4fff ... s/vGen.ahk
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.10 4th Feb 2017

04 Feb 2017, 11:12

New version released:

Code: Select all

Key:
! : Warning
* : Comment
= : Change / Fix
+ : Added feature

0.1.10 - 4th Feb 2017
= Ultrastik devices now work with UCR
  Code contributed by Snoothy - thankyou!
= If vJoy is not installed, on startup you no longer get the error
  "Error. An item with the name vJoy already exists in this menu"
eduardobedoya
Posts: 45
Joined: 05 May 2016, 14:02

Re: Universal Control Remapper (UCR) - v0.1.10 4th Feb 2017

13 Feb 2017, 12:32

Have you ever thought about including Graphic tablets stylus buttons? like wacom stylus buttons?
vank

Re: Universal Control Remapper (UCR) - v0.1.10 4th Feb 2017

15 Feb 2017, 07:31

Hi there,

I am trying to implement a kind of turbo ahk script to press several virtual xbox buttons while the LT (L2 from my physical DS4) controller is pressed. But so far no luck... I have the vxbox controller working fine, I just need to set this up now. Any ideas how I can get this done? I tried the code runner plugin but no dice...

Btw, great work with this tool, I've been searching all over for something like this, and it's the best one I've found so far :).

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 59 guests