@@ -309,37 +309,53 @@ void DetectDebugControllers()
309
309
| Check for custom key inserts and swaps |
310
310
\*---------------------------------------------------------*/
311
311
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))
314
328
{
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++)
317
330
{
318
331
keyboard_led* key = new keyboard_led;
319
332
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 ();
336
338
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
+ }
343
359
344
360
change.push_back (*key);
345
361
}
0 commit comments