openxr_dpad_binding_extension.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**************************************************************************/
  2. /* openxr_dpad_binding_extension.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_DPAD_BINDING_EXTENSION_H
  31. #define OPENXR_DPAD_BINDING_EXTENSION_H
  32. #include "../action_map/openxr_action_set.h"
  33. #include "../action_map/openxr_binding_modifier.h"
  34. #include "../action_map/openxr_haptic_feedback.h"
  35. #include "../util.h"
  36. #include "openxr_extension_wrapper.h"
  37. class OpenXRDPadBindingExtension : public OpenXRExtensionWrapper {
  38. public:
  39. static OpenXRDPadBindingExtension *get_singleton();
  40. OpenXRDPadBindingExtension();
  41. virtual ~OpenXRDPadBindingExtension() override;
  42. virtual HashMap<String, bool *> get_requested_extensions() override;
  43. bool is_available();
  44. private:
  45. static OpenXRDPadBindingExtension *singleton;
  46. bool binding_modifier_ext = false;
  47. bool dpad_binding_ext = false;
  48. };
  49. class OpenXRDpadBindingModifier : public OpenXRIPBindingModifier {
  50. GDCLASS(OpenXRDpadBindingModifier, OpenXRIPBindingModifier);
  51. private:
  52. PackedByteArray dpad_bindings_data;
  53. XrInteractionProfileDpadBindingEXT *dpad_bindings = nullptr;
  54. String input_path;
  55. Ref<OpenXRActionSet> action_set;
  56. Ref<OpenXRHapticBase> on_haptic;
  57. Ref<OpenXRHapticBase> off_haptic;
  58. protected:
  59. static void _bind_methods();
  60. public:
  61. OpenXRDpadBindingModifier();
  62. void set_action_set(const Ref<OpenXRActionSet> p_action_set);
  63. Ref<OpenXRActionSet> get_action_set() const;
  64. void set_input_path(const String &p_input_path);
  65. String get_input_path() const;
  66. void set_threshold(float p_threshold);
  67. float get_threshold() const;
  68. void set_threshold_released(float p_threshold);
  69. float get_threshold_released() const;
  70. void set_center_region(float p_center_region);
  71. float get_center_region() const;
  72. void set_wedge_angle(float p_wedge_angle);
  73. float get_wedge_angle() const;
  74. void set_wedge_angle_deg(float p_wedge_angle);
  75. float get_wedge_angle_deg() const;
  76. void set_is_sticky(bool p_sticky);
  77. bool get_is_sticky() const;
  78. void set_on_haptic(const Ref<OpenXRHapticBase> &p_haptic);
  79. Ref<OpenXRHapticBase> get_on_haptic() const;
  80. void set_off_haptic(const Ref<OpenXRHapticBase> &p_haptic);
  81. Ref<OpenXRHapticBase> get_off_haptic() const;
  82. virtual String get_description() const override { return "DPad modifier"; }
  83. virtual PackedByteArray get_ip_modification() override;
  84. };
  85. #endif // OPENXR_DPAD_BINDING_EXTENSION_H