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
This commit is contained in:
Filoppi 2021-05-04 23:51:58 +03:00
parent f4fec42165
commit 4625359a4f
2 changed files with 8 additions and 1 deletions
Source/Core
Core/HW/WiimoteEmu
InputCommon/ControllerEmu/ControlGroup

@ -22,6 +22,8 @@ enum ExtensionNumber : u8
UDRAW_TABLET,
DRAWSOME_TABLET,
TATACON,
MAX
};
// FYI: An extension must be attached.

@ -10,6 +10,7 @@
#include <vector>
#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<int> m_selection_value;
NumericSetting<int> 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<int> m_selection_setting = {
&m_selection_value, {""}, 0, 0, WiimoteEmu::ExtensionNumber::MAX - 1};
std::vector<std::unique_ptr<EmulatedController>> m_attachments;
};