VirtualGamepadButtonComponent.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 "VirtualGamepadButtonRequestBus.h"
  10. #include <AzCore/Component/Component.h>
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. namespace VirtualGamepad
  13. {
  14. ////////////////////////////////////////////////////////////////////////////////////////////////
  15. class VirtualGamepadButtonComponent : public AZ::Component
  16. , public VirtualGamepadButtonRequestBus::Handler
  17. {
  18. public:
  19. ////////////////////////////////////////////////////////////////////////////////////////////
  20. // AZ::Component Setup
  21. AZ_COMPONENT(VirtualGamepadButtonComponent, "{F3B59A12-BD6F-4CEC-A151-2EBC619912C5}", AZ::Component);
  22. ////////////////////////////////////////////////////////////////////////////////////////////
  23. // AZ::ComponentDescriptor Services
  24. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  25. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  26. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  27. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  28. ////////////////////////////////////////////////////////////////////////////////////////////
  29. //! \ref AZ::ComponentDescriptor::Reflect
  30. static void Reflect(AZ::ReflectContext* context);
  31. protected:
  32. ////////////////////////////////////////////////////////////////////////////////////////////
  33. //! \ref AZ::Component::Init
  34. void Init() override;
  35. ////////////////////////////////////////////////////////////////////////////////////////////
  36. //! \ref AZ::Component::Activate
  37. void Activate() override;
  38. ////////////////////////////////////////////////////////////////////////////////////////////
  39. //! \ref AZ::Component::Deactivate
  40. void Deactivate() override;
  41. ////////////////////////////////////////////////////////////////////////////////////////////
  42. //! \ref VirtualGamepad::VirtualGamepadButtonRequests::IsPressed
  43. bool IsPressed() const override;
  44. ////////////////////////////////////////////////////////////////////////////////////////////
  45. //! Get all potentially assignable input channel names
  46. AZStd::vector<AZStd::string> GetAssignableInputChannelNames() const;
  47. private:
  48. ////////////////////////////////////////////////////////////////////////////////////////////
  49. //! The input channel that will be updated when the user interacts with this virtual control
  50. AZStd::string m_assignedInputChannelName;
  51. ////////////////////////////////////////////////////////////////////////////////////////////
  52. //! Is the interactable attached to the same component currently pressed or not?
  53. bool m_isPressed = false;
  54. };
  55. } // namespace VirtualGamepad