Standardise KeyboardLayoutManager interface with Opcodes

* Added new KEYBOARD_OPCODE enum
* Updated `keyboard_leds` to include new opcode
* Reorganised InsertKeys and SwapKeys to work with struct change
* Changed public interfaces to only accept opcode changes
* Updated static keyboard declarations to align with new structures
This commit is contained in:
Chris M 2023-04-03 22:41:11 +10:00
parent cb447e3391
commit 1981e70830
4 changed files with 636 additions and 689 deletions

View file

@ -308,10 +308,10 @@ void DetectDebugControllers()
/*---------------------------------------------------------*\
| Check for custom key inserts and swaps |
\*---------------------------------------------------------*/
std::vector<keyboard_led> change;
if(json_kbd.contains("insert"))
{
std::vector<keyboard_led> insert;
for(size_t i = 0; i < json_kbd["insert"].size(); i++)
{
@ -322,17 +322,14 @@ void DetectDebugControllers()
key->col = json_kbd["insert"][i]["Col"];
key->value = json_kbd["insert"][i]["Val"];
key->name = json_kbd["insert"][i]["Name"].get_ref<const std::string&>().c_str();
key->opcode = KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT;
insert.push_back(*key);
change.push_back(*key);
}
new_kb.InsertKeys(insert);
new_kb.UpdateDimensions();
}
if(json_kbd.contains("swap"))
{
std::vector<keyboard_led> swap;
for(size_t i = 0; i < json_kbd["swap"].size(); i++)
{
keyboard_led* key = new keyboard_led;
@ -342,13 +339,14 @@ void DetectDebugControllers()
key->col = json_kbd["swap"][i]["Col"];
key->value = json_kbd["swap"][i]["Val"];
key->name = json_kbd["swap"][i]["Name"].get_ref<const std::string&>().c_str();
key->opcode = KEYBOARD_OPCODE_SWAP_ONLY;
swap.push_back(*key);
change.push_back(*key);
}
new_kb.SwapKeys(swap);
new_kb.UpdateDimensions();
}
new_kb.ChangeKeys(change);
dummy_keyboard->name = new_kb.GetName();
dummy_keyboard->type = DEVICE_TYPE_KEYBOARD;
dummy_keyboard->description = dummy_keyboard->name;