Skip to content

Commit 1996d34

Browse files
committed
Updated Debug Keyboard to process KLM Opcodes
* Added InsertRow, RemoveRow and RemoveKey opcodes. * Adjusted iterator for style and formatting.
1 parent ccb20f3 commit 1996d34

File tree

1 file changed

+42
-26
lines changed

1 file changed

+42
-26
lines changed

Controllers/DebugController/DebugControllerDetect.cpp

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -309,37 +309,53 @@ void DetectDebugControllers()
309309
| Check for custom key inserts and swaps |
310310
\*---------------------------------------------------------*/
311311
std::vector<keyboard_led> change;
312-
313-
if(json_kbd.contains("insert"))
312+
const char* change_keys = "change_keys";
313+
314+
const char* ins_key = "ins_key";
315+
const char* ins_row = "ins_row";
316+
const char* rmv_key = "rmv_key";
317+
const char* rmv_row = "rmv_row";
318+
const char* swp_key = "swp_key";
319+
320+
const char* dbg_zone = "Zone";
321+
const char* dbg_row = "Row";
322+
const char* dbg_col = "Col";
323+
const char* dbg_val = "Val";
324+
const char* dbg_name = "Name";
325+
const char* dbg_opcode = "Opcode";
326+
327+
if(json_kbd.contains(change_keys))
314328
{
315-
316-
for(size_t i = 0; i < json_kbd["insert"].size(); i++)
329+
for(size_t i = 0; i < json_kbd[change_keys].size(); i++)
317330
{
318331
keyboard_led* key = new keyboard_led;
319332

320-
key->zone = json_kbd["insert"][i]["Zone"];
321-
key->row = json_kbd["insert"][i]["Row"];
322-
key->col = json_kbd["insert"][i]["Col"];
323-
key->value = json_kbd["insert"][i]["Val"];
324-
key->name = json_kbd["insert"][i]["Name"].get_ref<const std::string&>().c_str();
325-
key->opcode = KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT;
326-
327-
change.push_back(*key);
328-
}
329-
}
330-
331-
if(json_kbd.contains("swap"))
332-
{
333-
for(size_t i = 0; i < json_kbd["swap"].size(); i++)
334-
{
335-
keyboard_led* key = new keyboard_led;
333+
key->zone = json_kbd[change_keys][i][dbg_zone];
334+
key->row = json_kbd[change_keys][i][dbg_row];
335+
key->col = json_kbd[change_keys][i][dbg_col];
336+
key->value = json_kbd[change_keys][i][dbg_val];
337+
key->name = json_kbd[change_keys][i][dbg_name].get_ref<const std::string&>().c_str();
336338

337-
key->zone = json_kbd["swap"][i]["Zone"];
338-
key->row = json_kbd["swap"][i]["Row"];
339-
key->col = json_kbd["swap"][i]["Col"];
340-
key->value = json_kbd["swap"][i]["Val"];
341-
key->name = json_kbd["swap"][i]["Name"].get_ref<const std::string&>().c_str();
342-
key->opcode = KEYBOARD_OPCODE_SWAP_ONLY;
339+
if(json_kbd[change_keys][i][dbg_opcode] == ins_row)
340+
{
341+
key->opcode = KEYBOARD_OPCODE_INSERT_ROW;
342+
}
343+
else if(json_kbd[change_keys][i][dbg_opcode] == rmv_key)
344+
{
345+
key->opcode = KEYBOARD_OPCODE_REMOVE_SHIFT_LEFT;
346+
}
347+
else if(json_kbd[change_keys][i][dbg_opcode] == rmv_row)
348+
{
349+
key->opcode = KEYBOARD_OPCODE_REMOVE_ROW;
350+
}
351+
else if(json_kbd[change_keys][i][dbg_opcode] == swp_key)
352+
{
353+
key->opcode = KEYBOARD_OPCODE_SWAP_ONLY;
354+
}
355+
else
356+
{
357+
key->opcode = KEYBOARD_OPCODE_INSERT_SHIFT_RIGHT;
358+
}
343359

344360
change.push_back(*key);
345361
}

0 commit comments

Comments
 (0)