1/**************************************************************************/
2/* openxr_action.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_ACTION_H
32#define OPENXR_ACTION_H
33
34#include "core/io/resource.h"
35
36class OpenXRActionSet;
37
38class OpenXRAction : public Resource {
39 GDCLASS(OpenXRAction, Resource);
40
41public:
42 enum ActionType {
43 OPENXR_ACTION_BOOL,
44 OPENXR_ACTION_FLOAT,
45 OPENXR_ACTION_VECTOR2,
46 OPENXR_ACTION_POSE,
47 OPENXR_ACTION_HAPTIC,
48 OPENXR_ACTION_MAX
49 };
50
51private:
52 String localized_name;
53 ActionType action_type = OPENXR_ACTION_FLOAT;
54
55 PackedStringArray toplevel_paths;
56
57protected:
58 friend class OpenXRActionSet;
59
60 OpenXRActionSet *action_set = nullptr; // action belongs to this action set.
61
62 static void _bind_methods();
63
64public:
65 static Ref<OpenXRAction> new_action(const char *p_name, const char *p_localized_name, const ActionType p_action_type, const char *p_toplevel_paths); // Helper function to add and configure an action
66 OpenXRActionSet *get_action_set() const { return action_set; } // Get the action set this action belongs to
67
68 String get_name_with_set() const; // Retrieve the name of this action as <action_set>/<action>
69
70 void set_localized_name(const String p_localized_name); // Set the localized name of this action
71 String get_localized_name() const; // Get the localized name of this action
72
73 void set_action_type(const ActionType p_action_type); // Set the type of this action
74 ActionType get_action_type() const; // Get the type of this action
75
76 void set_toplevel_paths(const PackedStringArray p_toplevel_paths); // Set the toplevel paths of this action
77 PackedStringArray get_toplevel_paths() const; // Get the toplevel paths of this action
78
79 void add_toplevel_path(const String p_toplevel_path); // Add a top level path to this action
80 void rem_toplevel_path(const String p_toplevel_path); // Remove a toplevel path from this action
81
82 void parse_toplevel_paths(const String p_toplevel_paths); // Parse and set the top level paths from a comma separated string
83};
84
85VARIANT_ENUM_CAST(OpenXRAction::ActionType);
86
87#endif // OPENXR_ACTION_H
88