VirtualGamepadSystemComponent.h 4.2 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 <AzCore/Component/Component.h>
  10. #include <AzCore/std/smart_ptr/unique_ptr.h>
  11. #include <LyShine/UiAssetTypes.h>
  12. #include <VirtualGamepad/VirtualGamepadBus.h>
  13. ////////////////////////////////////////////////////////////////////////////////////////////////////
  14. namespace VirtualGamepad
  15. {
  16. class InputDeviceVirtualGamepad;
  17. ////////////////////////////////////////////////////////////////////////////////////////////////
  18. class VirtualGamepadSystemComponent : public AZ::Component
  19. , public VirtualGamepadRequestBus::Handler
  20. {
  21. public:
  22. ////////////////////////////////////////////////////////////////////////////////////////////
  23. // AZ::Component Setup
  24. AZ_COMPONENT(VirtualGamepadSystemComponent, "{0FA16F21-B2A6-4057-BC0A-2D783973531E}");
  25. ////////////////////////////////////////////////////////////////////////////////////////////
  26. // AZ::ComponentDescriptor Services
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  30. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  31. ////////////////////////////////////////////////////////////////////////////////////////////
  32. //! \ref AZ::ComponentDescriptor::Reflect
  33. static void Reflect(AZ::ReflectContext* context);
  34. ////////////////////////////////////////////////////////////////////////////////////////////
  35. //! Constructor
  36. VirtualGamepadSystemComponent();
  37. protected:
  38. ////////////////////////////////////////////////////////////////////////////////////////////
  39. //! \ref AZ::Component::Init
  40. void Init() override;
  41. ////////////////////////////////////////////////////////////////////////////////////////////
  42. //! \ref AZ::Component::Activate
  43. void Activate() override;
  44. ////////////////////////////////////////////////////////////////////////////////////////////
  45. //! \ref AZ::Component::Deactivate
  46. void Deactivate() override;
  47. ////////////////////////////////////////////////////////////////////////////////////////////
  48. //! \ref VirtualGamepad::VirtualGamepadRequests::GetButtonNames
  49. const AZStd::unordered_set<AZStd::string>& GetButtonNames() const override;
  50. ////////////////////////////////////////////////////////////////////////////////////////////
  51. //! \ref VirtualGamepad::VirtualGamepadRequests::GetThumbStickNames
  52. const AZStd::unordered_set<AZStd::string>& GetThumbStickNames() const override;
  53. private:
  54. ////////////////////////////////////////////////////////////////////////////////////////////
  55. //! The list of button names made available by the virtual gamepad. These can be customized
  56. //! by editing the virtual gamepad system component, but these default values have been set
  57. //! (and are used by the provided canvas) so that the gem is able to work "out of the box".
  58. AZStd::unordered_set<AZStd::string> m_buttonNames;
  59. ////////////////////////////////////////////////////////////////////////////////////////////
  60. //! The list of thumb-stick names made available by the virtual gamepad. Can be customized
  61. //! by editing the virtual gamepad system component, but these default values have been set
  62. //! (and are used by the provided canvas) so that the gem is able to work "out of the box".
  63. AZStd::unordered_set<AZStd::string> m_thumbStickNames;
  64. ////////////////////////////////////////////////////////////////////////////////////////////
  65. //! Unique pointer to the virtual gamepad device
  66. AZStd::unique_ptr<InputDeviceVirtualGamepad> m_virtualGamepad;
  67. };
  68. } // namespace VirtualGamepad