openxr_interaction_profile.h 5.3 KB

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