feat(radio): optional key lock feature (#7383)
This commit is contained in:
@@ -978,7 +978,7 @@ bool BoardJson::loadDefinition()
|
||||
if (m_board == Board::BOARD_UNKNOWN)
|
||||
return true;
|
||||
|
||||
if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims, m_display, m_cfs, m_hardware))
|
||||
if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims, m_display, m_cfs, m_hardware, m_hasKeyLockCombo))
|
||||
return false;
|
||||
|
||||
afterLoadFixups(m_board, m_inputs, m_switches, m_keys, m_trims);
|
||||
@@ -1015,7 +1015,7 @@ bool BoardJson::loadDefinition()
|
||||
// static
|
||||
bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
|
||||
KeysTable * keys, TrimsTable * trims, DisplayDefn & display, CustomSwitchesDefn & cfs,
|
||||
HardwareDefn & hardware)
|
||||
HardwareDefn & hardware, bool & hasKeyLockCombo)
|
||||
{
|
||||
if (board == Board::BOARD_UNKNOWN) {
|
||||
return false;
|
||||
@@ -1202,6 +1202,9 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs
|
||||
}
|
||||
}
|
||||
|
||||
hasKeyLockCombo = obj.value("key_lock_combo").isArray() &&
|
||||
obj.value("key_lock_combo").toArray().size() == 2;
|
||||
|
||||
if (obj.value("trims").isArray()) {
|
||||
const QJsonArray &trms = obj.value("trims").toArray();
|
||||
|
||||
@@ -1315,4 +1318,4 @@ const QString BoardJson::getCapabilityStr(const Board::Capability capability) co
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ class BoardJson
|
||||
|
||||
const Board::KeyInfo getKeyInfo(int index) const;
|
||||
const int getKeyIndex(const QString key) const;
|
||||
bool hasKeyLockCombo() const { return m_hasKeyLockCombo; }
|
||||
|
||||
const int getSwitchIndex(const QString val, Board::LookupValueType lvt) const;
|
||||
const int getCFSIndexForSwitch(int sw) const;
|
||||
@@ -201,6 +202,7 @@ private:
|
||||
DisplayDefn m_display;
|
||||
CustomSwitchesDefn m_cfs;
|
||||
HardwareDefn m_hardware;
|
||||
bool m_hasKeyLockCombo = false;
|
||||
|
||||
struct InputCounts {
|
||||
unsigned int flexGyroAxes;
|
||||
@@ -226,7 +228,7 @@ private:
|
||||
|
||||
static bool loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
|
||||
KeysTable * keys, TrimsTable * trims, DisplayDefn & lcd, CustomSwitchesDefn & cfs,
|
||||
HardwareDefn & hardware);
|
||||
HardwareDefn & hardware, bool & hasKeyLockCombo);
|
||||
static void afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches,
|
||||
KeysTable * keys, TrimsTable * trims);
|
||||
|
||||
|
||||
@@ -417,6 +417,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
}
|
||||
|
||||
node["oneLogPerDay"] = (int)rhs.oneLogPerDay;
|
||||
node["keyLockEnabled"] = (int)rhs.keyLockEnabled;
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -780,6 +781,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
}
|
||||
|
||||
node["oneLogPerDay"] >> rhs.oneLogPerDay;
|
||||
node["keyLockEnabled"] >> rhs.keyLockEnabled;
|
||||
|
||||
// override critical settings after import
|
||||
// TODO: for consistency move up call stack to use existing eeprom and profile conversions
|
||||
|
||||
@@ -459,6 +459,7 @@ class GeneralSettings {
|
||||
unsigned int qmFavorites[MAX_QMFAVOURITES];
|
||||
char* qmFavoritesTools[MAX_QMFAVOURITES];
|
||||
bool oneLogPerDay;
|
||||
bool keyLockEnabled;
|
||||
|
||||
void switchConfigClear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user