Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/openxr/action_map/openxr_interaction_profile.h
10278 views
1
/**************************************************************************/
2
/* openxr_interaction_profile.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "openxr_action.h"
34
#include "openxr_binding_modifier.h"
35
#include "openxr_interaction_profile_metadata.h"
36
37
#include "core/io/resource.h"
38
39
class OpenXRActionMap;
40
41
class OpenXRIPBinding : public Resource {
42
GDCLASS(OpenXRIPBinding, Resource);
43
44
private:
45
Ref<OpenXRAction> action;
46
String binding_path;
47
Vector<Ref<OpenXRActionBindingModifier>> binding_modifiers;
48
49
protected:
50
friend class OpenXRActionMap;
51
52
OpenXRActionMap *action_map = nullptr;
53
54
static void _bind_methods();
55
56
public:
57
static Ref<OpenXRIPBinding> new_binding(const Ref<OpenXRAction> p_action, const String &p_binding_path); // Helper function for adding a new binding.
58
59
OpenXRActionMap *get_action_map() { return action_map; } // Return the action map we're a part of.
60
61
void set_action(const Ref<OpenXRAction> &p_action); // Set the action for this binding.
62
Ref<OpenXRAction> get_action() const; // Get the action for this binding.
63
64
void set_binding_path(const String &path);
65
String get_binding_path() const;
66
67
int get_binding_modifier_count() const; // Retrieve the number of binding modifiers in this profile path
68
Ref<OpenXRActionBindingModifier> get_binding_modifier(int p_index) const;
69
void clear_binding_modifiers(); // Remove all binding modifiers
70
void set_binding_modifiers(const Array &p_bindings); // Set the binding modifiers (for loading from a resource)
71
Array get_binding_modifiers() const; // Get the binding modifiers (for saving to a resource)
72
73
void add_binding_modifier(const Ref<OpenXRActionBindingModifier> &p_binding_modifier); // Add a binding modifier object
74
void remove_binding_modifier(const Ref<OpenXRActionBindingModifier> &p_binding_modifier); // Remove a binding modifier object
75
76
// Deprecated.
77
#ifndef DISABLE_DEPRECATED
78
void set_paths(const PackedStringArray p_paths); // Set our paths (for loading from resource), needed for loading old action maps.
79
PackedStringArray get_paths() const; // Get our paths (for saving to resource), needed for converted old action maps.
80
int get_path_count() const; // Get the number of io paths.
81
bool has_path(const String p_path) const; // Has this io path.
82
void add_path(const String p_path); // Add an io path.
83
void remove_path(const String p_path); // Remove an io path.
84
#endif // DISABLE_DEPRECATED
85
86
// TODO add validation that we can display in the interface that checks if no two paths belong to the same top level path
87
88
~OpenXRIPBinding();
89
};
90
91
class OpenXRInteractionProfile : public Resource {
92
GDCLASS(OpenXRInteractionProfile, Resource);
93
94
private:
95
String interaction_profile_path;
96
Array bindings;
97
Vector<Ref<OpenXRIPBindingModifier>> binding_modifiers;
98
99
protected:
100
friend class OpenXRActionMap;
101
102
OpenXRActionMap *action_map = nullptr;
103
104
static void _bind_methods();
105
106
public:
107
static Ref<OpenXRInteractionProfile> new_profile(const char *p_input_profile_path); // Helper function to create a new interaction profile
108
109
OpenXRActionMap *get_action_map() { return action_map; }
110
111
void set_interaction_profile_path(const String p_input_profile_path); // Set our input profile path
112
String get_interaction_profile_path() const; // get our input profile path
113
114
int get_binding_count() const; // Retrieve the number of bindings in this profile path
115
Ref<OpenXRIPBinding> get_binding(int p_index) const;
116
void set_bindings(const Array &p_bindings); // Set the bindings (for loading from a resource)
117
Array get_bindings() const; // Get the bindings (for saving to a resource)
118
119
Ref<OpenXRIPBinding> find_binding(const Ref<OpenXRAction> &p_action, const String &p_binding_path) const; // Get our binding record
120
Vector<Ref<OpenXRIPBinding>> get_bindings_for_action(const Ref<OpenXRAction> &p_action) const; // Get our binding record for a given action
121
void add_binding(const Ref<OpenXRIPBinding> &p_binding); // Add a binding object
122
void remove_binding(const Ref<OpenXRIPBinding> &p_binding); // Remove a binding object
123
124
void add_new_binding(const Ref<OpenXRAction> &p_action, const String &p_paths); // Create a new binding for this profile
125
void remove_binding_for_action(const Ref<OpenXRAction> &p_action); // Remove all bindings for this action
126
bool has_binding_for_action(const Ref<OpenXRAction> &p_action); // Returns true if we have a binding for this action
127
128
int get_binding_modifier_count() const; // Retrieve the number of binding modifiers in this profile path
129
Ref<OpenXRIPBindingModifier> get_binding_modifier(int p_index) const;
130
void clear_binding_modifiers(); // Remove all binding modifiers
131
void set_binding_modifiers(const Array &p_bindings); // Set the binding modifiers (for loading from a resource)
132
Array get_binding_modifiers() const; // Get the binding modifiers (for saving to a resource)
133
134
void add_binding_modifier(const Ref<OpenXRIPBindingModifier> &p_binding_modifier); // Add a binding modifier object
135
void remove_binding_modifier(const Ref<OpenXRIPBindingModifier> &p_binding_modifier); // Remove a binding modifier object
136
137
~OpenXRInteractionProfile();
138
};
139
140