1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-23 09:16:11 +00:00

Avoid sending keys that not supported by a keyboard model

This commit is contained in:
MatMoul 2017-02-12 02:09:37 +01:00
parent e79c4e3241
commit 7765ca3591

View File

@ -266,20 +266,57 @@ bool LedKeyboard::setKeys(KeyValueArray keyValues) {
for (uint8_t i = 0; i < keyValues.size(); i++) { for (uint8_t i = 0; i < keyValues.size(); i++) {
switch(static_cast<LedKeyboard::KeyAddressGroup>(static_cast<uint16_t>(keyValues[i].key) >> 8 )) { switch(static_cast<LedKeyboard::KeyAddressGroup>(static_cast<uint16_t>(keyValues[i].key) >> 8 )) {
case LedKeyboard::KeyAddressGroup::logo: case LedKeyboard::KeyAddressGroup::logo:
switch (m_keyboardModel) {
case LedKeyboard::KeyboardModel::g410:
case LedKeyboard::KeyboardModel::g610:
case LedKeyboard::KeyboardModel::g810:
if (SortedKeys[0].size() <= 1 && keyValues[i].key == LedKeyboard::Key::logo) SortedKeys[0].push_back(keyValues[i]);
break;
case LedKeyboard::KeyboardModel::g910:
if (SortedKeys[0].size() <= 2) SortedKeys[0].push_back(keyValues[i]); if (SortedKeys[0].size() <= 2) SortedKeys[0].push_back(keyValues[i]);
break; break;
default:
break;
}
break;
case LedKeyboard::KeyAddressGroup::indicators: case LedKeyboard::KeyAddressGroup::indicators:
if (SortedKeys[1].size() <= 5) SortedKeys[1].push_back(keyValues[i]); if (SortedKeys[1].size() <= 5) SortedKeys[1].push_back(keyValues[i]);
break; break;
case LedKeyboard::KeyAddressGroup::multimedia: case LedKeyboard::KeyAddressGroup::multimedia:
switch (m_keyboardModel) {
case LedKeyboard::KeyboardModel::g610:
case LedKeyboard::KeyboardModel::g810:
if (SortedKeys[2].size() <= 5) SortedKeys[2].push_back(keyValues[i]); if (SortedKeys[2].size() <= 5) SortedKeys[2].push_back(keyValues[i]);
break; break;
default:
break;
}
break;
case LedKeyboard::KeyAddressGroup::gkeys: case LedKeyboard::KeyAddressGroup::gkeys:
switch (m_keyboardModel) {
case LedKeyboard::KeyboardModel::g910:
if (SortedKeys[3].size() <= 9) SortedKeys[3].push_back(keyValues[i]); if (SortedKeys[3].size() <= 9) SortedKeys[3].push_back(keyValues[i]);
break; break;
default:
break;
}
break;
case LedKeyboard::KeyAddressGroup::keys: case LedKeyboard::KeyAddressGroup::keys:
switch (m_keyboardModel) {
case LedKeyboard::KeyboardModel::g610:
case LedKeyboard::KeyboardModel::g810:
case LedKeyboard::KeyboardModel::g910:
if (SortedKeys[4].size() <= 120) SortedKeys[4].push_back(keyValues[i]); if (SortedKeys[4].size() <= 120) SortedKeys[4].push_back(keyValues[i]);
break; break;
case LedKeyboard::KeyboardModel::g410:
// need filter num pad for G410
// if (SortedKeys[4].size() <= 120 && keyValues[i].key > 0x07 && keyValues[i].key < 0x23) SortedKeys[4].push_back(keyValues[i]);
if (SortedKeys[4].size() <= 120) SortedKeys[4].push_back(keyValues[i]);
break;
default:
break;
}
break;
} }
} }