mouse to joystick autocentering when not moved (solved)

Official forum for open source FreePIE discussion and development.
Post Reply
Bluedeath
One Eyed Hopeful
Posts: 49
Joined: Mon Feb 10, 2014 4:48 am

mouse to joystick autocentering when not moved (solved)

Post by Bluedeath »

i created this script to use a cheap mouse under my shoes for my vr treadmill (el cheapo virtuix omni), basically it "springloads" the return to center to so it can be used to track foot movements when the foot is on the ground.

here is the script

autoCenterSpeed = 0.03

if starting:
x = 0
y = 0
z = 0
sensX = 100
sensY = 100

x += mouse.deltaX * sensX
x /= (1.0 + autoCenterSpeed)

y += mouse.deltaY * sensY
y /= (1.0 + autoCenterSpeed)

vJoy[0].x = x
vJoy[0].y = y


diagnostics.watch(vJoy[0].x)
diagnostics.watch(vJoy[0].y)

it works ok but i need to add a line that forces a recenter (x = 0 and on the line below y = 0) skipping the return when the mouse is not moved

i tried use an "if mouse.deltax == 0" to force the recenter or run the tracking part after a "if mouse.deltax != 0"

but when i try the recenter prelates the other function and the virtual joystick is centered all the time and does not move.

what am i doing wrong?

I also wopuld need to know if there is away to interface 2 pcs over TCPIP and sending the gamepad data from one to another using freepie on both.

thanks in advance.
Bluedeath
One Eyed Hopeful
Posts: 49
Joined: Mon Feb 10, 2014 4:48 am

Re: mouse to joystick autocentering when not moved (solved)

Post by Bluedeath »

in case you shoud need it here is the correct script. playng with the values in the first 3 lines allow you to tweak the sensitivity. now for my vr tread milli will hack 2 wireless mice andput the snsor under the shoes et voila feet tracking done!

autoCenterSpeed = 0.05
sensX = 100
sensY = 100
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 10

if starting:
x = 0
y = 0

if mouse.deltaX:
x += mouse.deltaX * sensX
x /= (1.0 + autoCenterSpeed)
else:
x = 0

if mouse.deltaY:
y += mouse.deltaY * sensY
y /= (1.0 + autoCenterSpeed)
else:
y = 0

vJoy[0].x = x
vJoy[0].y = y

diagnostics.watch(vJoy[0].x)
diagnostics.watch(vJoy[0].y)
Post Reply

Return to “FreePIE”