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

Post gaming related scripts
billyisms
Posts: 10
Joined: 06 Jul 2016, 19:38

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

24 Mar 2017, 12:19

Hey evilC,

I don't know if you run into anyone who uses Dragon Naturallyspeaking, but I came across a script on the AHK forums which could be useful to anyone who uses voice commands and your software.

Here is a link to the code I found:
https://autohotkey.com/boards/posting.p ... =5&p=88923
Elgin wrote:Sure:

Code: Select all

DgnEngine:= ComObjCreate("Dragon.DgnEngineControl")
DgnEngine.Register(0)
DgnEngine.RecognitionMimic("what can I say")
This code enables people to use the coderunner plugin to activate any voice commands used with Dragon Naturallyspeaking. For anyone creating custom voice commands in Dragon NaturallySpeaking, this eliminates the need to recreate any macros or code that is activated with a voice command. There is a very short delay, but this essentially turns any voice command into a keyboard shortcut or a button on a controller. The delay is much shorter than any other solution I have found.
azerty55
Posts: 13
Joined: 28 Nov 2016, 17:34
Google: eliott hasiony
GitHub: eliott

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

25 Mar 2017, 03:03

Hi
It's seem to axis on button soft plugin was broken : when i set this and I test it worked twice times perhaps three times and then it goes crazy : input doesn't work when i press it
I test fixed version and earlier version and both bug
It s a shame because this plugin manage to imitate analogic sticks
MetalRocks
Posts: 1
Joined: 25 Mar 2017, 19:46

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

25 Mar 2017, 20:33

Hi azerty55,

I think the problem with the "button to axis SOFT" plugin is easily fixed by checking whether the timer is already disabled before disabling the timer again. Try this code:

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
	
	TimerOn := false
	
	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
		}
	}
	
	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"
	}
	
	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 (this.TimerOn == true) {
			if ((fn := this.TickFn) != 0){
				try {
					SetTimer, % fn, Off
					this.TimerOn := false
					this.TickFn := 0
				}
			}
		}
	}

	; 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()
		this.TimerOn := true
		SetTimer, % fn, % this.TickRate
	}



}
I have also mixed the "axis to axis" and the "button to axis SOFT" plugins to make an "axis to axis SOFT RETURN" that only softens the movement when the axis is going back to its default position. That is, when you leave the joystick it goes back to its default position smoothly. The field "Default Position" must be filled with the position of the axis by default (Left = 0; Right = 100; Center = 50)

Code: Select all

/*
Remaps a physical joystick axis to a virtual joystick axis
Requires the StickOps library and the vJoy library
*/
class AxisToAxisSoftReturn extends _UCR.Classes.Plugin {
	Type := "Remapper (Axis To Axis - SOFT RETURN)"
	Description := "Maps an axis input to a virtual axis output"
	vAxis := 0
	vDevice := 0

	AxisState := 0
	TickAmount := 0
	TickRate := 0
	TickFn := 0
	TimerOn := false

	; Set up the GUI to allow the user to select input and output axes
	Init(){
		Gui, Add, Text, % "xm w125 Center", Input Axis
		Gui, Add, Text, % "x+5 yp w100 Center", Input Preview
		Gui, Add, Text, % "x+5 yp w40 Center", Invert
		Gui, Add, Text, % "x+5 yp w40 Center", Deadzone
		Gui, Add, Text, % "x+5 yp w40 Center", Sensitivity
		Gui, Add, Text, % "x+5 yp w30 Center", Linear
		Gui, Add, Text, % "x+10 yp w125 Center", Output Virtual Axis
		Gui, Add, Text, % "x+5 yp w100 Center", Output Preview
		
		;this.AddInputAxis("InputAxis", 0, this.MyInputChangedState.Bind(this), "xm w125")
		this.AddControl("InputAxis", "IA1", 0, this.MyInputChangedState.Bind(this), "xm w125")
		this.AddControl("AxisPreview", "", 0, this.IOControls.IA1, "x+5 yp w100", 50)
		;this.AddControl("Invert", 0, "CheckBox", "x+20 yp+3 w30")
		this.AddControl("CheckBox", "Invert", 0, "x+20 yp+3 w30")
		;this.AddControl("Deadzone", 0, "Edit", "x+10 yp-3 w30", "0")
		this.AddControl("Edit", "Deadzone", 0, "x+10 yp-3 w30", "0")
		Gui, Add, Text, % "x+0 yp+3", `%
		;this.AddControl("Sensitivity", 0, "Edit", "x+10 yp-3 w30", "100")
		this.AddControl("Edit", "Sensitivity", 0, "x+10 yp-3 w30", "100")
		Gui, Add, Text, % "x+0 yp+3", `%
		;this.AddControl("Linear", 0, "Checkbox", "x+18 yp w30")
		this.AddControl("Checkbox", "Linear", 0, "x+18 yp w30")
		;this.AddOutputAxis("OutputAxis", this.MyOutputChangedValue.Bind(this), "x+5 yp-3 w125")
		this.AddControl("OutputAxis", "OA1", this.MyOutputChangedValue.Bind(this), "x+5 yp-3 w125")
		Gui, Add, Slider, % "hwndhwnd x+0 yp", 50
		this.hSlider := hwnd
		;this.AddControl("AxisPreview", "", 0, this.IOControls.OA1, "x+5 yp w100", 50)

		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)
		Gui, Add, Text, % "Center x+20 yp w80", Default Position
		this.AddControl("Edit", "DefaultPosition", 0, "x+5 yp w50", 50)
	}
	
	; The user changed options - store stick and axis selected for fast retreival
	MyOutputChangedValue(value){
		this.vAxis := value.Binding[1]
		this.vDevice := value.DeviceID
		this.OutputBound := value.IsBound()
	}
	
	; The user moved the selected input axis. Manipulate the output axis accordingly
	MyInputChangedState(value){
		this.StopMoveTimer()
		
		;If the joystick is returning to its default position soften de movement
		if ((Abs(value - this.GuiControls.DefaultPosition.Get()) < 1) && (Abs(this.AxisState - this.GuiControls.DefaultPosition.Get()) > 1)) {
			static limits := {-1: 0, 1: 100}			
			d := this.AxisState>this.GuiControls.DefaultPosition.Get() ? -1 : 1
			fn := this.MoveTick.Bind(this, d, this.TickAmount * d, this.GuiControls.DefaultPosition.Get())
			this.TickFn := fn
			fn.Call()
			this.TimerOn := true
			SetTimer, % fn, % this.TickRate
		} else {
			;Else have the usual behaviour
			value := UCR.Libraries.StickOps.AHKToInternal(value)
			if (this.OutputBound){
				if (this.GuiControls.Deadzone.Get()){
					value := UCR.Libraries.StickOps.Deadzone(value, this.GuiControls.Deadzone.Get())
				}
				if (this.GuiControls.Sensitivity.Get()){
					if (this.GuiControls.Linear.Get())
						value *= (this.GuiControls.Sensitivity.Get() / 100)
					else
						value := UCR.Libraries.StickOps.Sensitivity(value, this.GuiControls.Sensitivity.Get())
					
				}
				if (this.GuiControls.Invert.Get()){
					value := UCR.Libraries.StickOps.Invert(value)
				}
				value := UCR.Libraries.StickOps.InternalToAHK(value)
				this.SetState(value)
			}
		}
		
	}

	OnActive(){
		this.SetState(this.GuiControls.DefaultPosition.Get())
	}
	
	DecayChanged(whichvalue, value){
		if (whichvalue == 1){
			this.TickAmount := value
		} else {
			this.TickRate := value
		}
	}	

	SetState(out){
		this.AxisState := out
		this.IOControls.OA1.Set(out)
		GuiControl, , % this.hSlider, % out
	}

	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 (this.TimerOn == true) {
			if ((fn := this.TickFn) != 0){
				try {
					SetTimer, % fn, Off
					this.TickFn := 0
					this.TimerOn := false
				}
			}
		}
	}

	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"
	}	
}
unbreakable
Posts: 6
Joined: 26 Mar 2017, 06:07

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

26 Mar 2017, 06:58

First of all thanks, it's useful piece of software!

Q: Is it possible to map scroll wheel of particular mouse as vJoy Axis? Cause now it seems that you can map only axis X and Y and there is no Z axis... Also is it posible to map buttons of particular mouse as vJoy buttons?
I want to use my third mouse scroll wheel and buttons as additional controller with 1 axis(for scroll wheel) and 3 buttons, and I don't know how to do that yet.
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

27 Mar 2017, 09:12

I have noticed that Bind Mode for InputButtons seems to be broken, although it seems fine for OutputButtons.
I am really not sure what is going on at this point, will have to investigate more.
Last edited by evilC on 27 Mar 2017, 10:06, edited 1 time in total.
Acecool
Posts: 37
Joined: 10 Jan 2016, 18:25
Facebook: Acecool
Google: Acecool
GitHub: Acecool
Contact:

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

27 Mar 2017, 10:03

I downloaded the repo off github but it errors out because of no ucr.exe; I tried compiling ucr.ahk but got errors from that UCR\*iUCRDebug.ahk cannot be opened. I'll submit a pull request - there is a missing space... Other issues too such as calls to non-existent functions... AhkThread ...

Additionally, each axis, button or whatever I add to the profile fills up the entire screen which means a huge amount of wasted space instead of being 100px high or so as in the first post in this topic the boxes are 1000px high...
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

27 Mar 2017, 10:09

I have narrowed down the problem with the InputButton Bind Mode.
Both the PCs I tested it on have vJoy installed with a POV hat that is sat at North.

When Bind Mode starts, it registers a press for the POV, but never gets released, so Bind Mode gets confused.
I have raised an issue for this, I do not see a quick and easy fix.
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

27 Mar 2017, 11:04

As some of you may have noticed, my development time on UCR has gone down, but I have been working a lot more with C# lately.
I am now starting to formulate a plan of action.

Further development of UCR in it's current form is probably going to be halted.

At the very least, I wish to use C# for the back-end input handling, using something like my InputWrapper project I have been working on.

Next goal would probably be to move the IOControls to C#, or at least the bit which builds the menu structure and handles change requests.

Ultimately, I think I would like to move the whole lot into C# (While still allowing some kind of AHK interop) but I think in the short term if I move the back end to C#, I can move a lot of the problematic stuff to C#, where it is easier to manage.
scorpio
Posts: 11
Joined: 16 Mar 2017, 22:50

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

30 Mar 2017, 22:20

Hi evilC thanks allot for coding UCR it's awesome.

I've been trying to get UCR to pick up on key presses sent by this script https://autohotkey.com/boards/viewtopic ... 10#p140010

I even converted the keys to this type of format {vk4Fsc018} but didn't fix it.

Any idea on how I could get UCR to pick up on the key presses generated by the scroll script? Or maybe the issue is in the script itself as I can't get it to work with any program. Notepad picks up the numeric input just fine though.
scorpio
Posts: 11
Joined: 16 Mar 2017, 22:50

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

31 Mar 2017, 02:42

Helgef wrote:See sendlevel.
Thanks Helgef that seems to have solved it.
azerty55
Posts: 13
Joined: 28 Nov 2016, 17:34
Google: eliott hasiony
GitHub: eliott

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

31 Mar 2017, 06:21

hi
i have a very odd problem ; when i map one button to vjoy joystick and i click on it , it press correct input and other axis but i map any axis

i use latest vjoy version (2.1.8)
Acecool
Posts: 37
Joined: 10 Jan 2016, 18:25
Facebook: Acecool
Google: Acecool
GitHub: Acecool
Contact:

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

02 Apr 2017, 20:01

Honestly I just installed AHK off the site; no clue other than 64bit... But I'll download H ( guessing it has additional dlls ? ) and see what happens.

I want to switch to AHK because having to run the FreePIE each time is annoying, not to mention I can set up classes in ahk which can simplify the logic and clean up the code... and allows me a lot of other benefits...

Edit: I'm running 1.1.24.00 - I see on the site it says 1.1 is "previously known as _L"...

Ok, I updated and then copied the ahk_h files over... It now says #SingleInstance On is an error, using #SingeInstance fixes it... Then #NoENV doesn't work anymore, had to comment that out... It is also preventing me from using:

Code: Select all

;;
;; Rebuild our Load Order...
;;
if _rebuild
{
	;; Run each command in cmd.exe with the last being run_framework_full.ahk which loads all of the framework back-end and hotkeys, etc..
	;; The downside to this method is the cmd.exe and cmdhost.exe will remain running for the duration of the script. It will close on script
	;; end, and it is possible to exit the cmd.exe but it doesn't seem easily doable to be reliable enough on all client systems.. therefore I
	;; leave it running...
	__framework_launch_commands__=
	(join&
		_assets\autoloader\__generate_base__.ahk
		_assets\autoloader\__generate_full__.ahk
	)

	;; Since generating the load order actually ends with the ahk file closing, we can use Process Close to prevent this cmd.exe from remaining open.
	RunWait, %comspec% /c %__framework_launch_commands__%,,Hide,__cmd
	Process, Close, %__cmd%
}
saying __framework_launch_commands__=

should be __framework_launch_commands__:=

but that causes an error...


Changed that to RunWait x2, then claims AutoTrim, Off is invalid... but that's important.

Claiming IfExist doesn't exist as a function.....



Why is so much removed from _H?

Guess I need to recompile it myself - luckily I still own Visual Studio 2008 aka 9 - hopefully it'll compile without too much of a headache...
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Universal Control Remapper (UCR) - v0.1.14 12th Mar 2017

03 Apr 2017, 04:34

#SingleInstance On is not valid syntax in AHK_L, let alone AHK_H
https://autohotkey.com/docs/commands/_S ... stance.htm
Off, Force and Ignore are the valid options.
Why is so much removed from _H
To my knowledge, nothing that is in AHK_L is removed in AHK_H, there is only extra stuff.

Maybe your AHK scripts are all very old AHK 1.0.x scripts? Or even AutoIt?

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 7 guests