From ab2e89affd82eb2a95f41bdd6b691381ffd1ebb3 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Tue, 12 Mar 2024 23:12:21 +0100 Subject: [PATCH] a/bindings,xrt: Add FB_touch_controller_proximity Adding virtual profiles is a bit of a hack that we may want to unify in the future. It also adds some redundant verification for paths like "/user/hand/left/input/trigger" Part-of: --- CMakeLists.txt | 3 + scripts/generate_oxr_ext_support.py | 1 + src/xrt/auxiliary/bindings/bindings.json | 66 ++++++++++++++++++- src/xrt/auxiliary/bindings/bindings.py | 2 +- .../include/xrt/xrt_config_build.h.cmake_in | 1 + src/xrt/include/xrt/xrt_defines.h | 2 + .../oxr/oxr_extension_support.h | 13 ++++ 7 files changed, 86 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2710dd849..cd3a81256 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -413,6 +413,9 @@ endif() if(NOT DEFINED XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3) set(XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3 ON) endif() +if(NOT DEFINED XRT_FEATURE_OPENXR_INTERACTION_FB_PROXIMITY) + set(XRT_FEATURE_OPENXR_INTERACTION_FB_PROXIMITY ON) +endif() # Defaults for OpenXR layer support if(NOT DEFINED XRT_FEATURE_OPENXR_LAYER_DEPTH) diff --git a/scripts/generate_oxr_ext_support.py b/scripts/generate_oxr_ext_support.py index 31d0ad22f..711a76b88 100755 --- a/scripts/generate_oxr_ext_support.py +++ b/scripts/generate_oxr_ext_support.py @@ -74,6 +74,7 @@ EXTENSIONS = ( ['XR_FB_composition_layer_depth_test', 'XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST'], ['XR_FB_display_refresh_rate', 'XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE'], ['XR_FB_passthrough', 'XRT_FEATURE_OPENXR_LAYER_PASSTHROUGH'], + ['XR_FB_touch_controller_proximity', 'XRT_FEATURE_OPENXR_INTERACTION_FB_PROXIMITY'], ['XR_HTC_facial_tracking', 'XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC'], ['XR_ML_ml2_controller_interaction', 'XRT_FEATURE_OPENXR_INTERACTION_ML2'], ['XR_MND_headless', 'XRT_FEATURE_OPENXR_HEADLESS'], diff --git a/src/xrt/auxiliary/bindings/bindings.json b/src/xrt/auxiliary/bindings/bindings.json index 97e663cda..8d8c5e080 100644 --- a/src/xrt/auxiliary/bindings/bindings.json +++ b/src/xrt/auxiliary/bindings/bindings.json @@ -141,6 +141,70 @@ } }, + "/virtual_profiles/oculus/touch_controller_proximity_fb": { + "title": "Oculus Touch Controller Proximity Extension", + "type": "tracked_controller", + "monado_device": "XRT_DEVICE_TOUCH_CONTROLLER", + "extension": "FB_touch_controller_proximity", + "subaction_paths": [ + "/user/hand/left", + "/user/hand/right" + ], + "subpaths": { + "/input/trigger": { + "type": "button", + "localized_name": "Trigger", + "components": ["proximity_fb"], + "monado_bindings": { + "proximity_fb": "XRT_INPUT_TOUCH_TRIGGER_PROXIMITY" + } + }, + "/input/thumb_fb": { + "type": "button", + "localized_name": "Thumb", + "components": ["proximity_fb"], + "monado_bindings": { + "proximity_fb": "XRT_INPUT_TOUCH_THUMB_PROXIMITY" + } + } + } + }, + + "/virtual_profiles/oculus/touch_controller_proximity_1_1": { + "title": "Oculus Touch Controller Proximity OpenXR 1.1", + "type": "tracked_controller", + "monado_device": "XRT_DEVICE_TOUCH_CONTROLLER", + "openxr_version": { + "promoted": { + "major": "1", + "minor": "1" + } + }, + "subaction_paths": [ + "/user/hand/left", + "/user/hand/right" + ], + "subpaths": { + "/input/trigger": { + "type": "button", + "localized_name": "Trigger", + "components": ["proximity"], + "monado_bindings": { + "proximity": "XRT_INPUT_TOUCH_TRIGGER_PROXIMITY" + } + }, + "/input/thumb_resting_surfaces": { + "type": "button", + "localized_name": "Thumb", + "components": ["proximity"], + "monado_bindings": { + "proximity": "XRT_INPUT_TOUCH_THUMB_PROXIMITY" + } + } + } + }, + + "/interaction_profiles/ext/hand_interaction_ext": { "title": "Ext Hand Interaction", "type": "tracked_controller", @@ -786,7 +850,7 @@ "type": "tracked_controller", "steamvr_controllertype": "oculus_touch", "monado_device": "XRT_DEVICE_TOUCH_CONTROLLER", - "extended_by": ["ext/palm_pose", "grip_surface", "ext/hand_interaction_poses"], + "extended_by": ["ext/palm_pose", "grip_surface", "ext/hand_interaction_poses", "oculus/touch_controller_proximity_fb", "oculus/touch_controller_proximity_1_1"], "subaction_paths": [ "/user/hand/left", "/user/hand/right" diff --git a/src/xrt/auxiliary/bindings/bindings.py b/src/xrt/auxiliary/bindings/bindings.py index f0d6c6473..cb82c8c9c 100755 --- a/src/xrt/auxiliary/bindings/bindings.py +++ b/src/xrt/auxiliary/bindings/bindings.py @@ -604,7 +604,7 @@ def generate_bindings_c(file, b): # @todo Doesn't handle pose yet. steamvr_path = component.steamvr_path - if component.component_name in ["click", "touch", "force", "value"]: + if component.component_name in ["click", "touch", "force", "value", "proximity"]: steamvr_path += "/" + component.component_name f.write(f'\t\t\t{{ // binding_template {idx}\n') diff --git a/src/xrt/include/xrt/xrt_config_build.h.cmake_in b/src/xrt/include/xrt/xrt_config_build.h.cmake_in index b8bc33fff..180db451f 100644 --- a/src/xrt/include/xrt/xrt_config_build.h.cmake_in +++ b/src/xrt/include/xrt/xrt_config_build.h.cmake_in @@ -46,6 +46,7 @@ #cmakedefine XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE #cmakedefine XRT_FEATURE_OPENXR_INTERACTION_VIVE_COSMOS #cmakedefine XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3 +#cmakedefine XRT_FEATURE_OPENXR_INTERACTION_FB_PROXIMITY #cmakedefine XRT_FEATURE_OPENXR_LAYER_COLOR_SCALE_BIAS #cmakedefine XRT_FEATURE_OPENXR_LAYER_CUBE #cmakedefine XRT_FEATURE_OPENXR_LAYER_CYLINDER diff --git a/src/xrt/include/xrt/xrt_defines.h b/src/xrt/include/xrt/xrt_defines.h index f79c9ee30..c17e767be 100644 --- a/src/xrt/include/xrt/xrt_defines.h +++ b/src/xrt/include/xrt/xrt_defines.h @@ -1021,6 +1021,8 @@ enum xrt_input_type _(XRT_INPUT_TOUCH_THUMBREST_TOUCH , XRT_INPUT_NAME(0x00D0, BOOLEAN)) \ _(XRT_INPUT_TOUCH_GRIP_POSE , XRT_INPUT_NAME(0x00D1, POSE)) \ _(XRT_INPUT_TOUCH_AIM_POSE , XRT_INPUT_NAME(0x00D2, POSE)) \ + _(XRT_INPUT_TOUCH_TRIGGER_PROXIMITY , XRT_INPUT_NAME(0x00D3, BOOLEAN)) \ + _(XRT_INPUT_TOUCH_THUMB_PROXIMITY , XRT_INPUT_NAME(0x00D4, BOOLEAN)) \ \ _(XRT_INPUT_HAND_SELECT_VALUE , XRT_INPUT_NAME(0x00E0, VEC1_ZERO_TO_ONE)) \ _(XRT_INPUT_HAND_SQUEEZE_VALUE , XRT_INPUT_NAME(0x00E1, VEC1_ZERO_TO_ONE)) \ diff --git a/src/xrt/state_trackers/oxr/oxr_extension_support.h b/src/xrt/state_trackers/oxr/oxr_extension_support.h index 869fba544..6139141b6 100644 --- a/src/xrt/state_trackers/oxr/oxr_extension_support.h +++ b/src/xrt/state_trackers/oxr/oxr_extension_support.h @@ -486,6 +486,18 @@ #endif +/* + * XR_FB_touch_controller_proximity + */ +#if defined(XR_FB_touch_controller_proximity) && defined(XRT_FEATURE_OPENXR_INTERACTION_FB_PROXIMITY) +#define OXR_HAVE_FB_touch_controller_proximity +#define OXR_EXTENSION_SUPPORT_FB_touch_controller_proximity(_) \ + _(FB_touch_controller_proximity, FB_TOUCH_CONTROLLER_PROXIMITY) +#else +#define OXR_EXTENSION_SUPPORT_FB_touch_controller_proximity(_) +#endif + + /* * XR_HTC_facial_tracking */ @@ -744,6 +756,7 @@ OXR_EXTENSION_SUPPORT_FB_composition_layer_depth_test(_) \ OXR_EXTENSION_SUPPORT_FB_display_refresh_rate(_) \ OXR_EXTENSION_SUPPORT_FB_passthrough(_) \ + OXR_EXTENSION_SUPPORT_FB_touch_controller_proximity(_) \ OXR_EXTENSION_SUPPORT_HTC_facial_tracking(_) \ OXR_EXTENSION_SUPPORT_ML_ml2_controller_interaction(_) \ OXR_EXTENSION_SUPPORT_MND_headless(_) \