/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include #include #include //////////////////////////////////////////////////////////////////////////////////////////////////// namespace VirtualGamepad { //////////////////////////////////////////////////////////////////////////////////////////////// //! Implementation for a virtual gamepad input device that is controlled using a touch screen. class InputDeviceVirtualGamepad : public AzFramework::InputDevice { public: //////////////////////////////////////////////////////////////////////////////////////////// //! The id used to identify the primary virtual gamepad input device static const AzFramework::InputDeviceId Id; //////////////////////////////////////////////////////////////////////////////////////////// //! Check whether an input device id identifies a virtual gamepad (regardless of index) //! \param[in] inputDeviceId The input device id to check //! \return True if the input device id identifies a virtual gamepad, false otherwise static bool IsVirtualGamepadDevice(const AzFramework::InputDeviceId& inputDeviceId); //////////////////////////////////////////////////////////////////////////////////////////// // Allocator AZ_CLASS_ALLOCATOR(InputDeviceVirtualGamepad, AZ::SystemAllocator, 0); //////////////////////////////////////////////////////////////////////////////////////////// // Type Info AZ_RTTI(InputDeviceVirtualGamepad, "{DC4B939E-66C7-4F76-B7DF-049A3F13A1C3}", InputDevice); //////////////////////////////////////////////////////////////////////////////////////////// //! Constructor //! \param[in] buttonNames The list of button names supported by the virtual gamepad //! \param[in] thumbStickNames The list of thumbstick names supported by the virtual gamepad explicit InputDeviceVirtualGamepad(const AZStd::unordered_set& buttonNames, const AZStd::unordered_set& thumbStickNames); public: //////////////////////////////////////////////////////////////////////////////////////////// //! Destructor ~InputDeviceVirtualGamepad() override; //////////////////////////////////////////////////////////////////////////////////////////// //! \ref AzFramework::InputDevice::GetInputChannelsById const InputChannelByIdMap& GetInputChannelsById() const override; //////////////////////////////////////////////////////////////////////////////////////////// //! \ref AzFramework::InputDevice::IsSupported bool IsSupported() const override; //////////////////////////////////////////////////////////////////////////////////////////// //! \ref AzFramework::InputDevice::IsConnected bool IsConnected() const override; //////////////////////////////////////////////////////////////////////////////////////////// //! \ref AzFramework::InputDeviceRequests::TickInputDevice void TickInputDevice() override; protected: //////////////////////////////////////////////////////////////////////////////////////////// //! Create a button input channel //! \param[in] channelName The input channel name void CreateButtonChannel(const AZStd::string& channelName); //////////////////////////////////////////////////////////////////////////////////////////// //! Create a thumb-stick axis 1D input channel //! \param[in] channelName The input channel name void CreateThumbStickAxis1DChannel(const AZStd::string& channelName); //////////////////////////////////////////////////////////////////////////////////////////// //! Create a thumb-stick axis 2D input channel //! \param[in] channelName The input channel name void CreateThumbStickAxis2DChannel(const AZStd::string& channelName); //////////////////////////////////////////////////////////////////////////////////////////// //! Create a thumb-stick direction input channel //! \param[in] channelName The input channel name void CreateThumbStickDirectionChannel(const AZStd::string& channelName); private: //////////////////////////////////////////////////////////////////////////////////////////// ///@{ //! Alias for verbose container class using ButtonChannelByNameMap = AZStd::unordered_map; using ThumbStickAxis1DChannelByNameMap = AZStd::unordered_map; using ThumbStickAxis2DChannelByNameMap = AZStd::unordered_map; using ThumbStickDirectionChannelByNameMap = AZStd::unordered_map; ///@} //////////////////////////////////////////////////////////////////////////////////////////// // Variables InputChannelByIdMap m_allChannelsById; //!< All virtual input channels by id ButtonChannelByNameMap m_buttonChannelsByName; //!< All virtual button channels by id ThumbStickAxis1DChannelByNameMap m_thumbStickAxis1DChannelsByName; //!< All thumb-stick axis 1D channels by id ThumbStickAxis2DChannelByNameMap m_thumbStickAxis2DChannelsByName; //!< All thumb-stick axis 2D channels by id ThumbStickDirectionChannelByNameMap m_thumbStickDirectionChannelsByName; //!< All thumb-stick direction channels by id }; } // namespace VirtualGamepad