Simulate Vive controller trackpad from WASD/joystick.
-
- One Eyed Hopeful
- Posts: 7
- Joined: Sat Jan 18, 2014 1:29 pm
Simulate Vive controller trackpad from WASD/joystick.
I'm new to freepie but am studying programming and electronics.
Here's the deal.
1) I have a Vive.
2) I have a virtual reality treadmill which can either emulate a keyboard or a joystick input.
3) Increasingly many Vive games are using a Vive trackpad to control movement.
I want to be able to emulate pressing the trackpad on my Vive controller while still using my Vive controllers for the rest of the functions.
Does anyone have an idea how this could be achieved?
Is it possible to emulate a Vive controller with a Vive controller? If so extra input data could be added prior to SteamVR seeing it which would be a big boon.
Here's the deal.
1) I have a Vive.
2) I have a virtual reality treadmill which can either emulate a keyboard or a joystick input.
3) Increasingly many Vive games are using a Vive trackpad to control movement.
I want to be able to emulate pressing the trackpad on my Vive controller while still using my Vive controllers for the rest of the functions.
Does anyone have an idea how this could be achieved?
Is it possible to emulate a Vive controller with a Vive controller? If so extra input data could be added prior to SteamVR seeing it which would be a big boon.
-
- One Eyed Hopeful
- Posts: 14
- Joined: Thu Dec 01, 2016 7:36 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
I have followed this example to emulate the Vive controllers. It works by emulating the Razer Hydra controllers and having user install the Steam VR Razer Hydra drivers. It's pretty tricky if you don't read everything carefully first (don't do what I did), but really straightforward when you wrap your head around it.
http://www.mtbs3d.com/phpbb/viewtopic.php?f=139&t=22033
Once you get it to work, try replacing the xbox inputs with equivalent the keyboard keys or joystick values. For example:
or
http://www.mtbs3d.com/phpbb/viewtopic.php?f=139&t=22033
Once you get it to work, try replacing the xbox inputs with equivalent the keyboard keys or joystick values. For example:
Code: Select all
keypress = keyboard.getPressed(Key.PageDown)
if keypress:
#do something
Code: Select all
xAxis = joystick[0].x
hydra[1].x = xAxis *1000
-
- One Eyed Hopeful
- Posts: 7
- Joined: Sat Jan 18, 2014 1:29 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
Cheers for the link!
However is it possible to use both a Razer Hydra and a Vive controller at the same time?
However is it possible to use both a Razer Hydra and a Vive controller at the same time?
- zelmon64
- Cross Eyed!
- Posts: 134
- Joined: Thu Apr 09, 2015 4:27 am
Re: Simulate Vive controller trackpad from WASD/joystick.
I is possible to use multiple types of controllers simultaneously (such as PSMove controllers and a Leap Motion) but they are all recognised as separate controllers. To do this you must have the multiple drivers setting enabled. I don't know if you will get the desired effect by using the treadmill as a third controller.NobleBrutus wrote:However is it possible to use both a Razer Hydra and a Vive controller at the same time?
-
- One Eyed Hopeful
- Posts: 1
- Joined: Sun Jun 25, 2017 11:51 am
Re: Simulate Vive controller trackpad from WASD/joystick.
I'm very interested 'cause I'm expecting my treadmill (ROVR) next week. Have you found a working solution?NobleBrutus wrote:2) I have a virtual reality treadmill which can either emulate a keyboard or a joystick input.
-
- One Eyed Hopeful
- Posts: 1
- Joined: Tue Oct 10, 2017 5:27 am
Re: Simulate Vive controller trackpad from WASD/joystick.
Hi there,
I'm currently trying to get my device working that emulates a thumbstick, and pass it into OpenVR.
Were you able to achieve this with the FreePIE API?
If so how?
Cheers!
I'm currently trying to get my device working that emulates a thumbstick, and pass it into OpenVR.
Were you able to achieve this with the FreePIE API?
If so how?
Cheers!
- zelmon64
- Cross Eyed!
- Posts: 134
- Joined: Thu Apr 09, 2015 4:27 am
Re: Simulate Vive controller trackpad from WASD/joystick.
NobleBrutus, mmorselli and AgentMilkshake1
I'm not certain but OpenVR-InputEmulator is probably the way to go.
I'm not certain but OpenVR-InputEmulator is probably the way to go.
-
- One Eyed Hopeful
- Posts: 13
- Joined: Tue Nov 07, 2017 7:48 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
I'm trying to do this also but sadly I have terrible coding skills. I have got as far as getting an xbox 360 controller to emulate a Razor Hydra with zelmon64's script. Using OpenVR-InputEmulator I've got the xbox 360 controlling the vive trackpad. The treadmill is directinput so I've tried replacing in zelmon64's script:
with
When I do this the Y axis is backwards I don't know how to fix this (Walking forward is backwards, Backwards is forwards)
Also it moves on it's own with little input. Although it does register movements sometimes also it seems to ignore input at other times. I've spent many hours now editing zelmon64's script and even attempting to write completely new scripts. I have looked at every example and tried everything I could think of but I'm just not good at this....
Basically I just need something like this but with the ability to tweak Deadzone, Sensitivity, and Axis direction.
Can anyone help me, please?
Code: Select all
xbox360[i].leftStickX
xbox360[i].leftStickY
Code: Select all
joystick[i].x
joystick[i].y
Also it moves on it's own with little input. Although it does register movements sometimes also it seems to ignore input at other times. I've spent many hours now editing zelmon64's script and even attempting to write completely new scripts. I have looked at every example and tried everything I could think of but I'm just not good at this....
Basically I just need something like this but with the ability to tweak Deadzone, Sensitivity, and Axis direction.
Code: Select all
## Start
hydra[0].start = keyboard.getKeyDown(Key.Space)
hydra[1].start = keyboard.getKeyDown(Key.Space)
## joystick
hydra[0].joyx = joystick[i].x
hydra[0].joyy = joystick[i].y
hydra[1].joyx = joystick[i].x
hydra[1].joyy = joystick[i].y
Last edited by EVOL on Wed Nov 15, 2017 4:57 am, edited 1 time in total.
- zelmon64
- Cross Eyed!
- Posts: 134
- Joined: Thu Apr 09, 2015 4:27 am
Re: Simulate Vive controller trackpad from WASD/joystick.
Hi EVOL,EVOL wrote:Basically I just need something like this but with the ability to tweak Deadzone, Sensitivity, and Axis direction.
Try this (with appropriate settings):
Code: Select all
## Start
hydra[0].start = keyboard.getKeyDown(Key.Space)
hydra[1].start = keyboard.getKeyDown(Key.Space)
## Settings
Deadzone = 0.1
Sensitivity = 1
Axis_direction_X = 1
Axis_direction_Y = -1
i = 0
## joystick
hydra[0].joyx = filters.deadband(joystick[i].x, Deadzone) * Sensitivity * Axis_direction_X
hydra[0].joyy = filters.deadband(joystick[i].y, Deadzone) * Sensitivity * Axis_direction_Y
hydra[1].joyx = filters.deadband(joystick[i].x, Deadzone) * Sensitivity * Axis_direction_X
hydra[1].joyy = filters.deadband(joystick[i].y, Deadzone) * Sensitivity * Axis_direction_Y
-
- One Eyed Hopeful
- Posts: 13
- Joined: Tue Nov 07, 2017 7:48 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
Thank you! I'm getting somewhere now I think...
Last edited by EVOL on Wed Nov 15, 2017 5:28 am, edited 3 times in total.
- zelmon64
- Cross Eyed!
- Posts: 134
- Joined: Thu Apr 09, 2015 4:27 am
Re: Simulate Vive controller trackpad from WASD/joystick.
That says remove all the indentations:EVOL wrote:Sorry, but should I be putting anything more in the script than what you provided?
I get an error with just that code
Code: Select all
## Start
hydra[0].start = keyboard.getKeyDown(Key.Space)
hydra[1].start = keyboard.getKeyDown(Key.Space)
## Settings
Deadzone = 0.1
Sensitivity = 1
Axis_direction_X = 1
Axis_direction_Y = -1
i = 0
## joystick
hydra[0].joyx = filters.deadband(joystick[i].x, Deadzone) * Sensitivity * Axis_direction_X
hydra[0].joyy = filters.deadband(joystick[i].y, Deadzone) * Sensitivity * Axis_direction_Y
hydra[1].joyx = filters.deadband(joystick[i].x, Deadzone) * Sensitivity * Axis_direction_X
hydra[1].joyy = filters.deadband(joystick[i].y, Deadzone) * Sensitivity * Axis_direction_Y
-
- One Eyed Hopeful
- Posts: 13
- Joined: Tue Nov 07, 2017 7:48 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
Yeah I figured that out right before your post... Sorry
Thank you so much I think with this I can get it working!!
Thank you so much I think with this I can get it working!!
-
- One Eyed Hopeful
- Posts: 13
- Joined: Tue Nov 07, 2017 7:48 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
This is awesome it's gonna take some fine tuning but I think it will work great. Could you possibly give me some code that would allow clicking the thumbpad button when the Y axis is a set distance from center? This would enable running at full speed.
I cant thank you enough!!!
I cant thank you enough!!!
-
- One Eyed Hopeful
- Posts: 13
- Joined: Tue Nov 07, 2017 7:48 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
How can a make this code keep tapping hydra[0].joybutton while running?
I tried adding another press with a pause between using time.sleep but got error saying time wasn't defined.
I tried adding another press with a pause between using time.sleep but got error saying time wasn't defined.
Code: Select all
def Run_Action(Running):
hydra[0].joybutton = Running
hydra[1].joybutton = Running
if (abs(joystick[i].y) > Run_Threshold):
Run_Action(True)
else:
Run_Action(False)
- zelmon64
- Cross Eyed!
- Posts: 134
- Joined: Thu Apr 09, 2015 4:27 am
Re: Simulate Vive controller trackpad from WASD/joystick.
Are you sure it needs to be tapped instead of held down? That just seems a bit odd to me.EVOL wrote:How can a make this code keep tapping hydra[0].joybutton while running?
I tried adding another press with a pause between using time.sleep but got error saying time wasn't defined.
Code: Select all
if starting:
# system.setThreadTiming(TimingTypes.HighresSystemTimer) # uncomment to use use a iteration interval less than 16 ms
# system.threadExecutionInterval = 2 # uncomment to set a non-default iteration interval
from time import sleep
def Run_Action():
hydra[0].joybutton = True
hydra[1].joybutton = True
sleep(0.1)
hydra[0].joybutton = False
hydra[1].joybutton = False
if (abs(joystick[i].y) > Run_Threshold):
Run_Action()
-
- One Eyed Hopeful
- Posts: 34
- Joined: Tue Dec 22, 2015 12:52 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
Be careful though, this'll freeze your entire script for 100ms, including all the other positional updates that are (probably) in your script. Instead, it's better to store the state and the time since the last change (or the time at the last change). This can be implemented using either system.threadExecutionInterval, or by taking the difference between the current time and some previous time, as acquired by time.time().
The time variant is probably a little more accurate, because the script won't execute at exactly the rate of system.threadExecutionInterval.
Code: Select all
if starting:
tap_time = 0
tap_state = False
# In milliseconds:
if tap_time >= 100 and abs(joystick[i].y) > Run_Threshold:
tap_time = 0
tap_state = not tap_state
hydra[1].joybutton = hydra[0].joybutton = tap_state
tap_time += system.threadExecutionInterval
Code: Select all
if starting:
import time
last_tap_time = time.time()
tap_state = False
current_time = time.time()
# In seconds:
if current_time - last_tap_time >= .1 and abs(joystick[i].y) > Run_Threshold:
last_tap_time = current_time
tap_state = not tap_state
hydra[1].joybutton = hydra[0].joybutton = tap_state
-
- One Eyed Hopeful
- Posts: 13
- Joined: Tue Nov 07, 2017 7:48 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
Thank you both! I'll give it a go tonight. Holding down the button works great in most games. However I tried out a game that uses dashes. Instead of just being held down it needs to be tapped to perform the dash multiple times.
-
- Cross Eyed!
- Posts: 197
- Joined: Mon Mar 02, 2015 3:58 pm
Re: Simulate Vive controller trackpad from WASD/joystick.
Button spamming/tapping and sequences have been discussed in this topic, have you seen it?
https://www.mtbs3d.com/phpbb/viewtopic. ... 39&t=22533
https://www.mtbs3d.com/phpbb/viewtopic. ... 39&t=22533