openxr_dpad_binding_extension.h 4.4 KB

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