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 | #ifndef OPENXR_INTERACTION_PROFILE_H |
32 | #define OPENXR_INTERACTION_PROFILE_H |
33 | |
34 | #include "openxr_action.h" |
35 | #include "openxr_interaction_profile_metadata.h" |
36 | |
37 | #include "core/io/resource.h" |
38 | |
39 | class OpenXRIPBinding : public Resource { |
40 | GDCLASS(OpenXRIPBinding, Resource); |
41 | |
42 | private: |
43 | Ref<OpenXRAction> action; |
44 | PackedStringArray paths; |
45 | |
46 | protected: |
47 | static void _bind_methods(); |
48 | |
49 | public: |
50 | static Ref<OpenXRIPBinding> new_binding(const Ref<OpenXRAction> p_action, const char *p_paths); // Helper function for adding a new binding |
51 | |
52 | void set_action(const Ref<OpenXRAction> p_action); // Set the action for this binding |
53 | Ref<OpenXRAction> get_action() const; // Get the action for this binding |
54 | |
55 | int get_path_count() const; // Get the number of io paths |
56 | void set_paths(const PackedStringArray p_paths); // Set our paths (for loading from resource) |
57 | PackedStringArray get_paths() const; // Get our paths (for saving to resource) |
58 | |
59 | void parse_paths(const String p_paths); // Parse a comma separated string of io paths. |
60 | |
61 | bool has_path(const String p_path) const; // Has this io path |
62 | void add_path(const String p_path); // Add an io path |
63 | void remove_path(const String p_path); // Remove an io path |
64 | |
65 | // TODO add validation that we can display in the interface that checks if no two paths belong to the same top level path |
66 | |
67 | ~OpenXRIPBinding(); |
68 | }; |
69 | |
70 | class OpenXRInteractionProfile : public Resource { |
71 | GDCLASS(OpenXRInteractionProfile, Resource); |
72 | |
73 | private: |
74 | String interaction_profile_path; |
75 | Array bindings; |
76 | |
77 | protected: |
78 | static void _bind_methods(); |
79 | |
80 | public: |
81 | static Ref<OpenXRInteractionProfile> new_profile(const char *p_input_profile_path); // Helper function to create a new interaction profile |
82 | |
83 | void set_interaction_profile_path(const String p_input_profile_path); // Set our input profile path |
84 | String get_interaction_profile_path() const; // get our input profile path |
85 | |
86 | int get_binding_count() const; // Retrieve the number of bindings in this profile path |
87 | Ref<OpenXRIPBinding> get_binding(int p_index) const; |
88 | void set_bindings(Array p_bindings); // Set the bindings (for loading from a resource) |
89 | Array get_bindings() const; // Get the bindings (for saving to a resource) |
90 | |
91 | Ref<OpenXRIPBinding> get_binding_for_action(const Ref<OpenXRAction> p_action) const; // Get our binding record for a given action |
92 | void add_binding(Ref<OpenXRIPBinding> p_binding); // Add a binding object |
93 | void remove_binding(Ref<OpenXRIPBinding> p_binding); // Remove a binding object |
94 | |
95 | void add_new_binding(const Ref<OpenXRAction> p_action, const char *p_paths); // Create a new binding for this profile |
96 | void remove_binding_for_action(const Ref<OpenXRAction> p_action); // Remove all bindings for this action |
97 | bool has_binding_for_action(const Ref<OpenXRAction> p_action); // Returns true if we have a binding for this action |
98 | |
99 | ~OpenXRInteractionProfile(); |
100 | }; |
101 | |
102 | #endif // OPENXR_INTERACTION_PROFILE_H |
103 | |