The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aux/binding: Implement optional "steamvr_path" for SteamVR input bindings

When using the Monado SteamVR driver plugin together with an Oculus
Rift CV-1 and Oculus touch controllers, the grip / squeeze sensors
(e.g., /user/hand/left/input/squeeze/value) and the thumbsticks did not
work.

This because SteamVR expects those controls to be exposed under a
different path than what one would use for OpenXR, e.g.,
OpenXR /input/squeeze --> SteamVR /input/grip and
OpenXR /input/thumbstick --> SteamVR /input/joystick

The same is true for some other controller types.

To fix this, add some new code for input subpath substitution, to perform
this remapping, depending on binding type:

For type "trigger": Substitute squeeze with grip
For type "joystick": Substitute thumbstick with joystick

For rare controller types where this would be the wrong thing to do,
e.g., Valve Index (for type "joystick", needs the path to remain
"thumbstick" as before), and for special cases not covered, we add
a new optional parameter 'steamvr_path' which can be used in bindings.json
to handle such mismatches in path flexibly to allow a dedicated path
name for SteamVR, overriding the regular "OpenXR style" input path or
auto-substituted path is if the parameter is omitted.

This makes the Oculus Rift CV-1 touch controllers fully work under SteamVR.

I haven't tested this with other controllers, as I only have Oculus
controllers for testing atm. But after reading about the HTC Vive controllers,
i did add a "steamvr_path" override for /input/menu -> /input/application_menu.
Cfe. https://github.com/ValveSoftware/openvr/wiki/IVRDriverInput-Overview

Also, a minor typo fix in steamvr_profiles.py as a bonus.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>

authored by

Mario Kleiner and committed by
Christoph Haag
d3893c22 50f7b5ba

+23 -12
+2
src/xrt/auxiliary/bindings/bindings.json
··· 130 130 }, 131 131 "/input/menu": { 132 132 "type": "button", 133 + "steamvr_path": "/input/application_menu", 133 134 "localized_name": "Menu", 134 135 "components": ["click"], 135 136 "monado_bindings": { ··· 756 757 }, 757 758 "/input/thumbstick": { 758 759 "type": "joystick", 760 + "steamvr_path": "/input/thumbstick", 759 761 "localized_name": "Thumbstick", 760 762 "components": ["click", "touch", "position"], 761 763 "dpad_emulation": {
+19 -2
src/xrt/auxiliary/bindings/bindings.py
··· 19 19 return component 20 20 return None 21 21 22 + def steamvr_subpath_name(steamvr_path, subpath_type): 23 + if subpath_type == "pose": 24 + return steamvr_path.replace("/input/", "/pose/") 25 + 26 + if subpath_type == "trigger" or subpath_type == "button": 27 + return steamvr_path.replace("squeeze", "grip") 28 + 29 + if subpath_type == "joystick": 30 + return steamvr_path.replace("thumbstick", "joystick") 31 + 32 + return steamvr_path 22 33 23 34 class PathsByLengthCollector: 24 35 """Helper class to sort paths by length, useful for creating fast path ··· 119 130 if component_name in monado_bindings: 120 131 monado_binding = monado_bindings[component_name] 121 132 133 + steamvr_path = steamvr_subpath_name(identifier_json_path, json_subpath["type"]) 134 + if "steamvr_path" in json_subpath: 135 + steamvr_path = json_subpath["steamvr_path"] 136 + 122 137 c = Component(subaction_path, 123 138 identifier_json_path, 139 + steamvr_path, 124 140 json_subpath["localized_name"], 125 141 json_subpath["type"], 126 142 component_name, ··· 134 150 def __init__(self, 135 151 subaction_path, 136 152 identifier_json_path, 153 + steamvr_path, 137 154 subpath_localized_name, 138 155 subpath_type, 139 156 component_name, ··· 142 159 components_for_subpath): 143 160 self.subaction_path = subaction_path 144 161 self.identifier_json_path = identifier_json_path # note: starts with a slash 162 + self.steamvr_path = steamvr_path 145 163 self.subpath_localized_name = subpath_localized_name 146 164 self.subpath_type = subpath_type 147 165 self.component_name = component_name ··· 382 400 component: Component 383 401 for idx, component in enumerate(profile.components): 384 402 385 - json_path = component.identifier_json_path 386 - steamvr_path = json_path # @todo Doesn't handle pose yet. 403 + steamvr_path = component.steamvr_path # @todo Doesn't handle pose yet. 387 404 if component.component_name in ["click", "touch", "force", "value"]: 388 405 steamvr_path += "/" + component.component_name 389 406
+2 -10
src/xrt/auxiliary/bindings/steamvr_profiles.py
··· 33 33 f = open(fname, "w") 34 34 return f 35 35 36 - 37 - def steamvr_subpath_name(component): 38 - if component.subpath_type == "pose": 39 - return component.identifier_json_path.replace("/input/", "/pose/") 40 - 41 - return component.identifier_json_path 42 - 43 - 44 36 def get_required_components(path_type): 45 37 if path_type == "button": 46 38 return ["click", "touch"] ··· 81 73 82 74 component: Component 83 75 for idx, component in enumerate(p.components): 84 - subpath_name = steamvr_subpath_name(component) 76 + subpath_name = component.steamvr_path 85 77 86 78 input_source[subpath_name] = { 87 79 "type": component.subpath_type, ··· 100 92 "driver_name": "monado", 101 93 # "legacy_binding": None, # TODO 102 94 "input_bindingui_mode": "controller_handed", 103 - "should_show_binidng_errors": True, 95 + "should_show_binding_errors": True, 104 96 "input_bindingui_left": { 105 97 "image": "{indexcontroller}/icons/indexcontroller_left.svg" # TODO 106 98 },