Page 1 of 1
set Axis to middle
Posted: Tue May 12, 2020 12:08 pm
by Veteran66
Hi all
i use a SpaceMouse Pro
with SPACE i will set my Axis to 0
it will work with this scripts, but when i release the SPACE button the axes jump to the last position.
so, how i can set my vjoy Axis to middle
Code: Select all
if starting:
import time
axis_mult = (vJoy[0].axisMax / 1000)
vJoy[0].x = (joystick[3].x + 1 ) * axis_mult
vJoy[0].y = (joystick[3].y + 1 ) * axis_mult
if keyboard.getKeyDown(Key.Space):
vJoy[0].x = 0
Re: set Axis to middle
Posted: Wed May 13, 2020 5:22 am
by Jabberwock
I am not sure what you are trying to do...
With each run vJoy axes are set to joystick[3] values and then zeroed when Space is pressed. At another run they are set to joystick values again. What is supposed to happen?
Re: set Axis to middle
Posted: Wed May 13, 2020 6:13 am
by Veteran66
i use a SpaceMouse Pro, it have not a spring back like a Joystick.
so i will use a button to spring back to 0 like a Joystick
(sorry for my bad english)
Re: set Axis to middle
Posted: Wed May 13, 2020 8:24 am
by Jabberwock
That is not possible or I still do not understand the issue.
You constanly obtain the axis values from joystick[3]. Suppose that the joystick[3].x value outputs 50 and you press the button to zero the vjoy value. If the value remained that way, then what should happen if you moved the spacemouse back to the center, so the joystick[3].x is equal zero?
Re: set Axis to middle
Posted: Wed May 13, 2020 8:45 am
by Veteran66
yes I hoped there was a way to force the input value from the joystick to zero like a TrackIR imput
i have this "set zero" effect when i stop and run the Freepie script, maybe this is a way
follow script responds the Axis but the joystick does not go to zero
Code: Select all
if starting:
import time
axis_mult = (vJoy[0].axisMax / 1000)
vJoy[0].x = (joystick[3].x + 1 ) * axis_mult
vJoy[0].y = (joystick[3].y + 1 ) * axis_mult
if starting:
vJoy[0].x = 0
enabled = True
if enabled:
vJoy[0].x = joystick[3].x + 1
if keyboard.getPressed(Key.Space):
enabled = not enabled
Re: set Axis to middle
Posted: Wed May 13, 2020 11:47 am
by Jabberwock
If you want recentering like TrackIR, then you should have two global variables (they must be defined at the beginning of the script in a procedure) that would track the recentered values.
For example:
Code: Select all
def variables():
global recenterX
if starting:
recenterX = 0
if keyboard.getPressed(Key.Space):
recenterX = joystick[3].x
vJoy[0].x = joystick[3].x - recenterX
I am not sure how FreePIE/vJoy will react when you try to assign out of bound values to vJoy axes - if that is a problem, adjust the values accordingly.
Re: set Axis to middle
Posted: Wed May 13, 2020 11:52 am
by Veteran66
wauu yes this work, thx
Re: set Axis to middle
Posted: Wed May 13, 2020 12:00 pm
by Jabberwock
Glad to help!
Re: set Axis to middle
Posted: Wed May 13, 2020 12:51 pm
by Veteran66
first step solved
# 1=X (Pan Left/Right)
# 2=Y (Pan front/back)
# 3=Z (Up/Down)
# 4=RX (Nod)
# 5=RY (Lean Left/Right)
# 6=RZ (Left/Right)
if starting:
import time
axis_mult = (vJoy[0].axisMax / 3000)
vJoy[0].x = (joystick[3].x + 1 ) * axis_mult
vJoy[0].y = (joystick[3].y + 1 ) * axis_mult
vJoy[0].z = (joystick[3].z + 1 ) * axis_mult
vJoy[0].rx = (joystick[3].xRotation + 1 ) * axis_mult
vJoy[0].ry = (joystick[3].yRotation + 1 ) * axis_mult
vJoy[0].rz = (joystick[3].zRotation + 1 ) * axis_mult
# Centering
def variables():
global recenterX
global recenterY
global recenterZ
global recenterRY
global recenterRX
global recenterRZ
if starting:
recenterX = 0
recenterY = 0
recenterZ = 0
recenterRY = 0
recenterRX = 0
recenterRZ = 0
if keyboard.getPressed(Key.Space):
recenterX = joystick[3].x
recenterY = joystick[3].y
recenterZ = joystick[3].z
recenterRX = joystick[3].xRotation
recenterRY = joystick[3].yRotation
recenterRZ = joystick[3].zRotation
vJoy[0].x = joystick[3].x - recenterX
vJoy[0].y = joystick[3].y - recenterY
vJoy[0].z = joystick[3].z - recenterZ
vJoy[0].rx = joystick[3].xRotation - recenterRX
vJoy[0].ry = joystick[3].yRotation - recenterRY
vJoy[0].rz = joystick[3].zRotation - recenterRZ
next step limiter for the Axis, now the SpaceMouse Joystick run over 100% vJoy Axis
vJoy -100----------0----------+100
SpaceMouse -----------------------------0--------------------------------- have no limit
Re: set Axis to middle
Posted: Wed May 13, 2020 2:20 pm
by Jabberwock
I am afraid I do not follow...
Re: set Axis to middle
Posted: Wed May 13, 2020 10:13 pm
by Veteran66
please see screenshot
my SpaceMouse Axis do not stop on 100%
Re: set Axis to middle
Posted: Thu May 14, 2020 5:26 am
by Jabberwock
I see. Yes, you need to clip the values to the valid range.
Re: set Axis to middle
Posted: Thu May 14, 2020 10:16 am
by Veteran66
this have no effect
from System import Int16
if starting:
joystick[3].setRange(Int16.MinValue, Int16.MaxValue)
Re: set Axis to middle
Posted: Thu May 14, 2020 10:18 am
by Veteran66
my aktuell script
Code: Select all
# 1=X (Pan Left/Right)
# 2=Y (Pan front/back)
# 3=Z (Up/Down)
# 4=RX (Nod)
# 5=RY (Lean Left/Right)
# 6=RZ (Left/Right)
from System import Int16
if starting:
joystick[3].setRange(Int16.MinValue, Int16.MaxValue)
if starting:
import time
axis_mult = (vJoy[0].axisMax / 9000)
# Centering
def variables():
global recenterX
global recenterY
global recenterZ
global recenterRY
global recenterRX
global recenterRZ
if starting:
recenterX = 0
recenterY = 0
recenterZ = 0
recenterRY = 0
recenterRX = 0
recenterRZ = 0
if keyboard.getPressed(Key.Space):
recenterX = joystick[3].x
recenterY = joystick[3].y
recenterZ = joystick[3].z
recenterRX = joystick[3].xRotation
recenterRY = joystick[3].yRotation
recenterRZ = joystick[3].zRotation
vJoy[0].x = (joystick[3].x - recenterX ) * axis_mult
vJoy[0].y = (joystick[3].y - recenterY ) * axis_mult
vJoy[0].z = joystick[3].z - recenterZ
vJoy[0].rx = joystick[3].xRotation - recenterRX
vJoy[0].ry = joystick[3].yRotation - recenterRY
vJoy[0].rz = joystick[3].zRotation - recenterRZ
Re: set Axis to middle
Posted: Thu May 14, 2020 12:13 pm
by Veteran66
Jabberwock wrote: ↑Thu May 14, 2020 5:26 am
I see. Yes, you need to clip the values to the valid range.
you know how to do?
i find nothing how make
Re: set Axis to middle
Posted: Fri May 15, 2020 5:34 am
by Veteran66
setRange not work
Code: Select all
# 1=X (Pan Left/Right)
# 2=Y (Pan front/back)
# 3=Z (Up/Down)
# 4=RX (Nod)
# 5=RY (Lean Left/Right)
# 6=RZ (Left/Right)
from System import Int16
if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 5 # loop delay
joystick[4].setRange(Int16.MinValue / 2.001, Int16.MaxValue / 2.001) #Range of vJoy axis
# Centering
def variables():
global recenterX
global recenterY
global recenterZ
global recenterRY
global recenterRX
global recenterRZ
if starting:
recenterX = 0
recenterY = 0
recenterZ = 0
recenterRY = 0
recenterRX = 0
recenterRZ = 0
if keyboard.getPressed(Key.Space):
recenterX = joystick[4].x
recenterY = joystick[4].y
recenterZ = joystick[4].z
recenterRX = joystick[4].xRotation
recenterRY = joystick[4].yRotation
recenterRZ = joystick[4].zRotation
vJoy[0].x = joystick[4].x - recenterX
vJoy[0].y = joystick[4].y - recenterY
vJoy[0].z = joystick[4].z - recenterZ
vJoy[0].rx = joystick[4].xRotation - recenterRX
vJoy[0].ry = joystick[4].yRotation - recenterRY
vJoy[0].rz = joystick[4].zRotation - recenterRZ
Re: set Axis to middle
Posted: Fri May 15, 2020 1:35 pm
by Jabberwock
No, this will not work.
Suppose that you recenter at the minimal value of x. When you then move the physical controller to the middle, the recentered value for vjoy.x will be its maximum value. But physically you can move it even farther, so you will exceed the maximum value.
You would need to do something like:
Code: Select all
vJoy[0].x = max(vjoyminvalue, joystick[3].x - recenterX)
vJoy[0].x = min(vjoymaxvalue, joystick[3].x - recenterX)
(I do not remember now the min and max values for vjoy.) That way, if the recentered value is lower than the vjoy minimum, the value stays at the minimum, etc.
Re: set Axis to middle
Posted: Tue May 19, 2020 2:45 am
by Veteran66
ok thy for your answer, i will try it
Re: set Axis to middle
Posted: Mon May 25, 2020 10:07 pm
by Veteran66
thx for your support
now i find a way, i use UCR this tool have all i need for my SpacsMouse Pro
Link:
https://github.com/Snoothy/UCR
Re: set Axis to middle
Posted: Tue May 30, 2023 3:47 am
by Mashytr
Veteran66 wrote: ↑Tue May 19, 2020 2:45 am
ok thy for your answer, i will try it
Have you tried yet?