KozGit / DOOM-3-BFG-VR

Doom 3 BFG VR: Fully Possessed. Doom 3 BFG with native Oculus Rift/Touch or OpenVR support
GNU General Public License v3.0
370 stars 52 forks source link

Windows Mixed Reality support #245

Open Violins77 opened 6 years ago

Violins77 commented 6 years ago

Greetings, I was able to run the game with Windows Mixed Reality using the WMR SteamVR driver, and it works well as far as the code goes.

However, the analog sticks from the motion controller don't look like they can be bound. Using the touchpad, it kind of work for sweet locomotion, but it is imprecise. I think just to reconize the Mixed Reality controller as an Occulus touch would probably do the trick, but allow remapping using the analog stick would be even better! It is definitely possible in SteamVR as the SteamVR home, SPT and other use the analog stick natively (and they show 'Windows Mixed Reality compatible on the Steam page.

Anyways, I'll help anyway I can, I'm sure it is possible to do, and I'm not so bad at programming so I could probably take a look at it if I'm pointed toward the right direction. I've never developed for VR, but I'm sure I can at least contribute!

Thank you

Violins77 commented 6 years ago

Also, I tried to enable the vr_moveClick 1 INTEGER command but the WMR controler does not work with click command. I'm sure there is a way to use analog sticks as some devs did it for their games. Might need to look at the dev forums. Also, I do hope Microsoft patches the analog stick emulation as soon as possible.

Violins77 commented 6 years ago

I am dying to play this game :) Can anyone help? I'd be glad to do my due diligence to code and test if I can just be pointed in the right direction 👍

CarlKenner commented 6 years ago

It's mentioned here: https://www.reddit.com/r/WindowsMR/comments/7kxw19/how_to_use_windows_mixed_reality_analog_sticks_in/

Violins77 commented 6 years ago

Thanks a lot for your answer! I am well aware that you can "emulate" the touchpad with the analog stick, but that solution is far far from perfect or ideal. Since Doom 3 BFG Fully Possessed is open source, I can most likely do a better job and implement native support for analog sticks. Again, I would just need some pointer to get me started.

KozGit commented 6 years ago

Hey Carl, good to see you back!

Violins77: I don't have a MR headset to test with, but I would imagine that the thumbsticks are reported as additional axes by SteamVR. It shouldn't be too hard to add this functionality, but there are some other things I want to finish before revisiting the input system.

I did see this article about enabling thumstick turning in any steamVR app, not sure if it would help: ( see the section Enabling controller thumbstick turning in any SteamVR application )

https://docs.microsoft.com/en-us/windows/mixed-reality/enthusiast-guide/using-steamvr-with-windows-mixed-reality

Violins77 commented 6 years ago

Thanks for responding. Well I can gladly take a look if you want me to. I can find my way through the files and probably work something out for the controls if I am allowed to. This project is open source right? All github is?

Although I agree it would be even better if Microsoft allowed driver level emulation of track pad directly to analog sticks.

KozGit commented 6 years ago

Absolutely the project is open source - feel free to take a look.

Again, I haven't looked at all at how SteamVr is reporting the states for the MR controllers, but if you want to try compiling, try this:

Search in the file win_input.cpp for

axisType == vr::k_eControllerAxis_TrackPad

You should find two instances ( one for left controller and one for right ) in PollInputeEvents

Try changing these to

axisType == vr::k_eControllerAxis_Joystick

Hopefully this will read the values of the sticks instead of the pads. You may need to change the scaling as well - the pads return values between -1 and 1, the sticks may return different ranges.

You can add a debug print to check - after the lines

padX = currentStateL.rAxis[padAxis[0]].x; padY = currentStateL.rAxis[padAxis[0]].y;

add

common->Printf( "Stick x %f Stick y %f\n", padX, Pady );

This will output the raw values for the stick positions (if they are working) to the debugger. If the values only range from -1 to 1 when moving a stick you're good. If not, you will need to scale them to range between -32767 and 32767. You can see where this is currently done farther down in PollInputEvents, just change the scale value to whatever is appropriate.

If this works, the pad should no longer work, and the stick should work instead. It will also let me know what I need to do to add another set of axes so both the pad and the stick can work at the same time ( and even be bound to different actions if you want )

Let me know what happens!

Violins77 commented 6 years ago

Awesome!!! Thanks a lot!! I need to set my gaming machine with VS2013 as I usually use my work machine for this, but I will do as soon as possible! Hope this might help other Mixed Reality users.

KozGit commented 6 years ago

I hope it works too! I just took a look at the comments in OpenVR.h, and it looks like the sticks are supposed to range from -1.0 to 1.0 just like the pads, so it doesn't look like you will need to change the scaling - just the axisType check. Now I'm nervous though, nothings ever this easy :)

Violins77 commented 6 years ago

Well, I feel a little bad for asking this, but since I need to setup everything on my workstation to do this change, would you mind compiling the version with this slight change in a separate branch in the meantime? If it only takes two minutes for you to compile the file, it would save me quite a lot of time! But if it doesn't work, I'll definitely do the needful and debug on my end in the goal of helping the project.

Violins77 commented 6 years ago

Ok I have time tonight afterall! Will keep you posted!

Violins77 commented 6 years ago

Ok, I have tried my best in the last 3 hours, but I can't get it to build properly. I will need to troubleshoot my config and start from scratch later. I think some of my path are not set up properly or something in the readme is not up to date. I will keep you posted. Let me know if you have time to compile it in the meantime, I have the gear to test it!