Page 1 of 1

XOutput Keyboard 2 Axis

Posted: Sat Jul 15, 2017 4:37 pm
by andreaspada
Finally, I found the XOutput plugin which give me the possibility to map the keyboard to a virtual axis.

I have this script working:

Code: Select all

# Mapping keyboard to the axis 
# Left
if keyboard.getKeyDown(Key.RightControl) and keyboard.getKeyDown(Key.LeftArrow):
	xoutput[0].lx = xoutput[0].AxisMin
# Down
if keyboard.getKeyDown(Key.RightControl) and keyboard.getKeyDown(Key.DownArrow):
	xoutput[0].ly = xoutput[0].AxisMin
# Right
if keyboard.getKeyDown(Key.RightControl) and keyboard.getKeyDown(Key.RightArrow):
	xoutput[0].lx = xoutput[0].AxisMax
# Up
if keyboard.getKeyDown(Key.RightControl) and keyboard.getKeyDown(Key.UpArrow):
	xoutput[0].ly = xoutput[0].AxisMax

# Keyboard Output
vJoy[2].x = xoutput[0].lx
vJoy[2].y = xoutput[0].ly

# keyboard
diagnostics.watch(xoutput[0].lx)
diagnostics.watch(xoutput[0].ly)
diagnostics.watch(vJoy[2].x)
diagnostics.watch(vJoy[2].y)
However, it works only as toggles, or POV switches. Is it possible to tweak it to have incremental values?
I would like to use my NumericPad as a joystick, but without the spring function, something like a second mouse, which do not always return to its center.

Thanks!!!

Re: XOutput Keyboard 2 Axis

Posted: Sat Jul 15, 2017 11:49 pm
by lordsythe
Hey, I am working on a really similar problem right now myself. Trying to use keyboard presses and/or a script to emulate basic mouse movements from below API level. This looks like it might work for me but I haven't used FreePie or any of the other software/plugins you mentioned in your post. Could you explain in some additional detail how you got this working for your case?

Re: XOutput Keyboard 2 Axis

Posted: Sun Jul 16, 2017 8:42 am
by andreaspada
Well, I'm trying various solutions to find which one fits better my needs. I brand new to this, so I do not know exactly how things works.

First, of course, you need FreePIE installed, along with vJoy.

The code above use the XOutput plugin - https://github.com/dschu012/XOutputPlugin - and its pretty basic. As far as I understand, the AxisMin and AxisMax are fundamental for the axis be initialized and sees by the game.

I cannot help much more than this, right now... as soon as I have some deeper understanding, I'll provide as much details as possible!

Re: XOutput Keyboard 2 Axis

Posted: Sun Jul 16, 2017 12:19 pm
by lordsythe
Thanks. I will let you know if I make any progress myself. Hopefully some of the more experiences forum goers can lend us some insight.

Re: XOutput Keyboard 2 Axis

Posted: Wed Jul 19, 2017 12:44 pm
by andreaspada
You are welcome! Let me know about your progress... ;)

Cheers

Re: XOutput Keyboard 2 Axis

Posted: Tue Dec 12, 2017 1:51 pm
by dschu012
andreaspada wrote: I would like to use my NumericPad as a joystick, but without the spring function, something like a second mouse, which do not always return to its center.
https://github.com/dschu012/XOutputPlug ... in.cs#L276

If you set

Code: Select all

xoutput[0].ResetAxisOnExecute = false
it should not always return to the center. I haven't tested it myself (I don't have any of the tools installed on my system anymore).

Re: XOutput Keyboard 2 Axis

Posted: Tue Dec 12, 2017 8:44 pm
by Jabberwock
The thing with the plugin is that unless the values are input in each cycle, they go back to zero. The solution is quite simple: just use global variables and update the value from the variable in each cycle. For example:

def vars():
global lxvalue

if starting:
lxvalue = 0

# Mapping keyboard to the axis
# Left
if keyboard.getKeyDown(Key.RightControl) and keyboard.getKeyDown(Key.LeftArrow):
lxvalue = xoutput[0].AxisMin

xoutput[0].lx = lxvalue

EDIT: dschu012 method also works.