BarrierInputSystemComponent.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <BarrierInputClient.h>
  10. #include <AzCore/EBus/EBus.h>
  11. #include <AzCore/Component/Component.h>
  12. #include <AzCore/std/smart_ptr/unique_ptr.h>
  13. ////////////////////////////////////////////////////////////////////////////////////////////////////
  14. namespace BarrierInput
  15. {
  16. ////////////////////////////////////////////////////////////////////////////////////////////////
  17. //! EBus interface used to listen for changes to Barrier connection related CVars.
  18. class BarrierInputConnectionNotifications : public AZ::EBusTraits
  19. {
  20. public:
  21. ////////////////////////////////////////////////////////////////////////////////////////////
  22. //! Called when a CVar relating to the Barrier input connection changes.
  23. virtual void OnBarrierConnectionCVarChanged() {}
  24. };
  25. using BarrierInputConnectionNotificationBus = AZ::EBus<BarrierInputConnectionNotifications>;
  26. ////////////////////////////////////////////////////////////////////////////////////////////////
  27. //! A system component providing functionality related to Barrier input.
  28. class BarrierInputSystemComponent : public AZ::Component
  29. , public BarrierInputConnectionNotificationBus::Handler
  30. {
  31. public:
  32. ////////////////////////////////////////////////////////////////////////////////////////////
  33. // AZ::Component Setup
  34. AZ_COMPONENT(BarrierInputSystemComponent, "{720B6420-8A76-46F9-80C7-0DBF0CD467C2}");
  35. ////////////////////////////////////////////////////////////////////////////////////////////
  36. //! \ref AZ::ComponentDescriptor::Reflect
  37. static void Reflect(AZ::ReflectContext* context);
  38. ////////////////////////////////////////////////////////////////////////////////////////////
  39. //! \ref AZ::ComponentDescriptor::GetProvidedServices
  40. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  41. ////////////////////////////////////////////////////////////////////////////////////////////
  42. //! \ref AZ::ComponentDescriptor::GetIncompatibleServices
  43. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  44. ////////////////////////////////////////////////////////////////////////////////////////////
  45. //! Default constructor
  46. BarrierInputSystemComponent() = default;
  47. ////////////////////////////////////////////////////////////////////////////////////////////
  48. //! Default destructor
  49. ~BarrierInputSystemComponent() override = default;
  50. ////////////////////////////////////////////////////////////////////////////////////////////
  51. //! \ref AZ::Component::Activate
  52. void Activate() override;
  53. ////////////////////////////////////////////////////////////////////////////////////////////
  54. //! \ref AZ::Component::Deactivate
  55. void Deactivate() override;
  56. protected:
  57. ////////////////////////////////////////////////////////////////////////////////////////////
  58. //! \ref BarrierInput::BarrierInputConnectionNotifications::OnBarrierConnectionCVarChanged
  59. void OnBarrierConnectionCVarChanged() override;
  60. ////////////////////////////////////////////////////////////////////////////////////////////
  61. //! Try to create the Barrier client and input device implementations.
  62. void TryCreateBarrierClientAndInputDeviceImplementations();
  63. ////////////////////////////////////////////////////////////////////////////////////////////
  64. //! Destroy the Barrier client and input device implementations (if they've been created).
  65. void DestroyBarrierClientAndInputDeviceImplementations();
  66. private:
  67. ////////////////////////////////////////////////////////////////////////////////////////////
  68. //! The Barrier client instance.
  69. AZStd::unique_ptr<BarrierClient> m_barrierClient;
  70. };
  71. } // namespace BarrierInput