Path: blob/master/modules/openxr/action_map/openxr_interaction_profile_metadata.h
10278 views
/**************************************************************************/1/* openxr_interaction_profile_metadata.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132///////////////////////////////////////////////////////////////////////////33// Stores available interaction profile metadata34//35// OpenXR defines and hardcodes all the supported input devices and their36// paths as part of the OpenXR spec. When support for new devices is37// introduced this often starts life as an extension that needs to be enabled38// until it's adopted into the core. As there is no interface to39// enumerate the possibly paths, and that any OpenXR runtime would likely40// limit such enumeration to those input devices supported by that runtime41// there is no other option than to hardcode this.42//43// Note that we need to include paths of our extensions in our action map44// regardless of whether the developers machine supports the extension or45// not. Unsupported paths are filtered out when the action map is submitted46// to the OpenXR runtime.47//48// Note on action type that automatic conversions between boolean and float49// are supported but otherwise action types should match between action and50// input/output paths.5152#include "openxr_action.h"5354#include "core/object/object.h"55#include "core/templates/hash_map.h"5657#define XR_PATH_UNSUPPORTED_NAME "unsupported"5859class OpenXRInteractionProfileMetadata : public Object {60GDCLASS(OpenXRInteractionProfileMetadata, Object);6162public:63struct TopLevelPath {64String display_name; // User friendly display name (i.e. Left controller)65String openxr_path; // Path in OpenXR (i.e. /user/hand/left)66String openxr_extension_name; // If set, only available if extension is enabled (i.e. XR_HTCX_vive_tracker_interaction)67};6869struct IOPath {70String display_name; // User friendly display name (i.e. Grip pose (left controller))71String top_level_path; // Top level path identifying the usage of the device in relation to this input/output72String openxr_path; // Path in OpenXR (i.e. /user/hand/left/input/grip/pose)73String openxr_extension_name; // If set, only available if extension is enabled (i.e. XR_EXT_palm_pose)74OpenXRAction::ActionType action_type; // Type of input/output75};7677struct InteractionProfile {78String display_name; // User friendly display name (i.e. Simple controller)79String openxr_path; // Path in OpenXR (i.e. /interaction_profiles/khr/simple_controller)80String openxr_extension_name; // If set, only available if extension is enabled (i.e. XR_HTCX_vive_tracker_interaction)81Vector<IOPath> io_paths; // Inputs and outputs for this device8283bool has_io_path(const String p_io_path) const;84const IOPath *get_io_path(const String p_io_path) const;85};8687private:88static OpenXRInteractionProfileMetadata *singleton;8990HashMap<String, String> profile_renames;91Vector<TopLevelPath> top_level_paths;92Vector<InteractionProfile> interaction_profiles;9394void _register_core_metadata();9596protected:97static void _bind_methods();9899public:100static OpenXRInteractionProfileMetadata *get_singleton() { return singleton; }101102OpenXRInteractionProfileMetadata();103~OpenXRInteractionProfileMetadata();104105void register_profile_rename(const String &p_old_name, const String &p_new_name);106String check_profile_name(const String &p_name) const;107108void register_top_level_path(const String &p_display_name, const String &p_openxr_path, const String &p_openxr_extension_name);109bool has_top_level_path(const String p_openxr_path) const;110String get_top_level_name(const String p_openxr_path) const;111String get_top_level_extension(const String p_openxr_path) const;112113void register_interaction_profile(const String &p_display_name, const String &p_openxr_path, const String &p_openxr_extension_name);114bool has_interaction_profile(const String p_openxr_path) const;115String get_interaction_profile_extension(const String p_openxr_path) const;116const InteractionProfile *get_profile(const String p_openxr_path) const;117PackedStringArray get_interaction_profile_paths() const;118119void register_io_path(const String &p_interaction_profile, const String &p_display_name, const String &p_toplevel_path, const String &p_openxr_path, const String &p_openxr_extension_name, OpenXRAction::ActionType p_action_type);120const IOPath *get_io_path(const String p_interaction_profile, const String p_io_path) const;121};122123124