Search Unity

XR Inputs and WMR

Discussion in 'Input System' started by KospY, Jun 7, 2018.

  1. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    Hello there!
    I'm currently working on a VR Game where I use native Unity support for VR controllers (so I don't need to create a painfull abstraction layer between SteamVR and Oculus SDK, or using third parties plugins like VRTK).

    It's working great with the native input system (https://docs.unity3d.com/Manual/OpenVRControllers.html), however haptic is not supported and I didn't find a way to make WMR device working properly on SteamVR (not sure why, some things works but some button ID/Axis are wrong, as I don't have any WMR device I'm must rely on other and it's pretty painfull to debug).

    I recently decided to try the new input system, as the XR native inputs abstraction layer seem to be stalling for age... (I'm not sure, but It's may be because the XR team are waiting this new input system?).
    Anyway some explanation on the XR input roadmap will be great to be honest... We are left in the dark here, choosing an XR input system is like doing a bet on the future right now.

    So I switched to the new input system and so far it's working great for HTC Vive and Oculus Rift. I also got haptics working so I'm pretty happy (ok haptics still doesn't work on OpenVR, but It should be coming for 2018.2.B8 at least).

    However I still got problem with WMR... Inputs are wrong, trigger registered as joystick axis, etc... Not sure why but I'm lacking information about the correct binding path for this controllers.
    I tried to use
    Code (CSharp):
    1. thumbstickLInput = new InputAction(binding: "/<WMRSpatialController>{leftHand}/joystick")
    2. triggerLInput = new InputAction(binding: "/<WMRSpatialController>{leftHand}/trigger")
    but nothing worked.

    I switched to
    Code (CSharp):
    1. thumbstickLInput = new InputAction(binding: "/<XRController>{leftHand}/joystick")
    2. triggerLInput = new InputAction(binding: "/<XRController>{leftHand}/trigger")
    It was better but trigger get recognized as thumbstick...

    I'm maybe just misunderstanding WMR (sorry don't have an headset so...), but one possible cause is different binding paths between OpenVR and native. If it's the case where can I find this paths?
    I'm more interested about the OpenVR paths, as I I'm not sure how to natively support WMR like Oculus to be honest. (I don't see any "WMR" SDK to choose in Unity)

    For information I tried to output log all bindings paths from someone how got an WMR, and here is what I got:
    Code (CSharp):
    1.  
    2. combinedtrigger | /OpenVRControllerWindowsMR0x045E0x065B01Left/combinedtrigger
    3. trackpad | /OpenVRControllerWindowsMR0x045E0x065B01Left/trackpad
    4. joystick | /OpenVRControllerWindowsMR0x045E0x065B01Left/joystick
    5. trigger | /OpenVRControllerWindowsMR0x045E0x065B01Left/trigger
    6. grip | /OpenVRControllerWindowsMR0x045E0x065B01Left/grip
    7. primary | /OpenVRControllerWindowsMR0x045E0x065B01Left/primary
    8. stickorpadpress | /OpenVRControllerWindowsMR0x045E0x065B01Left/stickorpadpress
    9. triggertouch | /OpenVRControllerWindowsMR0x045E0x065B01Left/triggertouch
    10. stickorpadtouch | /OpenVRControllerWindowsMR0x045E0x065B01Left/stickorpadtouch
    11. position | /OpenVRControllerWindowsMR0x045E0x065B01Left/position
    12. rotation | /OpenVRControllerWindowsMR0x045E0x065B01Left/rotation
    13. velocity | /OpenVRControllerWindowsMR0x045E0x065B01Left/velocity
    14. angularvelocity | /OpenVRControllerWindowsMR0x045E0x065B01Left/angularvelocity
    15. trackingstate | /OpenVRControllerWindowsMR0x045E0x065B01Left/trackingstate
    16. istracked | /OpenVRControllerWindowsMR0x045E0x065B01Left/istracked
    17. x | /OpenVRControllerWindowsMR0x045E0x065B01Left/trackpad/x
    18. y | /OpenVRControllerWindowsMR0x045E0x065B01Left/trackpad/y
    19. x | /OpenVRControllerWindowsMR0x045E0x065B01Left/joystick/x
    20. y | /OpenVRControllerWindowsMR0x045E0x065B01Left/joystick/y
    21. x | /OpenVRControllerWindowsMR0x045E0x065B01Left/position/x
    22. y | /OpenVRControllerWindowsMR0x045E0x065B01Left/position/y
    23. z | /OpenVRControllerWindowsMR0x045E0x065B01Left/position/z
    24. x | /OpenVRControllerWindowsMR0x045E0x065B01Left/rotation/x
    25. y | /OpenVRControllerWindowsMR0x045E0x065B01Left/rotation/y
    26. z | /OpenVRControllerWindowsMR0x045E0x065B01Left/rotation/z
    27. w | /OpenVRControllerWindowsMR0x045E0x065B01Left/rotation/w
    28. x | /OpenVRControllerWindowsMR0x045E0x065B01Left/velocity/x
    29. y | /OpenVRControllerWindowsMR0x045E0x065B01Left/velocity/y
    30. z | /OpenVRControllerWindowsMR0x045E0x065B01Left/velocity/z
    31. x | /OpenVRControllerWindowsMR0x045E0x065B01Left/angularvelocity/x
    32. y | /OpenVRControllerWindowsMR0x045E0x065B01Left/angularvelocity/y
    33. z | /OpenVRControllerWindowsMR0x045E0x065B01Left/angularvelocity/z
    34.  
    So "trackpad" and "joystick" are separated, that mean I can use both right?
    Not sure why there is "stickorpadpress" It's not possible to differentiate them? Maybe not supported on steamVR?
    I assumed "primary" are the menu buttons, but in fact it seem to be the touchpad press (so what is "stickorpadpress"??)

    To resume does it possible to get a list of all VR binding paths per SDK / Controllers type on the Github wiki?
     
    Last edited: Jun 8, 2018
    ROBYER1 and Alverik like this.
  2. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    Hello,
    So, I can confirm that Windows MR over OpenVR has some critical issues in 2018.2 beta. Checking locally, I don't think we send enough information for you to get the full touchpad and triggers. I'm going to look at this ASAP. A short explanation of that is that our current SteamVR implementation doesn't handle the joystick AND trackpad properly, and I'm sorry it slipped by.

    As far as XR native input vs. the new input system, they are both backed by the same systems now. So the data you get from UnityEngine.XR.Input.GetNodeStates() is the same as getting a the tracking data from a new input system connected device. This should keep them equivalent for the near term, with the exception of cases where we've run out of buttons or axes in the InputManager. However, in the longer term, we are focussing on the new input system, and I'm hoping to not add many (or any) new APIs to the Input/InputTracking static classes, unless absolutely necessary or we get unexpected delays.

    And as for Bindings paths for controllers in XR that is a good idea. We've got a few tricks with the XR controllers to make cross-platform a little easier, but if it's not documented, it's not yet readily available. I'm hoping to get to that once I clean up Windows MR over SteamVR (as well as a few other lingering issues).
     
    ROBYER1 likes this.
  3. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    Thanks for your reply! I was starting going crazy trying to find working axis/button with another user.
    Do you know if this WMR issues will be fixed before the final 2018.2 release?

    I'm really happy to know that this new input system is the focus for VR inputs in the long term. We definitely need a proper abstraction layer to manage all VR controllers, this is really something lacking right now in Unity.

    If I can push a suggestion for the new input system, I would really like if all the paths or variables are unified/combined between all PC VR controllers (HTC, Oculus, WMR). As PC VR controllers share a lot of buttons/axis this should work pretty well.
    So if I query the trigger axis it will work for all controllers, same for the grip to the exception than it will only retrieve 0/1 for the HTC Vive (not analog), if I query the thumbstick, it should retrieve the correct axis for Oculus and WMR Controller but fallback (or not) to Touchpad for HTC Vive and at last if a button only exist on one controller it will only work for this one (like the menu button on the Touch). This way we can handle game inputs a lot more easily without messing up with all the different binding paths (and even differents SDK like Oculus or OpenVR).
    It's maybe what you are talking when you said "We've got a few tricks with the XR controllers to make cross-platform a little easier", but I'm not sure so I prefer to give you my view just in case ;)
     
  4. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    Regarding WMR, I've got a few other must fixes I'm trying to get into 2018.2, but I'm really hoping.

    Your suggestion is a good one, and is part of the tricks I was alluding to.
    The XR controllers all come loaded with 'usages' which are basically just some simple context for the use of a control.
    for example, this form of pathing:
    Code (CSharp):
    1. var Accept = new InputAction(binding: "/<XRController>{leftHand}/{PrimaryButton}")
    Will grab you the Hamburger button on both Vive and WMR, the inside button on a Knuckles controller, and the A/X buttons on an Oculus Touch.
    Those squiggly brackets represent a sort of tag that we call usages, and I've tried to make sure that we can use those to map multiple devices at once, and even allow you to design relatively simple games for devices that you've never had a chance to see (e.g. if you need a stick/touchpad, trigger, and grip, you can use the usages instead of explicit controller mappings and so long as they exist on an XR controller, your game will be pick up and play).

    Those usages also relate back into specific axes in the old input system. So if in the old system you wanted to map to button indices of 6 & 7, you will be able to use {MenuButton} in the new system and be confident you are getting the same values.

    I 100% want to make sure I make a good, accurate chart of how which usages are available and how they relate to each supported device, and it's incoming, I'm just a little backlogged at the moment. If you check out Window->Input Debugger you can actually inspect them at the current moment and try experimenting with them before I get that document out though.
     
    pvloon likes this.
  5. FloHal

    FloHal

    Joined:
    Feb 25, 2013
    Posts:
    38
    Is WMR with OpenVR work well now on 2018.2.2f1 ?
    Because i want to use OpenVR (for multi headset compatibility) with my WMR headset :).
     
  6. opamped

    opamped

    Joined:
    Oct 3, 2015
    Posts:
    6
    I just upgraded to 2018.2.2f1. The input mapping (old system) still seems a little wonky for WMR. The triggers are mapping to buttons 8 and 9 for WMR (touchpad on the Vive), when they used to map to 14 and 15.

    I'd recommend waiting on the update. Between this and some other issues (I'm also getting the error documented here when the controllers turn on), WMR support was, at least in my experience, more solid in previous releases.
     
  7. FloHal

    FloHal

    Joined:
    Feb 25, 2013
    Posts:
    38
    Alright, thanks for your answer.

    By the way, i think i'll use MRTK vNext rather than OpenVR in Unity. MRTK vNext (currently in Alpha) support WMR (for MR headset) and OpenVR (for Vive and Oculus headset). This is the official Microsoft SDK for VR/AR/XR. As i said, the MRTK is currently in Alpha, but a beta version will be available within the end of August and the release version within the end of Septembre.

    https://github.com/Microsoft/MixedRealityToolkit-Unity/tree/mrtk_release
     
  8. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    A bit of topic, but could you please explain to me the correct way to get VR input using the native input system? I'd like to do the whole thing in script. But, it's kinda my first time trying to use VR input and have only used the Input class in simple ways (GetButton, GetKey, etc). Am I supposed to simply use the Input.GetButton("buttonName")? Do I have no choice other than adding Axes to the input manager manually? (I far prefer keyCodes usually...). Normally I would just try it and see but I have some problems with my PC and I won't be able to use the headset for a few weeks so I'm a bit in the dark (since I can't test... and I hate not knowing if something works).

    Anyway, sorry to bother you, but any advice would be greatly appreciated.
    and I hate not knowing if something works
     
    Last edited: Aug 19, 2018
  9. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    Hey there,
    So if you want to use axes (Touchpad, Joystick, Trigger, etc...) you will need to setup some Input Manager mappings.
    Because XR devices use so many axes and buttons, this can get pretty tedious, and so a few people I know have taken to sharing the file I've attached. Rename it to InputManager.asset and overwrite the existing file at
    .
    What it'll do is give you all the strings for the main joystick as
    and
    The manual itself has a listings for various devices, for example we have:
    OpenVR: https://docs.unity3d.com/Manual/OpenVRControllers.html
    Oculus: https://docs.unity3d.com/Manual/OculusControllers.html
    Windows MR: https://docs.unity3d.com/Manual/Windows-Mixed-Reality-Input.html

    And you can rename the existing input mappings (from the file attached) such that these can be named things like
    . But this can be a bit daunting to try to sync up multiple charts, and there is some actual method to the madness of input indices that we chose. Both controllers fit into one mapping, so that you can use the 'global joystick' or joystick 0 which is a grouping of all the other joysticks combined. This makes it so you don't need to scan the joystick list to find where the two XR controllers are.

    Otherwise, each index is designed to represent a basic feature, like a Trigger, or a Menu button, or the horizontal value of a trackpad or joystick. The basic mappings in one big chart is here: https://docs.google.com/spreadsheets/d/1XqSzYRHGAbzW9uRi_8t2Xm_zfBEJHCS2Bp3dkAYsOQc/edit?usp=sharing
    This is on it's way in a cleaner form to the manual, but should allow you to start setting up basic button and axis mapping in the old system.


    As for Windows MR over OpenVR, there were a few unusual issues, but that has finally been unblocked and is on it's way to a patch. I will report the patch number it'll be in once I know myself (Edit! 2018.2.6f1). It will be almost identical to the existing WindowsMR controller mappings, with the exception of the Joystick - Click action, which is reserved by OpenVR.
     

    Attached Files:

    Last edited: Aug 22, 2018
    scvnathan and Alverik like this.
  10. andre-ivankio

    andre-ivankio

    Joined:
    Mar 29, 2010
    Posts:
    53
    How do I enable this Input Debugger? My window menu doesn't have it. Project is set with Active Input Handling: Both, Target Platform: Windows standalone. Unity 2018.2.2f1,

    And what is the reasoning to have conventionalized this InputManager.asset with button(0-19) and axes(1-28) instead of the spreadsheet you linked? Will the spreadsheet fail in any circumstance? BTW, it's missing Daydream.
     
    ROBYER1 likes this.
  11. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    Thanks for the chart! It's definitely helpfull!
    The main buttons and axes are working (didn't tried touch usage however) but usage {Primary2DAxisClick} didn't work for both Oculus and Vive (I still need to use thumbstickclicked for Oculus and joystickorpadpressed for Vive).
    I'm using Unity 2018.2.11.

    I don't have a WMR so I can't verify if usage work yet but I can assume that {Primary2DAxisClick} will not work for this controller too (as well as {Primary2DAxisTouch}?).
    Will be nice if that can be fixed!

    Thanks!
     
    Last edited: Oct 15, 2018
  12. andre-ivankio

    andre-ivankio

    Joined:
    Mar 29, 2010
    Posts:
    53
    WMR was a bit different than the chart suggest on my test.
    It also misses many inputs: menu, touchpad axes, touchpad press, joystick press and trigger as axes.

    Unity VR Basic Index Mappings - Planilhas Google-2018-10-15 13_50_56.png
     
  13. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    668
    Could you please point me in the right direction on how you accomplished this? Did you simply add Inputs through the Unity's native input manager and it worked?
     
  14. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    I've got the same problem: I'm working with OpenVR and Unity 2017.3.1f1 but I'm missing inputs too - a lot of the information on the WMR website @StayTalm_Unity linked just doesn't work:
    E.g. you should be able to access presses of the left analog stick with keycode 8 but even a keycode finder doesn't find anything for that one - it does open the SteamVR settings, so the controllers are definitely working, you just can't access the button. Same with with the grip button, it doesn't react to any keycode (and also doesn't do anything).
    A bunch of the others are also mixed up: E.g. pressing the left touchpad triggers keycode 8, even though it's 16 according to the website, while touching the left touchpad answers to 16.
    My Xbox One controller that usually works perfectly fine doesn't work at all if OpenVR is enabled.

    How do I fix this?
     
  15. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    Update: The Xbox One controller works but there has to be an extra icon for it in Steam VR, otherwise it won't!
    The controls are the same (e.g. button 0 for "A") and the buttons are recognized as either "JoystickButton0" or "Joystick1Button0".
     
  16. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    @SimRuJ I've been fixing issues only up to the current version 2018.3. WMR via OpenVR should work in 2018.3.1 with the only exception being that the controllers are not reporting their velocity. That's being fixed in an incoming change to ISX. In 2018.3, when using WMR over OpenVR, we cannot get the Joystick click button, it's reserved by the OS and never sent to us. The Grip however is mapped as button's 4 & 5.

    @KospY You opened a bug with those two, and it was my mistake. The document was using the preset tense of {Primary2DAxisClick} and {Primary2DAxisTouch}, but the devices themselves were sending {Primary2DAxisClicked} and {Primary2DAxisTouched} in past tense. I updated the doc.
     
    ROBYER1 likes this.
  17. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    @StayTalm_Unity Oh, so I can't get it to work with 2017.3., is that what you mean? Unfortunately I currently don't have the time to upgrade to 2018.3.1. and then deal with the changes/new issues there.
    The VR controllers are basically (thank Microsoft...) an Xbox One controller in terms of input and I got mine to work (including the LB/RB which react to button 4 and 5). I tested every button with two different keycode finders and the grips don't output anything and also doesn't react to 4 or 5.
    Microsoft have their own documentation here (they also suggest axis 11 and 12 for the grips - haven't tested that yet) and there's even a note saying that certain keycodes differ in Unity because of OpenVR but that note is missing in the Unity documentation.
    I noticed they open some Steam settings window - that's a pity!

    Edit: I just tested axis 11 and 12 for the grips: They didn't work either.
     
    Last edited: Jan 16, 2019
    ROBYER1 likes this.
  18. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Downloading 2018.3.3f1 now to see if this is the case, beginning a project in VR soon and wondering whether to work with the native XR support in Unity or work with VRTK to support cross platform SDKs
     
  19. SimRuJ

    SimRuJ

    Joined:
    Apr 7, 2016
    Posts:
    247
    If you decide to use native XR support, could you please try using only the basic "Edit - Project Settings - Input" input manager without importing the SteamVR plugin (that adds e.g. models for the VR controllers) first. It would be interesting to see if you get the same result as I do then (but with the newer version).
     
  20. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Unfortunately won't have the VR equipment at hand to test this anytime soon, am eager to check out the native XR support for a new project next month when I have the equipment - the current input manager has these options currently in a project made brand new that just was using the LWRP VR template and importing the VRTK SDK into the assets folder.
    upload_2019-1-30_10-6-32.png