diff --git a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp index 496d89d767..ef39e50cb8 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.cpp @@ -27,28 +27,4 @@ namespace AzFramework ; } } - - //////////////////////////////////////////////////////////////////////////////////////////////// - const char* InputChannelId::GetName() const - { - return m_name.c_str(); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - const AZ::Crc32& InputChannelId::GetNameCrc32() const - { - return m_crc32; - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - bool InputChannelId::operator==(const InputChannelId& other) const - { - return (m_crc32 == other.m_crc32); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - bool InputChannelId::operator!=(const InputChannelId& other) const - { - return !(*this == other); - } } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h index a4d8ac83eb..62d79285f5 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Channels/InputChannelId.h @@ -39,53 +39,58 @@ namespace AzFramework //////////////////////////////////////////////////////////////////////////////////////////// //! Constructor - //! \param[in] name Name of the input channel (will be ignored if exceeds MAX_NAME_LENGTH) + //! \param[in] name Name of the input channel (will be truncated if exceeds MAX_NAME_LENGTH) explicit constexpr InputChannelId(AZStd::string_view name = "") - : m_name(name) - , m_crc32(name) + : m_name(name.substr(0, MAX_NAME_LENGTH)) + , m_crc32(name.substr(0, MAX_NAME_LENGTH)) { } - constexpr InputChannelId(const InputChannelId& other) = default; - constexpr InputChannelId(InputChannelId&& other) = default; - constexpr InputChannelId& operator=(const InputChannelId& other) - { - m_name = other.m_name; - m_crc32 = other.m_crc32; - return *this; - } - constexpr InputChannelId& operator=(InputChannelId&& other) - { - m_name = AZStd::move(other.m_name); - m_crc32 = AZStd::move(other.m_crc32); - other.m_crc32 = 0; - return *this; - } + //////////////////////////////////////////////////////////////////////////////////////////// + // Default copying and moving + AZ_DEFAULT_COPY_MOVE(InputChannelId); + + //////////////////////////////////////////////////////////////////////////////////////////// + //! Default destructor ~InputChannelId() = default; //////////////////////////////////////////////////////////////////////////////////////////// //! Access to the input channel's name //! \return Name of the input channel - const char* GetName() const; + constexpr const char* GetName() const + { + return m_name.c_str(); + } //////////////////////////////////////////////////////////////////////////////////////////// //! Access to the crc32 of the input channel's name //! \return crc32 of the input channel name - const AZ::Crc32& GetNameCrc32() const; + constexpr const AZ::Crc32& GetNameCrc32() const + { + return m_crc32; + } //////////////////////////////////////////////////////////////////////////////////////////// - ///@{ //! Equality comparison operator //! \param[in] other Another instance of the class to compare for equality - bool operator==(const InputChannelId& other) const; - bool operator!=(const InputChannelId& other) const; - ///@} + constexpr bool operator==(const InputChannelId& other) const + { + return m_crc32 == other.m_crc32; + } + + //////////////////////////////////////////////////////////////////////////////////////////// + //! Inequality comparison operator + //! \param[in] other Another instance of the class to compare for inequality + constexpr bool operator!=(const InputChannelId& other) const + { + return !(*this == other); + } private: //////////////////////////////////////////////////////////////////////////////////////////// // Variables AZStd::fixed_string m_name; //!< Name of the input channel - AZ::Crc32 m_crc32; //!< Crc32 of the input channel + AZ::Crc32 m_crc32; //!< Crc32 of the input channel name }; } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp index 9759a95733..c7629c7afb 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.cpp @@ -14,14 +14,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// namespace AzFramework { - //////////////////////////////////////////////////////////////////////////////////////////////// - const char* InputDeviceGamepad::Name("gamepad"); - const InputDeviceId InputDeviceGamepad::IdForIndex0(Name, 0); - const InputDeviceId InputDeviceGamepad::IdForIndex1(Name, 1); - const InputDeviceId InputDeviceGamepad::IdForIndex2(Name, 2); - const InputDeviceId InputDeviceGamepad::IdForIndex3(Name, 3); - const InputDeviceId InputDeviceGamepad::IdForIndexN(AZ::u32 n) { return InputDeviceId(Name, n); } - //////////////////////////////////////////////////////////////////////////////////////////////// bool InputDeviceGamepad::IsGamepadDevice(const InputDeviceId& inputDeviceId) { diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h index 7be498830b..b143709621 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Gamepad/InputDeviceGamepad.h @@ -32,16 +32,16 @@ namespace AzFramework public: //////////////////////////////////////////////////////////////////////////////////////////// //! The name used to identify any game-pad input device - static const char* Name; + static constexpr inline const char* Name{"gamepad"}; //////////////////////////////////////////////////////////////////////////////////////////// //! The id used to identify a game-pad input device with a specific index ///@{ - static const InputDeviceId IdForIndex0; - static const InputDeviceId IdForIndex1; - static const InputDeviceId IdForIndex2; - static const InputDeviceId IdForIndex3; - static const InputDeviceId IdForIndexN(AZ::u32 n); + static constexpr inline InputDeviceId IdForIndex0{Name, 0}; + static constexpr inline InputDeviceId IdForIndex1{Name, 1}; + static constexpr inline InputDeviceId IdForIndex2{Name, 2}; + static constexpr inline InputDeviceId IdForIndex3{Name, 3}; + static constexpr inline InputDeviceId IdForIndexN(AZ::u32 n) { return InputDeviceId(Name, n); } ///@} //////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.cpp index fa0955bd16..7f9a0039ac 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.cpp @@ -29,71 +29,4 @@ namespace AzFramework ; } } - - //////////////////////////////////////////////////////////////////////////////////////////////// - InputDeviceId::InputDeviceId(const char* name, AZ::u32 index) - : m_crc32(name) - , m_index(index) - { - memset(m_name, 0, AZ_ARRAY_SIZE(m_name)); - azstrncpy(m_name, NAME_BUFFER_SIZE, name, MAX_NAME_LENGTH); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - InputDeviceId::InputDeviceId(const InputDeviceId& other) - : m_crc32(other.m_crc32) - , m_index(other.m_index) - { - memset(m_name, 0, AZ_ARRAY_SIZE(m_name)); - azstrcpy(m_name, NAME_BUFFER_SIZE, other.m_name); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - InputDeviceId& InputDeviceId::operator=(const InputDeviceId& other) - { - azstrcpy(m_name, NAME_BUFFER_SIZE, other.m_name); - m_crc32 = other.m_crc32; - m_index = other.m_index; - return *this; - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - const char* InputDeviceId::GetName() const - { - return m_name; - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - const AZ::Crc32& InputDeviceId::GetNameCrc32() const - { - return m_crc32; - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - AZ::u32 InputDeviceId::GetIndex() const - { - return m_index; - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - bool InputDeviceId::operator==(const InputDeviceId& other) const - { - return (m_crc32 == other.m_crc32) && (m_index == other.m_index); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - bool InputDeviceId::operator!=(const InputDeviceId& other) const - { - return !(*this == other); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - bool InputDeviceId::operator<(const InputDeviceId& other) const - { - if (m_index == other.m_index) - { - return m_crc32 < other.m_crc32; - } - return m_index < other.m_index; - } } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.h index 6d2aa8b9fd..ffc1745c3b 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/InputDeviceId.h @@ -11,6 +11,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////////////////////////////////// namespace AzFramework @@ -22,8 +23,7 @@ namespace AzFramework public: //////////////////////////////////////////////////////////////////////////////////////////// // Constants - static const int NAME_BUFFER_SIZE = 64; - static const int MAX_NAME_LENGTH = NAME_BUFFER_SIZE - 1; + static constexpr int MAX_NAME_LENGTH = 64; //////////////////////////////////////////////////////////////////////////////////////////// // Allocator @@ -41,17 +41,16 @@ namespace AzFramework //! Constructor //! \param[in] name Name of the input device (will be truncated if exceeds MAX_NAME_LENGTH) //! \param[in] index Index of the input device (optional) - explicit InputDeviceId(const char* name, AZ::u32 index = 0); - - //////////////////////////////////////////////////////////////////////////////////////////// - //! Copy constructor - //! \param[in] other Another instance of the class to copy from - InputDeviceId(const InputDeviceId& other); + explicit constexpr InputDeviceId(AZStd::string_view name, AZ::u32 index = 0) + : m_name(name.substr(0, MAX_NAME_LENGTH)) + , m_crc32(name.substr(0, MAX_NAME_LENGTH)) + , m_index(index) + { + } //////////////////////////////////////////////////////////////////////////////////////////// - //! Copy assignment operator - //! \param[in] other Another instance of the class to copy from - InputDeviceId& operator=(const InputDeviceId& other); + // Default copying and moving + AZ_DEFAULT_COPY_MOVE(InputDeviceId); //////////////////////////////////////////////////////////////////////////////////////////// //! Default destructor @@ -60,12 +59,18 @@ namespace AzFramework //////////////////////////////////////////////////////////////////////////////////////////// //! Access to the input device's name //! \return Name of the input device - const char* GetName() const; + constexpr const char* GetName() const + { + return m_name.c_str(); + } //////////////////////////////////////////////////////////////////////////////////////////// //! Access to the crc32 of the input device's name //! \return crc32 of the input device name - const AZ::Crc32& GetNameCrc32() const; + constexpr const AZ::Crc32& GetNameCrc32() const + { + return m_crc32; + } //////////////////////////////////////////////////////////////////////////////////////////// //! Access to the input device's index. Used for differentiating between multiple instances @@ -75,27 +80,45 @@ namespace AzFramework //! at startup using indicies 0->3. As gamepads connect/disconnect at runtime we assign the //! appropriate (system dependent) local user id (see InputDevice::GetAssignedLocalUserId). //! \return Index of the input device - AZ::u32 GetIndex() const; + constexpr AZ::u32 GetIndex() const + { + return m_index; + } //////////////////////////////////////////////////////////////////////////////////////////// - ///@{ //! Equality comparison operator //! \param[in] other Another instance of the class to compare for equality - bool operator==(const InputDeviceId& other) const; - bool operator!=(const InputDeviceId& other) const; - ///@} + constexpr bool operator==(const InputDeviceId& other) const + { + return (m_crc32 == other.m_crc32) && (m_index == other.m_index); + } + + //////////////////////////////////////////////////////////////////////////////////////////// + //! Inequality comparison operator + //! \param[in] other Another instance of the class to compare for inequality + constexpr bool operator!=(const InputDeviceId& other) const + { + return !(*this == other); + } //////////////////////////////////////////////////////////////////////////////////////////// //! Less than comparison operator //! \param[in] other Another instance of the class to compare - bool operator<(const InputDeviceId& other) const; + constexpr bool operator<(const InputDeviceId& other) const + { + if (m_index == other.m_index) + { + return m_crc32 < other.m_crc32; + } + return m_index < other.m_index; + } private: //////////////////////////////////////////////////////////////////////////////////////////// // Variables - char m_name[NAME_BUFFER_SIZE]; //!< Name of the input device - AZ::Crc32 m_crc32; //!< Crc32 of the input device - AZ::u32 m_index; //!< Index of the input device + AZStd::fixed_string m_name; //!< Name of the input device + AZ::Crc32 m_crc32; //!< Crc32 of the input device name + AZ::u32 m_index; //!< Index of the input device }; } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp index 2a76cc6e1b..08674ea92f 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.cpp @@ -15,9 +15,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// namespace AzFramework { - //////////////////////////////////////////////////////////////////////////////////////////////// - const InputDeviceId InputDeviceKeyboard::Id("keyboard"); - //////////////////////////////////////////////////////////////////////////////////////////////// bool InputDeviceKeyboard::IsKeyboardDevice(const InputDeviceId& inputDeviceId) { diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h index c0c2f5d92b..f8300eefdf 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard.h @@ -33,7 +33,7 @@ namespace AzFramework public: //////////////////////////////////////////////////////////////////////////////////////////// //! The id used to identify the primary physical keyboard input device - static const InputDeviceId Id; + static constexpr inline InputDeviceId Id{"keyboard"}; //////////////////////////////////////////////////////////////////////////////////////////// //! Check whether an input device id identifies a physical keyboard (regardless of index) diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp index d4057bc5d3..fec51349c9 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.cpp @@ -14,9 +14,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// namespace AzFramework { - //////////////////////////////////////////////////////////////////////////////////////////////// - const InputDeviceId InputDeviceMotion::Id("motion"); - //////////////////////////////////////////////////////////////////////////////////////////////// bool InputDeviceMotion::IsMotionDevice(const InputDeviceId& inputDeviceId) { diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h index f0fc976963..14783e01ca 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Motion/InputDeviceMotion.h @@ -28,7 +28,7 @@ namespace AzFramework public: //////////////////////////////////////////////////////////////////////////////////////////// //! The id used to identify the primary motion input device - static const InputDeviceId Id; + static constexpr inline InputDeviceId Id{"motion"}; //////////////////////////////////////////////////////////////////////////////////////////// //! Check whether an input device id identifies a motion device (regardless of index) diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp index 39504d9352..d869fa1f83 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.cpp @@ -15,18 +15,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// namespace AzFramework { - //////////////////////////////////////////////////////////////////////////////////////////////// - const AZ::u32 InputDeviceMouse::MovementSampleRateDefault = 60; - - //////////////////////////////////////////////////////////////////////////////////////////////// - const AZ::u32 InputDeviceMouse::MovementSampleRateQueueAll = std::numeric_limits::max(); - - //////////////////////////////////////////////////////////////////////////////////////////////// - const AZ::u32 InputDeviceMouse::MovementSampleRateAccumulateAll = 0; - - //////////////////////////////////////////////////////////////////////////////////////////////// - const InputDeviceId InputDeviceMouse::Id("mouse"); - //////////////////////////////////////////////////////////////////////////////////////////////// bool InputDeviceMouse::IsMouseDevice(const InputDeviceId& inputDeviceId) { diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h index 3c519a3edb..8ad2088d2b 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Mouse/InputDeviceMouse.h @@ -31,23 +31,23 @@ namespace AzFramework //////////////////////////////////////////////////////////////////////////////////////////// //! Default sample rate for raw mouse movement events that aims to strike a balance between //! responsiveness and performance. - static const AZ::u32 MovementSampleRateDefault; + static constexpr inline AZ::u32 MovementSampleRateDefault{60}; //////////////////////////////////////////////////////////////////////////////////////////// //! Sample rate for raw mouse movement that will cause all events received in the same frame //! to be queued and dispatched as individual events. This results in maximum responsiveness //! but may potentially impact performance depending how many events happen over each frame. - static const AZ::u32 MovementSampleRateQueueAll; + static constexpr inline AZ::u32 MovementSampleRateQueueAll{std::numeric_limits::max()}; //////////////////////////////////////////////////////////////////////////////////////////// //! Sample rate for raw mouse movement that will cause all events received in the same frame //! to be accumulated and dispatched as a single event. Optimal for performance, but results //! in sluggish/unresponsive mouse movement, especially when running at low frame rates. - static const AZ::u32 MovementSampleRateAccumulateAll; + static constexpr inline AZ::u32 MovementSampleRateAccumulateAll{0}; //////////////////////////////////////////////////////////////////////////////////////////// //! The id used to identify the primary mouse input device - static const InputDeviceId Id; + static constexpr inline InputDeviceId Id{"mouse"}; //////////////////////////////////////////////////////////////////////////////////////////// //! Check whether an input device id identifies a mouse (regardless of index) diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp index 2695e3bb08..395ebcecb5 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.cpp @@ -15,9 +15,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// namespace AzFramework { - //////////////////////////////////////////////////////////////////////////////////////////////// - const InputDeviceId InputDeviceTouch::Id("touch"); - //////////////////////////////////////////////////////////////////////////////////////////////// bool InputDeviceTouch::IsTouchDevice(const InputDeviceId& inputDeviceId) { diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h index 12b8aded4b..6e5e0c7ca9 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/Touch/InputDeviceTouch.h @@ -25,7 +25,7 @@ namespace AzFramework public: //////////////////////////////////////////////////////////////////////////////////////////// //! The id used to identify the primary touch input device - static const InputDeviceId Id; + static constexpr inline InputDeviceId Id{"touch"}; //////////////////////////////////////////////////////////////////////////////////////////// //! Check whether an input device id identifies a touch device (regardless of index) diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp index bcbdeaa478..5cfc4ea480 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.cpp @@ -14,9 +14,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// namespace AzFramework { - //////////////////////////////////////////////////////////////////////////////////////////////// - const InputDeviceId InputDeviceVirtualKeyboard::Id("virtual_keyboard"); - //////////////////////////////////////////////////////////////////////////////////////////////// bool InputDeviceVirtualKeyboard::IsVirtualKeyboardDevice(const InputDeviceId& inputDeviceId) { diff --git a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h index abe1312733..c9f6286128 100644 --- a/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h +++ b/Code/Framework/AzFramework/AzFramework/Input/Devices/VirtualKeyboard/InputDeviceVirtualKeyboard.h @@ -25,7 +25,7 @@ namespace AzFramework public: //////////////////////////////////////////////////////////////////////////////////////////// //! The id used to identify the primary virtual keyboard input device - static const InputDeviceId Id; + static constexpr inline InputDeviceId Id{"virtual_keyboard"}; //////////////////////////////////////////////////////////////////////////////////////////// //! Check whether an input device id identifies a virtual keyboard (regardless of index) diff --git a/Code/Framework/AzFramework/Tests/InputTests.cpp b/Code/Framework/AzFramework/Tests/InputTests.cpp index 9942912622..5fba7f5796 100644 --- a/Code/Framework/AzFramework/Tests/InputTests.cpp +++ b/Code/Framework/AzFramework/Tests/InputTests.cpp @@ -48,6 +48,24 @@ namespace InputUnitTests AZStd::unique_ptr m_inputSystemComponent; }; + //////////////////////////////////////////////////////////////////////////////////////////////// + TEST_F(InputTest, InputChannelId_ConstExpression_CopyConstructorSuccessfull) + { + constexpr InputChannelId testInputChannelId1("TestInputChannelId"); + constexpr InputChannelId testInputChannelId2(testInputChannelId1); + static_assert(testInputChannelId1 == testInputChannelId2); + EXPECT_EQ(testInputChannelId1, testInputChannelId2); + } + + //////////////////////////////////////////////////////////////////////////////////////////////// + TEST_F(InputTest, InputDeviceId_ConstExpression_CopyConstructorSuccessfull) + { + constexpr InputDeviceId testInputDeviceId1("TestInputDeviceId"); + constexpr InputDeviceId testInputDeviceId2(testInputDeviceId1); + static_assert(testInputDeviceId1 == testInputDeviceId2); + EXPECT_EQ(testInputDeviceId1, testInputDeviceId2); + } + //////////////////////////////////////////////////////////////////////////////////////////////// TEST_F(InputTest, InputContext_InitWithDataStruct_InitializationSuccessfull) {