From 4625359a4fe05c408bfd7d555f880bd7faac5c50 Mon Sep 17 00:00:00 2001 From: Filoppi Date: Tue, 4 May 2021 23:51:58 +0300 Subject: [PATCH] InputCommon: clamp the attachment setting max to its actual enum max NumericSettings support a max, so let's use it. It might not do much now, but the max and min values will be used to give visual feeback in the UI in one of my upcoming input PRs --- Source/Core/Core/HW/WiimoteEmu/ExtensionPort.h | 2 ++ .../InputCommon/ControllerEmu/ControlGroup/Attachments.h | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/WiimoteEmu/ExtensionPort.h b/Source/Core/Core/HW/WiimoteEmu/ExtensionPort.h index 3a266bcc07..5cfa0cbbcd 100644 --- a/Source/Core/Core/HW/WiimoteEmu/ExtensionPort.h +++ b/Source/Core/Core/HW/WiimoteEmu/ExtensionPort.h @@ -22,6 +22,8 @@ enum ExtensionNumber : u8 UDRAW_TABLET, DRAWSOME_TABLET, TATACON, + + MAX }; // FYI: An extension must be attached. diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.h index f92bd8b1fd..77d44df093 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.h @@ -10,6 +10,7 @@ #include #include "Common/CommonTypes.h" +#include "Core/HW/WiimoteEmu/ExtensionPort.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" #include "InputCommon/ControllerEmu/Setting/NumericSetting.h" @@ -34,7 +35,11 @@ public: private: SettingValue m_selection_value; - NumericSetting m_selection_setting = {&m_selection_value, {""}, 0, 0, 0}; + // This is here and not added to the list of numeric_settings because it's serialized differently, + // by string (to be independent from the enum), and visualized differently in the UI. + // For the rest, it's treated similarly to other numeric_settings in the group. + NumericSetting m_selection_setting = { + &m_selection_value, {""}, 0, 0, WiimoteEmu::ExtensionNumber::MAX - 1}; std::vector> m_attachments; };