Path: blob/master/modules/openxr/action_map/openxr_interaction_profile.h
10278 views
/**************************************************************************/1/* openxr_interaction_profile.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#include "openxr_action.h"33#include "openxr_binding_modifier.h"34#include "openxr_interaction_profile_metadata.h"3536#include "core/io/resource.h"3738class OpenXRActionMap;3940class OpenXRIPBinding : public Resource {41GDCLASS(OpenXRIPBinding, Resource);4243private:44Ref<OpenXRAction> action;45String binding_path;46Vector<Ref<OpenXRActionBindingModifier>> binding_modifiers;4748protected:49friend class OpenXRActionMap;5051OpenXRActionMap *action_map = nullptr;5253static void _bind_methods();5455public:56static Ref<OpenXRIPBinding> new_binding(const Ref<OpenXRAction> p_action, const String &p_binding_path); // Helper function for adding a new binding.5758OpenXRActionMap *get_action_map() { return action_map; } // Return the action map we're a part of.5960void set_action(const Ref<OpenXRAction> &p_action); // Set the action for this binding.61Ref<OpenXRAction> get_action() const; // Get the action for this binding.6263void set_binding_path(const String &path);64String get_binding_path() const;6566int get_binding_modifier_count() const; // Retrieve the number of binding modifiers in this profile path67Ref<OpenXRActionBindingModifier> get_binding_modifier(int p_index) const;68void clear_binding_modifiers(); // Remove all binding modifiers69void set_binding_modifiers(const Array &p_bindings); // Set the binding modifiers (for loading from a resource)70Array get_binding_modifiers() const; // Get the binding modifiers (for saving to a resource)7172void add_binding_modifier(const Ref<OpenXRActionBindingModifier> &p_binding_modifier); // Add a binding modifier object73void remove_binding_modifier(const Ref<OpenXRActionBindingModifier> &p_binding_modifier); // Remove a binding modifier object7475// Deprecated.76#ifndef DISABLE_DEPRECATED77void set_paths(const PackedStringArray p_paths); // Set our paths (for loading from resource), needed for loading old action maps.78PackedStringArray get_paths() const; // Get our paths (for saving to resource), needed for converted old action maps.79int get_path_count() const; // Get the number of io paths.80bool has_path(const String p_path) const; // Has this io path.81void add_path(const String p_path); // Add an io path.82void remove_path(const String p_path); // Remove an io path.83#endif // DISABLE_DEPRECATED8485// TODO add validation that we can display in the interface that checks if no two paths belong to the same top level path8687~OpenXRIPBinding();88};8990class OpenXRInteractionProfile : public Resource {91GDCLASS(OpenXRInteractionProfile, Resource);9293private:94String interaction_profile_path;95Array bindings;96Vector<Ref<OpenXRIPBindingModifier>> binding_modifiers;9798protected:99friend class OpenXRActionMap;100101OpenXRActionMap *action_map = nullptr;102103static void _bind_methods();104105public:106static Ref<OpenXRInteractionProfile> new_profile(const char *p_input_profile_path); // Helper function to create a new interaction profile107108OpenXRActionMap *get_action_map() { return action_map; }109110void set_interaction_profile_path(const String p_input_profile_path); // Set our input profile path111String get_interaction_profile_path() const; // get our input profile path112113int get_binding_count() const; // Retrieve the number of bindings in this profile path114Ref<OpenXRIPBinding> get_binding(int p_index) const;115void set_bindings(const Array &p_bindings); // Set the bindings (for loading from a resource)116Array get_bindings() const; // Get the bindings (for saving to a resource)117118Ref<OpenXRIPBinding> find_binding(const Ref<OpenXRAction> &p_action, const String &p_binding_path) const; // Get our binding record119Vector<Ref<OpenXRIPBinding>> get_bindings_for_action(const Ref<OpenXRAction> &p_action) const; // Get our binding record for a given action120void add_binding(const Ref<OpenXRIPBinding> &p_binding); // Add a binding object121void remove_binding(const Ref<OpenXRIPBinding> &p_binding); // Remove a binding object122123void add_new_binding(const Ref<OpenXRAction> &p_action, const String &p_paths); // Create a new binding for this profile124void remove_binding_for_action(const Ref<OpenXRAction> &p_action); // Remove all bindings for this action125bool has_binding_for_action(const Ref<OpenXRAction> &p_action); // Returns true if we have a binding for this action126127int get_binding_modifier_count() const; // Retrieve the number of binding modifiers in this profile path128Ref<OpenXRIPBindingModifier> get_binding_modifier(int p_index) const;129void clear_binding_modifiers(); // Remove all binding modifiers130void set_binding_modifiers(const Array &p_bindings); // Set the binding modifiers (for loading from a resource)131Array get_binding_modifiers() const; // Get the binding modifiers (for saving to a resource)132133void add_binding_modifier(const Ref<OpenXRIPBindingModifier> &p_binding_modifier); // Add a binding modifier object134void remove_binding_modifier(const Ref<OpenXRIPBindingModifier> &p_binding_modifier); // Remove a binding modifier object135136~OpenXRInteractionProfile();137};138139140