XOutput Keyboard 2 Axis

Official forum for open source FreePIE discussion and development.
Post Reply
User avatar
andreaspada
One Eyed Hopeful
Posts: 23
Joined: Thu Jul 13, 2017 10:06 am
Location: Rio de Janeiro
Contact:

XOutput Keyboard 2 Axis

Post 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!!!
lordsythe
One Eyed Hopeful
Posts: 2
Joined: Sat Jul 15, 2017 11:44 pm

Re: XOutput Keyboard 2 Axis

Post 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?
User avatar
andreaspada
One Eyed Hopeful
Posts: 23
Joined: Thu Jul 13, 2017 10:06 am
Location: Rio de Janeiro
Contact:

Re: XOutput Keyboard 2 Axis

Post 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!
lordsythe
One Eyed Hopeful
Posts: 2
Joined: Sat Jul 15, 2017 11:44 pm

Re: XOutput Keyboard 2 Axis

Post 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.
User avatar
andreaspada
One Eyed Hopeful
Posts: 23
Joined: Thu Jul 13, 2017 10:06 am
Location: Rio de Janeiro
Contact:

Re: XOutput Keyboard 2 Axis

Post by andreaspada »

You are welcome! Let me know about your progress... ;)

Cheers
dschu012
One Eyed Hopeful
Posts: 8
Joined: Fri Nov 06, 2015 4:26 pm

Re: XOutput Keyboard 2 Axis

Post 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).
Jabberwock
Cross Eyed!
Posts: 196
Joined: Mon Mar 02, 2015 3:58 pm

Re: XOutput Keyboard 2 Axis

Post 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.
Post Reply

Return to “FreePIE”