openxr_interaction_profile.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. PackedStringArray paths;
  40. protected:
  41. static void _bind_methods();
  42. public:
  43. static Ref<OpenXRIPBinding> new_binding(const Ref<OpenXRAction> p_action, const char *p_paths); // 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. int get_path_count() const; // Get the number of io paths
  47. void set_paths(const PackedStringArray p_paths); // Set our paths (for loading from resource)
  48. PackedStringArray get_paths() const; // Get our paths (for saving to resource)
  49. void parse_paths(const String p_paths); // Parse a comma separated string of io paths.
  50. bool has_path(const String p_path) const; // Has this io path
  51. void add_path(const String p_path); // Add an io path
  52. void remove_path(const String p_path); // Remove an io path
  53. // TODO add validation that we can display in the interface that checks if no two paths belong to the same top level path
  54. ~OpenXRIPBinding();
  55. };
  56. class OpenXRInteractionProfile : public Resource {
  57. GDCLASS(OpenXRInteractionProfile, Resource);
  58. private:
  59. String interaction_profile_path;
  60. Array bindings;
  61. protected:
  62. static void _bind_methods();
  63. public:
  64. static Ref<OpenXRInteractionProfile> new_profile(const char *p_input_profile_path); // Helper function to create a new interaction profile
  65. void set_interaction_profile_path(const String p_input_profile_path); // Set our input profile path
  66. String get_interaction_profile_path() const; // get our input profile path
  67. int get_binding_count() const; // Retrieve the number of bindings in this profile path
  68. Ref<OpenXRIPBinding> get_binding(int p_index) const;
  69. void set_bindings(Array p_bindings); // Set the bindings (for loading from a resource)
  70. Array get_bindings() const; // Get the bindings (for saving to a resource)
  71. Ref<OpenXRIPBinding> get_binding_for_action(const Ref<OpenXRAction> p_action) const; // Get our binding record for a given action
  72. void add_binding(Ref<OpenXRIPBinding> p_binding); // Add a binding object
  73. void remove_binding(Ref<OpenXRIPBinding> p_binding); // Remove a binding object
  74. void add_new_binding(const Ref<OpenXRAction> p_action, const char *p_paths); // Create a new binding for this profile
  75. void remove_binding_for_action(const Ref<OpenXRAction> p_action); // Remove all bindings for this action
  76. bool has_binding_for_action(const Ref<OpenXRAction> p_action); // Returns true if we have a binding for this action
  77. ~OpenXRInteractionProfile();
  78. };
  79. #endif // OPENXR_INTERACTION_PROFILE_H