Vive controller emulation using an Xbox controller

Official forum for open source FreePIE discussion and development.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Vive controller emulation using an Xbox controller

Post by zelmon64 »

NeoToriyama asked to be able to emulate the Vive controllers with an xbox controller. Here is an initial script that takes the input from an xbox 360 controller and sends it to the Hydra to be used in SteamVR:
xbox_vive_emulation_v0.3.2.py.7z
This works fine with sixense_simple3d.exe but after the initial button pushing in SteamVR the xbox controller only acts as an xbox controller.
You do not have the required permissions to view the files attached to this post.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Thank you for all the help, it's much appreciated. I'll give it a go. I hope this is the start of better Vive-to-Xbox controller emulation. It can only improve from here on out :)
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

NeoToriyama wrote:Thank you for all the help, it's much appreciated. I'll give it a go. I hope this is the start of better Vive-to-Xbox controller emulation. It can only improve from here on out :)
I forgot to mention a setting that may need to change. On line two is "i=1". This will probably need to be changed to "i=0" for you. If you test it in sixense_simple3d.exe don't forget to copy over the fake sixence.dll to that folder as well (it's in C:\Program Files (x86)\Steam\steamapps\common\Sixense SDK\SixenseSDK\samples\win32\sixense_simple3d).
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Okay, will do.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

So, I was actually able to get the controller to show up in the CyberPong and Budget Cuts! I can move the left controller, but it's pointed away from the screen, but you can rotate it by holding LB and moving the left stick, the right controller works with the trigger, but you can't move at all. You have to move the left stick around sometimes for it to move into the scene. This is a great start!

EDIT: The left controller is inverted as well for rotation, but once you get used to it, it's much easier. I was actually able to start and play a game of Cyber-pong, although I was defeated pretty easily. If we could somehow map the right hand controller to the right stick and the rotation to the of the right controller to rb and get rid of the inverted controls for rotation on both controllers, it would be a huge step forward.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

NeoToriyama wrote:So, I was actually able to get the controller to show up in the CyberPong and Budget Cuts! I can move the left controller, but it's pointed away from the screen, but you can rotate it by holding LB and moving the left stick, the right controller works with the trigger, but you can't move at all. You have to move the left stick around sometimes for it to move into the scene. This is a great start!

EDIT: The left controller is inverted as well for rotation, but once you get used to it, it's much easier. I was actually able to start and play a game of Cyber-pong, although I was defeated pretty easily. If we could somehow map the right hand controller to the right stick and the rotation to the of the right controller to rb and get rid of the inverted controls for rotation on both controllers, it would be a huge step forward.
This one should do as you asked. For some reason I can't seem to get it to work in SteamVR (can't even launch a VR game). The right stick was previously set to act as the Vive controller touch pad but it now controls the other controller's movement.
You do not have the required permissions to view the files attached to this post.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Okay awesome thanks, I'll test it out now. That's weird though that you can't get it working. I ran the sixense test you talked about earlier and then as it was open, I launched a game from Steam, I'm not sure if that's why it worked, but I'd say you should give it a try.

EDIT: Also, are you using Vridge/Riftcat or an actual HMD?
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

I modified the script slightly, so that I could move the posz1 for both of the analog sticks while either holding LB or RB and pressing the D-pad up and down.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

I've got another question, what is the grip button mapped to?
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

It turns out that it wasn't working for me because I was being lazy and trying to use driver_null instead of VRidge (the Hydra calibration probably can't get the position of the HMD when using driver_null).

I've mapped the Hydra bumpers (Vive grips) to the triggers (fully depressed) when RB and LB are pressed. I've also mapped the Hydra sticks (Vive touchpads) to the xbox sticks when RB or LB are pressed and the corresponding triggers are partially depressed.

I added your modification so that you won't need to re-add it.

I noticed that the pitch was assigned to horizontal stick movement and the yaw to vertical movement so I swapped them to make it more intuitive (is that what you meant earlier when you said they were inverted?). Actually, just to check, what are the sizes of the fake sixense.dll files you're using? are they 27kB and 32kB? If not then we're using different versions which behave differently.
You do not have the required permissions to view the files attached to this post.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Oh okay! Well, I'm glad you got it working. I've tested a good amount of games and had some pretty funny experiences trying to play with emulated Vive controllers. The file sizes for the fake .dlls are 16kb (sixense.dll) and 18kb (sixense_x64.dll).

Okay, cool I'll test it out now and see how it performs, and yes that's what I meant by the inverted controls. I'll do some more testing to see how well the new script works.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Before testing, i got an error that says "Local variable 'posz1' referenced before assignment. Is this an error on my part?
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

NeoToriyama wrote:Before testing, i got an error that says "Local variable 'posz1' referenced before assignment. Is this an error on my part?
No, it was my bad - I added your mod without testing it. I've now moved the global definitions to the top of the function so that the problem shouldn't happen again.
You do not have the required permissions to view the files attached to this post.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

No worries, I figured it was a small error if any.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Okay, I've only tested one title, but it works now and really well I might add. A lot more streamlined this time around. You're doing amazing work.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

I've added a condition where if the A button is held down the HMD position can be moved with the left stick and d-pad up/down. Reset it with the left stick button and reset the HMD forward direction (send ctrl+shift+alt+R) with d-pad left. I "ummed-and-ahed" about adding HMD orientation control and decided to add it for completeness. It is similarly controlled by holding the B button but the roll is controlled with the d-pad left/right instead of up/down (I thought it made more sense).
You do not have the required permissions to view the files attached to this post.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Awesome, sounds good. I'll give it a go.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

It's working great man, I really appreciate all the work you put into this, it's also cool because it works with just about every game haven't had an issue yet.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Think you can help? It's the same problem many people seem to be having with IMU emulation in SteamVR. After a few minutes, the screen goes black and creates an unfortunate disappointment. The only solution was to create an environment variable to disable the 64 bit version of SteamVR. Can you make a tutorial on how to do so? I'm able to create an environment variable, but what folder/and or file do I target? Any help would be appreciated. I've asked everywhere I could think of with no response.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

NeoToriyama wrote:Think you can help? It's the same problem many people seem to be having with IMU emulation in SteamVR. After a few minutes, the screen goes black and creates an unfortunate disappointment. The only solution was to create an environment variable to disable the 64 bit version of SteamVR. Can you make a tutorial on how to do so? I'm able to create an environment variable, but what folder/and or file do I target? Any help would be appreciated. I've asked everywhere I could think of with no response.
How long does it take to go black? If you have it morrored on your monitor do both go black? I haven't been able to replicate this but only have the VRidge trial so am limited to 10 minutes. Does this only happen in games or can it happen if only SteamVR is running?

Are all your drivers for the Hydra and SteamVR up to date?

edit: I found your reddit post. Does this only happen with Leap Motion or does it also happen with the Hydra emulation? PSMoveService is now using a x64 bit version so maybe that's what's needed of the Leap Motion implementation. I don't have a Leap Motion so I can't try it out.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

It happens in random intervals and yes it happens with both Hydra emulation and Leap Motion after some time. Different games tend to go black at different times. It only happens with SteamVR games when I'm using IMU emulation. Even if I'm emulating Hydra or Leap Motion during Oculus Rift titles, the screen never goes black. Also, yes they're up to date, but the Leap Motion driver hasn't been updated for almost a month, so I'm assuming you're correct that it isn't using x64 bit version and that's causing the black screen. If I uninstall all the drivers, the SteamVR games never go black. You must be right about the 64bit implementation. As far as disabling the 64bit server, do you know how to do it?
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

NeoToriyama wrote:It happens in random intervals and yes it happens with both Hydra emulation and Leap Motion after some time. Different games tend to go black at different times. It only happens with SteamVR games when I'm using IMU emulation. Even if I'm emulating Hydra or Leap Motion during Oculus Rift titles, the screen never goes black. Also, yes they're up to date, but the Leap Motion driver hasn't been updated for almost a month, so I'm assuming you're correct that it isn't using x64 bit version and that's causing the black screen. If I uninstall all the drivers, the SteamVR games never go black. You must be right about the 64bit implementation. As far as disabling the 64bit server, do you know how to do it?
I'm not certain how to do it but HipsterSloth posted the following before he pushed the x64 version of PSMoveservice (I never tried it myself).
HipsterSloth wrote:IMPORTANT STEAM VR NOTE
SteamVR just updated today (7/5/2016) making the 64-bit vrserver the default. The problem with this is that I'm not currently building 64-bit version of the plugin yet, though I'm going to fix that soon.

In the mean time do the following gross work around:

1) Go to: C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin (Or where ever your SteamVR folder lives)
2) Rename the "win64" folder to "win64_original"
3) Duplicate the "win32" folder to "win64"

This tricks SteamVR into thinking it's running the 64-bit server
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Thank you! I'll give it a go.
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Damn, no dice. It seems as though the issue isn't SteamVR. It may be the actual Leap Motion drivers. It's weird that no one is actively working on them. Unless it's actually that difficult that it isn't worth it. I'm unsure. It seemed to fix the issue with the Hydra emulation so, it must be the Leap Motion drivers that are conflicting with SteamVR.

EDIT: It's definitely the Leap Motion drivers now, tested a few games with Hydra emulation and no black screen after multiple playthroughs.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

NeoToriyama wrote:Damn, no dice. It seems as though the issue isn't SteamVR. It may be the actual Leap Motion drivers. It's weird that no one is actively working on them. Unless it's actually that difficult that it isn't worth it. I'm unsure. It seemed to fix the issue with the Hydra emulation so, it must be the Leap Motion drivers that are conflicting with SteamVR.

EDIT: It's definitely the Leap Motion drivers now, tested a few games with Hydra emulation and no black screen after multiple playthroughs.
Just to let you know, I've been trying to build the x64 version but I keep getting errors. I ordered one of those HP keyboards with the LM built in because I found a cheap one so hopefully I'll be able to make some progress.

Are you still having problems or managed to find a way to fix it?
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Vive controller emulation using an Xbox controller

Post by konstantin_lozev »

That's an awesome idea for emulation. I was thinking of making a similar script with a similar approach, but with a standard gamepad. How did you finally tackle the problem of 2x6dof which is 12 axes vs the 4 axes available on the Xbox (and standard) controllers? I was thinking of assuming you always move the Vive/Hydra wands somewhere from your elbows, then you have only 4 dof in total to cover in most cases.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

konstantin_lozev wrote:That's an awesome idea for emulation. I was thinking of making a similar script with a similar approach, but with a standard gamepad. How did you finally tackle the problem of 2x6dof which is 12 axes vs the 4 axes available on the Xbox (and standard) controllers? I was thinking of assuming you always move the Vive/Hydra wands somewhere from your elbows, then you have only 4 dof in total to cover in most cases.
In my script the two analogue sticks default to x and y position of the Hydra controllers. When a bumper is held down the corresponding stick controls the yaw and pitch of the corresponding controller. The d-pad is set to change the roll and z position of a controller also when the corresponding bumper is held down.

It seems to work reasonably well and can easily be modified to use the generic `joystick` instead of `xbox360`. One interesting thing to note is that when in the SteamVR menu the real xbox controller input is detected as well as the emulated Vive controllers which can lead to unintentional things happening. I was going to use a DS4 controller instead to try to circumvent this behaviour but then found that the DS4 is also recognised by Steam. I can't find a way to turn off controller support in Steam (which I thought was rather ironic).
NeoToriyama
One Eyed Hopeful
Posts: 17
Joined: Wed Jun 29, 2016 4:09 am

Re: Vive controller emulation using an Xbox controller

Post by NeoToriyama »

Sorry about the late response, I actually haven't been able to fix it, although I'm assuming after research the issue is Riftcat/Vridge. Many people I know that have the actual Rift or Vive don't experience black screens. I even have a friend that has OSVR and he gets no black screens using Leap Motion. I reached out to the devs at Riftcat and they'e aware of the issue and say they will work on the issue in August as they're currently working on the GearVR version.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

I've figured why the initialisation of the emulated Hydra controllers does not always work. I had the initial and reset positions set for both controllers as (0,0,0). This meant that they were in exactly the same place which would be impossible if they are supposed to be either side of your head. Ihave now set them to have an offset of +/- 65 in the x direction (eg side by side).

To further help initialisation I have modified the behaviour of the start and back buttons. Now when the either of the bumpers are held, if either the start or back buttons are pressed the start button on both Hydra controllers will be pressed.

I have also swapped the forwards / back positional movement of the controllers because it was anoying me (sorry if anyone liked that configuration).

The default real xbox controller is also now set to use the first instead of the second (i = 0) so hopefully that will be better for most people.
You do not have the required permissions to view the files attached to this post.
egglego
One Eyed Hopeful
Posts: 2
Joined: Thu Aug 18, 2016 2:03 pm

Re: Vive controller emulation using an Xbox controller

Post by egglego »

Hi, After a lot of trial and error I have kind of got my xbox controller thinking its a Hydra thinking its a vive wand. When Steam VR starts it tells me to point my controller at the base station, i press the left trigger and then the right trigger. Steam then tells me to put the controllers to my head and press both system buttons. the green controller icons then blink and vrserver crashes.

what buttons on the 360 controller do i need to press for the hydra system buttons?

any help would be gratefully received.

thanks

Neil.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

egglego wrote:Hi, After a lot of trial and error I have kind of got my xbox controller thinking its a Hydra thinking its a vive wand. When Steam VR starts it tells me to point my controller at the base station, i press the left trigger and then the right trigger. Steam then tells me to put the controllers to my head and press both system buttons. the green controller icons then blink and vrserver crashes.

what buttons on the 360 controller do i need to press for the hydra system buttons?

any help would be gratefully received.

thanks

Neil.
Like I said in the previous post, to simultaneously press both system buttons hold one bumper and press either start or back. I don't know why it's crashing though because it shouldn't have a time limit for performing this action. Check your log files to see if there's a clue to why it crashes.
egglego
One Eyed Hopeful
Posts: 2
Joined: Thu Aug 18, 2016 2:03 pm

Re: Vive controller emulation using an Xbox controller

Post by egglego »

Thank you for your quick response, and sorry to have you repeat yourself. in case it helps anyone else, the crashing was caused by a ps move driver that i had in the steam vr drivers folder.
crookedDeebz
One Eyed Hopeful
Posts: 5
Joined: Tue Aug 30, 2016 12:07 pm

Re: Vive controller emulation using an Xbox controller

Post by crookedDeebz »

maybe I am missing something, does anyone mind helping?

- Freepie installed, script loaded and started
- hydra installed via steam
- six... installed via steam

xbox one controller, is being read by freepie and seems to follow same commands as 360 controller.

vive wands not showing as active in steam VR

- i dont have hydra or vive.

simply trying to emulate vive wands with xbone controller.

am I missing a step??

also OP, you mention system buttons and start/select buttons in referencing initialization.
what are the system buttons??

thank you and apologies for ignorance.
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

crookedDeebz wrote:maybe I am missing something, does anyone mind helping?

- Freepie installed, script loaded and started
- hydra installed via steam
- six... installed via steam

xbox one controller, is being read by freepie and seems to follow same commands as 360 controller.

vive wands not showing as active in steam VR

- i dont have hydra or vive.

simply trying to emulate vive wands with xbone controller.

am I missing a step??

also OP, you mention system buttons and start/select buttons in referencing initialization.
what are the system buttons??

thank you and apologies for ignorance.
You are forgetting to replace the sixense DLL files.

The "system" buttons are the Hydra start buttons which are mapped to the xbox back and start buttons for the left and right Hydra controllers.
crookedDeebz
One Eyed Hopeful
Posts: 5
Joined: Tue Aug 30, 2016 12:07 pm

Re: Vive controller emulation using an Xbox controller

Post by crookedDeebz »

thank you for the clarification.

it also seems the hydra wont start, program error with steam. i suppose that is normal until everything is setup, or at least normal for those without actual hydras.

hopefully not some other conflict.

will test this shortly.

thank you again


EDIT---
Did the sixsens swap, still nothing show up in steam vr as a usable controller.

Is that normal or should I see "working" controllers in the steam VR window?
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Vive controller emulation using an Xbox controller

Post by zelmon64 »

crookedDeebz wrote:thank you for the clarification.

it also seems the hydra wont start, program error with steam. i suppose that is normal until everything is setup, or at least normal for those without actual hydras.

hopefully not some other conflict.

will test this shortly.

thank you again


EDIT---
Did the sixsens swap, still nothing show up in steam vr as a usable controller.

Is that normal or should I see "working" controllers in the steam VR window?
SteamVR should believe the Hydra controllers are connected even if the FreePIE script isn't running. To check, did you replaced the DLLs in the folder Steam/steamapps/common/SteamVR Driver for Razer Hydra/hydra/bin?
crookedDeebz
One Eyed Hopeful
Posts: 5
Joined: Tue Aug 30, 2016 12:07 pm

Re: Vive controller emulation using an Xbox controller

Post by crookedDeebz »

I have not done that yet, strange I missed 2 steps here.

thank you, i will try that now.

No hydras showing up.

Ya definitely no go on the hydras showing up.

i have replaced the ddls in x64, x32 and sixsens folders accordingly.

im surprised the hydras are nto showing up at all.

any suggestions?
crookedDeebz
One Eyed Hopeful
Posts: 5
Joined: Tue Aug 30, 2016 12:07 pm

Re: Vive controller emulation using an Xbox controller

Post by crookedDeebz »

wholey shite, they were working all along.

i just never bothered to test them in a game...

however the horizontal plane is reversed, IE left = right, etc.

the left wand is missing, only see a laser beam

any suggestions?

is this mean for xbone controller? or is that the same identical as the 360?

i dont think I have a 360 controller to test.
crookedDeebz
One Eyed Hopeful
Posts: 5
Joined: Tue Aug 30, 2016 12:07 pm

Re: Vive controller emulation using an Xbox controller

Post by crookedDeebz »

wholey shite, they were working all along.

i just never bothered to test them in a game...

however the horizontal plane is reversed, IE left = right, etc.

the left wand is missing, only see a laser beam

any suggestions?

is this mean for xbone controller? or is that the same identical as the 360?

i dont think I have a 360 controller to test.
jesserichton
One Eyed Hopeful
Posts: 1
Joined: Tue Oct 18, 2016 11:44 pm

Re: Vive controller emulation using an Xbox controller

Post by jesserichton »

Hey guys. I fixed the Issue with the left goes right and right goes left probblem.
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “FreePIE”