diff options
Diffstat (limited to 'modules/openxr/openxr_api.h')
-rw-r--r-- | modules/openxr/openxr_api.h | 83 |
1 files changed, 56 insertions, 27 deletions
diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h index 33b503543a..e20826c849 100644 --- a/modules/openxr/openxr_api.h +++ b/modules/openxr/openxr_api.h @@ -55,12 +55,16 @@ // forward declarations, we don't want to include these fully class OpenXRVulkanExtension; +class OpenXRInterface; class OpenXRAPI { private: // our singleton static OpenXRAPI *singleton; + // linked XR interface + OpenXRInterface *xr_interface = nullptr; + // layers uint32_t num_layer_properties = 0; XrApiLayerProperties *layer_properties = nullptr; @@ -148,29 +152,45 @@ private: bool release_image(XrSwapchain p_swapchain); // action map - struct Path { - XrPath path; + struct Tracker { // Trackers represent tracked physical objects such as controllers, pucks, etc. + String name; // Name for this tracker (i.e. "/user/hand/left") + XrPath toplevel_path; // OpenXR XrPath for this tracker + RID active_profile_rid; // RID of the active profile for this tracker }; - RID_Owner<Path, true> xr_path_owner; + RID_Owner<Tracker, true> tracker_owner; + RID get_tracker_rid(XrPath p_path); - struct ActionSet { - bool is_attached; - XrActionSet handle; + struct ActionSet { // Action sets define a set of actions that can be enabled together + String name; // Name for this action set (i.e. "godot_action_set") + bool is_attached; // If true our action set has been attached to the session and can no longer be modified + XrActionSet handle; // OpenXR handle for this action set }; RID_Owner<ActionSet, true> action_set_owner; - struct PathWithSpace { - XrPath toplevel_path; - XrSpace space; - bool was_location_valid; + struct ActionTracker { // Links and action to a tracker + RID tracker_rid; // RID of the tracker + XrSpace space; // Optional space for pose actions + bool was_location_valid; // If true the last position we obtained was valid }; - struct Action { - XrActionType action_type; - Vector<PathWithSpace> toplevel_paths; - XrAction handle; + struct Action { // Actions define the inputs and outputs in OpenXR + RID action_set_rid; // RID of the action set this action belongs to + String name; // Name for this action (i.e. "aim_pose") + XrActionType action_type; // Type of action (bool, float, etc.) + Vector<ActionTracker> trackers; // The trackers this action can be used with + XrAction handle; // OpenXR handle for this action }; RID_Owner<Action, true> action_owner; + RID get_action_rid(XrAction p_action); + + struct InteractionProfile { // Interaction profiles define suggested bindings between the physical inputs on controller types and our actions + String name; // Name of the interaction profile (i.e. "/interaction_profiles/valve/index_controller") + XrPath path; // OpenXR path for this profile + Vector<XrActionSuggestedBinding> bindings; // OpenXR action bindings + }; + RID_Owner<InteractionProfile, true> interaction_profile_owner; + RID get_interaction_profile_rid(XrPath p_path); + XrPath get_interaction_profile_path(RID p_interaction_profile); // state changes bool poll_events(); @@ -209,6 +229,7 @@ public: String get_error_string(XrResult result); String get_swapchain_format_name(int64_t p_swapchain_format) const; + void set_xr_interface(OpenXRInterface *p_xr_interface); void register_extension_wrapper(OpenXRExtensionWrapper *p_extension_wrapper); bool is_initialized(); @@ -233,26 +254,34 @@ public: // action map String get_default_action_map_resource_name(); - RID path_create(const String p_name); - void path_free(RID p_path); + + RID tracker_create(const String p_name); + String tracker_get_name(RID p_tracker); + void tracker_check_profile(RID p_tracker, XrSession p_session = XR_NULL_HANDLE); + void tracker_free(RID p_tracker); + RID action_set_create(const String p_name, const String p_localized_name, const int p_priority); + String action_set_get_name(RID p_action_set); bool action_set_attach(RID p_action_set); void action_set_free(RID p_action_set); - RID action_create(RID p_action_set, const String p_name, const String p_localized_name, OpenXRAction::ActionType p_action_type, const Vector<RID> &p_toplevel_paths); + + RID action_create(RID p_action_set, const String p_name, const String p_localized_name, OpenXRAction::ActionType p_action_type, const Vector<RID> &p_trackers); + String action_get_name(RID p_action); void action_free(RID p_action); - struct Binding { - RID action; - String path; - }; - bool suggest_bindings(const String p_interaction_profile, const Vector<Binding> p_bindings); + RID interaction_profile_create(const String p_name); + String interaction_profile_get_name(RID p_interaction_profile); + void interaction_profile_clear_bindings(RID p_interaction_profile); + bool interaction_profile_add_binding(RID p_interaction_profile, RID p_action, const String p_path); + bool interaction_profile_suggest_bindings(RID p_interaction_profile); + void interaction_profile_free(RID p_interaction_profile); bool sync_action_sets(const Vector<RID> p_active_sets); - bool get_action_bool(RID p_action, RID p_path); - float get_action_float(RID p_action, RID p_path); - Vector2 get_action_vector2(RID p_action, RID p_path); - XRPose::TrackingConfidence get_action_pose(RID p_action, RID p_path, Transform3D &r_transform, Vector3 &r_linear_velocity, Vector3 &r_angular_velocity); - bool trigger_haptic_pulse(RID p_action, RID p_path, float p_frequency, float p_amplitude, XrDuration p_duration_ns); + bool get_action_bool(RID p_action, RID p_tracker); + float get_action_float(RID p_action, RID p_tracker); + Vector2 get_action_vector2(RID p_action, RID p_tracker); + XRPose::TrackingConfidence get_action_pose(RID p_action, RID p_tracker, Transform3D &r_transform, Vector3 &r_linear_velocity, Vector3 &r_angular_velocity); + bool trigger_haptic_pulse(RID p_action, RID p_tracker, float p_frequency, float p_amplitude, XrDuration p_duration_ns); OpenXRAPI(); ~OpenXRAPI(); |