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

Add an optional switch -s or --steamvr to steamvr_profiles.py, which enables
a different naming scheme for the "controller_type" field in the generated
SteamVR profile json files.

If the switch is provided and an interaction profile in bindings.json
provides the optional new property "steamvr_controllertype", that property
will be used for the "controller_type" field of the written out .json,
instead of the regular auto-generated name.

This allows to generate json files which use controller_type names normally
used by SteamVR, so Monado provided controllers are mapped to the same
OpenXR interaction profiles that SteamVR would normally map them to.
E.g., the standard controller_type for Oculus touch controllers used by
SteamVR is "oculus_touch" instead of Monado's "monado_oculus_touch_controller".

That in turn allows OpenXR clients to use the SteamVR/OpenXR runtime to
access controllers provided by Monado's SteamVR driver plugin. Without such
compatible json files, only standard OpenVR clients can use controllers
exposed by Monado's SteamVR driver by default, but not OpenXR clients.

Tested with an Oculus Rift CV-1, and shown to now enable OpenXR clients
to make full use of the Oculus touch controllers.

The mappings for controllers other than Oculus Touch are derived from
SteamVR log output, but not actually tested due to lack of suitable hw.

Per discussion for the merge request, we enable this '-s' flag by
default in the make file for SteamVR style naming scheme.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
This commit is contained in:
Mario Kleiner 2023-01-17 05:11:49 +01:00 committed by Christoph Haag
parent d3893c229f
commit 887b770f9e
4 changed files with 20 additions and 2 deletions

View file

@ -3,6 +3,7 @@
"/interaction_profiles/khr/simple_controller": {
"title": "Khronos Simple Controller",
"type": "tracked_controller",
"steamvr_controllertype": "khr_simple_controller",
"monado_device": "XRT_DEVICE_SIMPLE_CONTROLLER",
"subaction_paths": [
"/user/hand/left",
@ -106,6 +107,7 @@
"/interaction_profiles/htc/vive_controller": {
"title": "HTC Vive Controller",
"type": "tracked_controller",
"steamvr_controllertype": "vive_controller",
"monado_device": "XRT_DEVICE_VIVE_WAND",
"subaction_paths": [
"/user/hand/left",
@ -191,6 +193,7 @@
"/interaction_profiles/htc/vive_pro": {
"title": "HTC Vive Pro",
"type": "tracked_hmd",
"steamvr_controllertype": "vive_pro",
"monado_device": "XRT_DEVICE_VIVE_PRO",
"subaction_paths": [
"/user/head"
@ -234,6 +237,7 @@
"/interaction_profiles/microsoft/motion_controller": {
"title": "Microsoft Mixed Reality Motion Controller",
"type": "tracked_controller",
"steamvr_controllertype": "holographic_controller",
"monado_device": "XRT_DEVICE_WMR_CONTROLLER",
"subaction_paths": [
"/user/hand/left",
@ -322,6 +326,7 @@
"/interaction_profiles/microsoft/xbox_controller": {
"title": "Microsoft Xbox Controller",
"type": "untracked_controller",
"steamvr_controllertype": "gamepad",
"monado_device": "XRT_DEVICE_XBOX_CONTROLLER",
"subaction_paths": [
"/user/gamepad"
@ -570,6 +575,7 @@
"/interaction_profiles/oculus/touch_controller": {
"title": "Oculus Touch Controller",
"type": "tracked_controller",
"steamvr_controllertype": "oculus_touch",
"monado_device": "XRT_DEVICE_TOUCH_CONTROLLER",
"subaction_paths": [
"/user/hand/left",
@ -703,6 +709,7 @@
"/interaction_profiles/valve/index_controller": {
"title": "Valve Index Controller",
"type": "tracked_controller",
"steamvr_controllertype": "knuckles",
"monado_device": "XRT_DEVICE_INDEX_CONTROLLER",
"subaction_paths": [
"/user/hand/left",

View file

@ -273,6 +273,10 @@ class Profile:
self.validation_func_name = profile_name.replace("/interaction_profiles/", "").replace("/", "_")
self.identifiers = Identifer.parse_identifiers(json_profile)
self.steamvr_controller_type = None
if "steamvr_controllertype" in json_profile:
self.steamvr_controller_type = json_profile["steamvr_controllertype"]
self.components = []
for identifier in self.identifiers:
for component in identifier.components:

View file

@ -54,6 +54,9 @@ def main():
'bindings', help='Bindings file to use')
parser.add_argument(
'output', type=str, help='Output directory')
parser.add_argument(
'-s', '--steamvr', action='store_true',
help='Use SteamVR standard controller type names')
args = parser.parse_args()
bindings = Bindings.load_and_parse(args.bindings)
@ -69,6 +72,10 @@ def main():
profile_type, vendor_name, fname = names(p)
controller_type = "monado_" + vendor_name + "_" + profile_type
if args.steamvr == True and p.steamvr_controller_type is not None:
controller_type = p.steamvr_controller_type
input_source = {}
component: Component
@ -86,7 +93,7 @@ def main():
j = {
"json_id": "input_profile",
"controller_type": "monado_" + vendor_name + "_" + profile_type,
"controller_type": controller_type,
"device_class": device_class,
"resource_root": "steamvr-monado",
"driver_name": "monado",

View file

@ -9,7 +9,7 @@ add_custom_command(
OUTPUT "${INPUT_PROFILES_OUTPUT_DIR}"
COMMAND
${PYTHON_EXECUTABLE} ${INPUT_PROFILES_INPUT_DIR}/steamvr_profiles.py
${INPUT_PROFILES_INPUT_DIR}/bindings.json "${INPUT_PROFILES_OUTPUT_DIR}"
${INPUT_PROFILES_INPUT_DIR}/bindings.json "${INPUT_PROFILES_OUTPUT_DIR}" "-s"
DEPENDS ${INPUT_PROFILES_INPUT_DIR}/bindings.py ${INPUT_PROFILES_INPUT_DIR}/bindings.json
COMMENT "Generating SteamVR input profiles to ${INPUT_PROFILES_OUTPUT_DIR}"
)