Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

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

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 14:15

Ah, that's a lot more digestible, thank you.

Right, something has just dawned on me...

In order to control a vjoy stick, you have to "acquire" it first. This locks out other apps from grabbing that vjoy stick. When you are done with it, you "relinquish" it, and other apps can acquire it.

UCR can currently only acquire one vJoy stick at a time

So UCR is doing this:
acquire stick 1, send position to stick 1, relinquish stick 1, acquire stick 2, send position to 2, relinquish stick 2, repeat

I will look into the feasibility of enabling multi-vjoy support, but in order to do it "properly", it would need a fair amount of work I think.
Basically, every time you are switching profile or delete a plugin, it needs to check which sticks still have mappings and relinquish all vjoy sticks that do not have mappings in an active profile.
I could probably bodge something together though for the short term. If it never relinquished sticks, it would just mean that if you wanted to use a vjoy stick with another app, you would have to quit and restart UCR to relinquish the stick.
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 14:25

LOL yeah, adding multi-vjoy support is a one-line bodge :)

Edit Libraries\vjoy\vjoy.ahk, replace contents with:

Code: Select all

#include Libraries\vjoy\CvJoyInterface.ahk

class vJoy extends CvJoyInterface {
	_UCR_LoadLibrary(){
		if (this.vJoyEnabled()){
			this.SingleStickMode := 0	; <---- This is the new line
			return 1
		} else {
			return this.LoadLibraryLog
		}
	}
}
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 14:30

Ah, that answers the issue with using more than one vJoy (which was something I tried as a work-around btw). But what about using only one vJoy but merge to different axis?

Here is a quick'n'dirty gif of my issue (sorry about the low quality):

Image
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 14:36

The two inputs are the G27 pedals yeah? Will have to try when i'm at home at the weekend as i don't have my wheel here - because as you saw from my recording I canot reproduce with this gamepad. The only difference I see is that you have invert on for input 2 - I tried that and it was still analogue. Try disabling invert - does the issue still exhibit? Can you try with other sticks? Do you have a gamepad?

[Edit] I notice that the slider in UCR is showing analogue output, but vJoy monitor is not. I re-tested my end and vjoy monitor is showing exactly what UCR is, so no repro still :(
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 14:45

Awesome! That basically solved it, no more flickering :)

There's still the issue with vJoy 1 being "digital" on subsequent axis, but now I can just use vJoy 2 for the rest. I've only briefly tried it just now, but it seems to work.

Thanks for looking into the problem!
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 14:52

evilC wrote:The two inputs are the G27 pedals yeah? Will have to try when i'm at home at the weekend as i don't have my wheel here - because as you saw from my recording I canot reproduce with this gamepad. The only difference I see is that you have invert on for input 2 - I tried that and it was still analogue. Try disabling invert - does the issue still exhibit? Can you try with other sticks? Do you have a gamepad?

[Edit] I notice that the slider in UCR is showing analogue output, but vJoy monitor is not. I re-tested my end and vjoy monitor is showing exactly what UCR is, so no repro still :(
Yes, its input is from the G27 pedals. So, on your end it works as it should, puzzling! The only thing I did was to switch axis, and it's "digital" on all other axis but 1, on the first vJoy.
I have a generic logitech gamepad I can try, plus throttle/joystick, will get back to it to see if there is a difference.

Disabling invert did nothing (except disabling invert), it was still "digital" on the other axis.
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 16:52

Well, I suppose I could do that if that would help, and if you want. A bit depending on what you will be doing with it :) I don't have TeamViewer or anything similar atm, so I'll have to install it first, and we have to find a time I guess.
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 17:03

I would be debugging what is going on with the discrepancy.
So ideally I would probably want to download DebugView from MS TechNet and Scite4Autohotkey Editor if you do not have it and poke around in the internals of UCR while it is running to try and work out what is going on and/or writing test scripts to try and repro the issue in the least possible code.
I dunno though, something says to me it maybe isnt UCR. If the sliders are behaving OK, but vjoy is just "acting digital" after the switch of axis, it could potentially even be vjoy.
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 17:07

Ok. I have no problems with that (I don't have those programs).

Yes, the UCR sliders behave normal (analog), so maybe it isn't UCR.
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

09 Jun 2016, 17:53

Just FYI, I've now tested the gamepad I have (a Logitech dual action USB), as well as the HOTAS throttle (2 axis) and joystick, merging 2 axis to a virtual joystick axis. I tried all 8 sliders but only on two virtual joysticks.

On vJoy #1, only the first virtual axis (X) works normally (analog), the others are either full on or off (I'm sure I've observed 50% earlier, but not now, not sure whats up with that).
On vJoy #2 all axis work great. Supposedly also on subsequent vJoys (famous last words or something. I didn't try more than 2 atm).
I didn't try all combinations of the invert settings, just a few, but it doesn't seem to have any effect on the axis analog/digital output.

EDIT: Make that three virtual joysticks. vJoy #3 also works normal on all axis, merging two axis from my controllers (gamepad, throttle, joystick, G27 pedals).
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

10 Jun 2016, 07:18

This is damned odd.
OK, so it is probably best that we try to reproduce this issue with simpler code.

This code uses basically the same vjoy interface as UCR, but in a stand-alone script.

Download this file: https://raw.githubusercontent.com/evilC ... erface.ahk

Then run this script (Put it in same folder as the above library script):
Edit the ; Configure these variables to tweak input and output axes section to set up input and output devices and axes
It should remap one axis to vJoy

Code: Select all

#SingleInstance, force
#include "CvJoyInterface.ahk"
#persistent
 
; Configure these variables to tweak input and output axes
vJoyDevice := 1		; The VJOY id of the device to acquire
vJoyAxis := 1		; Axis number of the vjoy stick to control
InputDevice := 2		; Joystick ID of the input stick (Find with PJP JoyIDs if unsure)
InputAxis := 1		; Axis number of the input stick

; ===================
AHKAxisList := ["X","Y","Z","R","U","V"]
 
; Create an object from vJoy Interface Class.
vJoyInterface := new CvJoyInterface()
 
; Was vJoy installed and the DLL Loaded?
if (!vJoyInterface.vJoyEnabled()){
	; Show log of what happened
	Msgbox % vJoyInterface.LoadLibraryLog
	ExitApp
}
 
myStick := vJoyInterface.Devices[vJoyDevice]
 
AxisStr := InputDevice "Joy" AHKAxisList[InputAxis]
Loop {
	ax := GetKeyState(AxisStr)
	ax *= 327.68
	myStick.SetAxisByIndex(ax,vJoyAxis)
	Sleep 10
}
[Edit] Tested, fixed, now works.
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

10 Jun 2016, 14:18

OK, I updated the code above, and it now works.

So let me get this straight. This digital axis thing happens when you use vJoy stick 1, regardless?
Does it only happen when you change the axis setting, or does it also happen if you load up UCR with it already set to that stick?
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

10 Jun 2016, 16:37

Yes, the digital axis seems only to happen with vJoy stick 1, except on its first axis (X).
Did a quick test just now, had to remove the quotation marks (") in the include line, otherwise it couldn't load the include file for some reason. But then I get this error:

Image
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

10 Jun 2016, 21:15

Ugh, I must be blind or something, downloaded your CvJoyInterface.ahk now and ran the test script. In addition, I hadn't updated AutoHotKey in a while, but I've done that now. With THAT CvJoyInterface.ahk, it worked, but just as before; my vJoy #1 axis one is analog, but the rest on vJoy #1 is digital. On vJoy #2 they all work.

EDIT: Still needed to remove those quotation marks on the #include "CvJoyInterface.ahk" line btw.
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

11 Jun 2016, 13:44

OK, so if the problem happens with CvJoyInterface, then at least we can reproduce this outside of UCR.

Have you tried the demo feeder that comes with vJoy? Does it exhibit the digital behavior?
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

11 Jun 2016, 14:22

I actually haven't tried it, until now. And yes, the digital behavior is still present on vJoy #1, all axis except the first. If I hit 50% exactly on the feeder they are at the midpoint, or else they are fully off or on (0%, 50%, 100%). On vJoy #2 they work as expected. I presume also on vJoy #3 etc (not tested atm).
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

11 Jun 2016, 14:48

This has something to do with my windows install, and nothing with your code as you say, nor vJoy.

As it happens, I have another partition with windows, but I don't use it much. It's the same (Windows 7) on the same PC, but not as much installed stuff. So I got the idea to test vJoy there.. I already had vJoy 2.05 installed (forgot about it), and using the feeder application and monitoring vJoy, vJoy #1 worked on all axis! As did vJoy 2,3 and 4 (didn't try more). Updated to latest vJoy, and it still worked.

So I'm not sure why it doesn't work in my regular windows. My current work-around is just using vJoy #2 and not vJoy #1, which works great after your multi-vJoy fix earlier :)

EDIT: So, yeah, thanks for the help and sorry about this mess!
EDIT2: Grammar fix.
Dayanto

Re: Universal Joystick Remapper (UJR) - v6.10 2nd Nov 2015

15 Jun 2016, 10:24

I have a game uses a lot of bindings. To be able to use everything, I would need one axis more than my controller actually has. What I would like to do is to redirect the output from one of the thumbsticks to an additional virtual axis whenever a certain button is held down, to give it a dual functionality. Is this something that would be possible to do with this program?

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 20 guests