3
0

InputDeviceGestures.h 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 <AzFramework/Input/Devices/InputDevice.h>
  10. #include "InputChannelGesture.h"
  11. ////////////////////////////////////////////////////////////////////////////////////////////////////
  12. namespace Gestures
  13. {
  14. ////////////////////////////////////////////////////////////////////////////////////////////////
  15. //! Implementation for an input device listens for mouse and touch input, then interprets it as
  16. //! common gestures such as multi-click/tap, drag, hold, pinch, rotate, and swipe.
  17. class InputDeviceGestures : public AzFramework::InputDevice
  18. {
  19. public:
  20. ////////////////////////////////////////////////////////////////////////////////////////////
  21. //! The id used to identify the primary gestures input device
  22. static const AzFramework::InputDeviceId Id;
  23. ////////////////////////////////////////////////////////////////////////////////////////////
  24. //! Check whether an input device id identifies the gestures device (regardless of index)
  25. //! \param[in] inputDeviceId The input device id to check
  26. //! \return True if the input device id identifies the gestures device, false otherwise
  27. static bool IsGesturesDevice(const AzFramework::InputDeviceId& inputDeviceId);
  28. ////////////////////////////////////////////////////////////////////////////////////////////
  29. //! All the input channel ids that identify standard gesture input
  30. struct Gesture
  31. {
  32. static const AzFramework::InputChannelId DoublePress;
  33. static const AzFramework::InputChannelId Drag;
  34. static const AzFramework::InputChannelId Hold;
  35. static const AzFramework::InputChannelId Pinch;
  36. static const AzFramework::InputChannelId Rotate;
  37. static const AzFramework::InputChannelId Swipe;
  38. //!< All gesture channel ids
  39. static const AZStd::array<AzFramework::InputChannelId, 6> All;
  40. };
  41. ////////////////////////////////////////////////////////////////////////////////////////////
  42. // Allocator
  43. AZ_CLASS_ALLOCATOR(InputDeviceGestures, AZ::SystemAllocator);
  44. ////////////////////////////////////////////////////////////////////////////////////////////
  45. // Type Info
  46. AZ_RTTI(InputDeviceGestures, "{4E6EB405-9C01-418E-96F2-0E99A2B61C45}", InputDevice);
  47. ////////////////////////////////////////////////////////////////////////////////////////////
  48. // Reflection
  49. static void Reflect(AZ::ReflectContext* context);
  50. ////////////////////////////////////////////////////////////////////////////////////////////
  51. //! Alias for verbose container class
  52. using ConfigsByNameMap = AZStd::unordered_map<AZStd::string, InputChannelGesture::Type*>;
  53. ////////////////////////////////////////////////////////////////////////////////////////////
  54. //! Constructor
  55. //! \param[in] gestureConfigsByName Map of gesture name/config pairs used to create channels
  56. explicit InputDeviceGestures(const ConfigsByNameMap& gestureConfigsByName);
  57. InputDeviceGestures(const InputDeviceGestures&) = delete;
  58. public:
  59. ////////////////////////////////////////////////////////////////////////////////////////////
  60. //! Destructor
  61. ~InputDeviceGestures() override;
  62. ////////////////////////////////////////////////////////////////////////////////////////////
  63. //! \ref AzFramework::InputDevice::GetInputChannelsById
  64. const InputChannelByIdMap& GetInputChannelsById() const override;
  65. ////////////////////////////////////////////////////////////////////////////////////////////
  66. //! \ref AzFramework::InputDevice::IsSupported
  67. bool IsSupported() const override;
  68. ////////////////////////////////////////////////////////////////////////////////////////////
  69. //! \ref AzFramework::InputDevice::IsConnected
  70. bool IsConnected() const override;
  71. ////////////////////////////////////////////////////////////////////////////////////////////
  72. //! \ref AzFramework::InputDeviceRequests::TickInputDevice
  73. void TickInputDevice() override;
  74. private:
  75. ////////////////////////////////////////////////////////////////////////////////////////////
  76. // Variables
  77. InputChannelByIdMap m_allChannelsById; //!< All gesture input channels by id
  78. };
  79. } // namespace Gestures