Fixed vector index crash in KeyboardLayoutManager

* Fixed crash when swapping key into the beginning of keymap vector
This commit is contained in:
Chris M 2023-04-05 23:15:10 +10:00
parent 1981e70830
commit 2cfa73518b

View file

@ -614,8 +614,15 @@ void KeyboardLayoutManager::SwapKey(keyboard_led swp_key)
if(strlen(swp_name) != 0)
{
LOG_DEBUG(LOG_MSG_INSERT_BEFORE, KLM_CLASS_NAME, swp_name, keymap[key_idx].name, swp_row, swp_col, KEY_EN_UNUSED);
if(key_idx == 0)
{
keymap.insert(keymap.begin(), swp_key);
}
else
{
keymap.insert(keymap.begin() + (key_idx - 1), swp_key);
}
}
break;
}
}