Add extended TiltModel

This commit is contained in:
jpirnay
2026-05-11 16:29:40 +02:00
parent e035e4584b
commit 2b1dbb6737
17 changed files with 545 additions and 28 deletions
@@ -30,18 +30,13 @@ constexpr std::array<ButtonRow, 7> kButtonRows = {{
}};
// Find the SettingInfo for a given (button submenu, press kind) pair in the shared settings list.
const SettingInfo* findEntry(StrId submenu, StrId pressKind) {
const auto& list = getSettingsList();
std::string cellValue(StrId submenu, StrId pressKind) {
const auto list = getSettingsList();
auto it = std::find_if(list.begin(), list.end(), [submenu, pressKind](const SettingInfo& s) {
return s.submenu == submenu && s.nameId == pressKind && s.category == StrId::STR_CAT_CONTROLS;
});
return it != list.end() ? &*it : nullptr;
}
std::string cellValue(StrId submenu, StrId pressKind) {
const SettingInfo* s = findEntry(submenu, pressKind);
if (!s) return {};
return s->getDisplayValue();
if (it == list.end()) return {};
return it->getDisplayValue();
}
} // namespace
+10
View File
@@ -11,6 +11,8 @@
enum class SettingType { TOGGLE, ENUM, ACTION, VALUE, STRING };
enum class SettingDeviceTarget { BOTH, X3, X4 };
enum class SettingAction {
None,
RemapFrontButtons,
@@ -56,6 +58,7 @@ struct SettingInfo {
const char* key = nullptr; // JSON API key (nullptr for ACTION types)
StrId category = StrId::STR_NONE_OPT; // Category for web UI grouping
bool obfuscated = false; // Save/load via base64 obfuscation (passwords)
SettingDeviceTarget deviceTarget = SettingDeviceTarget::BOTH;
// Direct char[] string fields (for settings stored in CrossPointSettings)
size_t stringOffset = 0;
@@ -234,6 +237,13 @@ struct SettingInfo {
return *this;
}
// Restrict visibility of this setting to a specific hardware target.
// Default is BOTH when this method is not used.
SettingInfo& withDeviceTarget(SettingDeviceTarget target) {
deviceTarget = target;
return *this;
}
// For internal use by SettingsActivity: placeholder entry that launches the submenu.
static SettingInfo SubmenuEntry(StrId titleId) {
SettingInfo s;
+1 -1
View File
@@ -54,7 +54,7 @@ void SettingsActivity::onEnter() {
}
vec.push_back(s);
};
auto addToMoved = [](std::vector<SettingInfo>& vec, StrId& lastSub, SettingInfo&& s) {
auto addToMoved = [](std::vector<SettingInfo>& vec, StrId& lastSub, SettingInfo s) {
if (s.subcategory != StrId::STR_NONE_OPT && s.subcategory != lastSub) {
vec.push_back(SettingInfo::Separator(s.subcategory));
lastSub = s.subcategory;