Hi,
I am looking to control the Z axis of a Vjoy joystick so that if I press Num 0, the axes moves down and if I press Num Enter it moves up, but incrementally.
I also dont want it to auto center.
I can make a script to make this happen, but not on an incremental basis, just either full min/max.
I need it to act that when I hold down they key, it keeps gradually increasing the value on the axes....
My script so far is:
from System import Int16
# Devices and axis initializing
max = Int16.MaxValue*0.5+0.5 # 16384
min = -Int16.MaxValue*0.5-0.5 # -16384
joystick[0].setRange(min, max)
joyZ = 0
##### Axis fallback, for easy assignment
# Joystick Axis
if keyboard.getKeyDown(Key.NumberPad0):
vJoy[0].z = min
if keyboard.getKeyDown(Key.NumberPadEnter):
vJoy[0].z = max
# vJoy
diagnostics.watch(vJoy[0].z)
Vjoy Axes Controlled by Keyboard
-
- One Eyed Hopeful
- Posts: 1
- Joined: Thu Nov 05, 2020 7:42 am
-
- Cross Eyed!
- Posts: 197
- Joined: Mon Mar 02, 2015 3:58 pm
Re: Vjoy Axes Controlled by Keyboard
Two simple ones:
This one sets one increase per press.
This one is continous, but slow. Of course, you can increase the step.
Note that at the min/max values they overshoot the value a bit, but vjoy does not seem to mind. With larger steps you might want to limit the value not to axisMax, but to the last step taken.
This one sets one increase per press.
Code: Select all
if vJoy[0].z < vJoy[0].axisMax and keyboard.getPressed(Key.NumberPad0):
vJoy[0].z = vJoy[0].z + vJoy[0].axisMax / 10
if vJoy[0].z > -vJoy[0].axisMax and keyboard.getPressed(Key.NumberPadEnter):
vJoy[0].z = vJoy[0].z - vJoy[0].axisMax / 10
diagnostics.watch(vJoy[0].z)
Code: Select all
if vJoy[0].z < vJoy[0].axisMax and keyboard.getKeyDown(Key.NumberPad0):
vJoy[0].z = vJoy[0].z + 50
if vJoy[0].z > -vJoy[0].axisMax and keyboard.getKeyDown(Key.NumberPadEnter):
vJoy[0].z = vJoy[0].z - 50
diagnostics.watch(vJoy[0].z)
-
- One Eyed Hopeful
- Posts: 1
- Joined: Sat Jan 14, 2023 1:43 pm
Re: Vjoy Axes Controlled by Keyboard
muito obrigado me ajudou muito sou brasileiro <3