summaryrefslogtreecommitdiff
path: root/quantum/dynamic_keymap.c
diff options
context:
space:
mode:
authorWilba <wilba@wilba.tech>2022-11-10 07:46:44 +1100
committerGitHub <noreply@github.com>2022-11-10 07:46:44 +1100
commitbc6f8dc8b0822e5e03893eacffa42a7badb4c2fa (patch)
treeb1e8a219803f30b7347e479734a5c6e7352a5f30 /quantum/dynamic_keymap.c
parent575b0e33fa47034f5cfaf6f7cd98570268efa0a2 (diff)
VIA V3 - The Custom UI Update (#18222)
Diffstat (limited to 'quantum/dynamic_keymap.c')
-rw-r--r--quantum/dynamic_keymap.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index e9529ed14e..c406be4585 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -279,9 +279,8 @@ void dynamic_keymap_macro_send(uint8_t id) {
279 p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); 279 p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
280 void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); 280 void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
281 while (id > 0) { 281 while (id > 0) {
282 // If we are past the end of the buffer, then the buffer 282 // If we are past the end of the buffer, then there is
283 // contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT 283 // no Nth macro in the buffer.
284 // nulls in the buffer.
285 if (p == end) { 284 if (p == end) {
286 return; 285 return;
287 } 286 }
@@ -291,9 +290,8 @@ void dynamic_keymap_macro_send(uint8_t id) {
291 ++p; 290 ++p;
292 } 291 }
293 292
294 // Send the macro string one or three chars at a time 293 // Send the macro string by making a temporary string.
295 // by making temporary 1 or 3 char strings 294 char data[8] = {0};
296 char data[4] = {0, 0, 0, 0};
297 // We already checked there was a null at the end of 295 // We already checked there was a null at the end of
298 // the buffer, so this cannot go past the end 296 // the buffer, so this cannot go past the end
299 while (1) { 297 while (1) {
@@ -303,14 +301,44 @@ void dynamic_keymap_macro_send(uint8_t id) {
303 if (data[0] == 0) { 301 if (data[0] == 0) {
304 break; 302 break;
305 } 303 }
306 // If the char is magic (tap, down, up), 304 if (data[0] == SS_QMK_PREFIX) {
307 // add the next char (key to use) and send a 3 char string. 305 // Get the code
308 if (data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE) { 306 data[1] = eeprom_read_byte(p++);
309 data[1] = data[0]; 307 // Unexpected null, abort.
310 data[0] = SS_QMK_PREFIX; 308 if (data[1] == 0) {
311 data[2] = eeprom_read_byte(p++); 309 return;
312 if (data[2] == 0) { 310 }
313 break; 311 if (data[1] == SS_TAP_CODE || data[1] == SS_DOWN_CODE || data[1] == SS_UP_CODE) {
312 // Get the keycode
313 data[2] = eeprom_read_byte(p++);
314 // Unexpected null, abort.
315 if (data[2] == 0) {
316 return;
317 }
318 // Null terminate
319 data[3] = 0;
320 } else if (data[1] == SS_DELAY_CODE) {
321 // Get the number and '|'
322 // At most this is 4 digits plus '|'
323 uint8_t i = 2;
324 while (1) {
325 data[i] = eeprom_read_byte(p++);
326 // Unexpected null, abort
327 if (data[i] == 0) {
328 return;
329 }
330 // Found '|', send it
331 if (data[i] == '|') {
332 data[i + 1] = 0;
333 break;
334 }
335 // If haven't found '|' by i==6 then
336 // number too big, abort
337 if (i == 6) {
338 return;
339 }
340 ++i;
341 }
314 } 342 }
315 } 343 }
316 send_string_with_delay(data, DYNAMIC_KEYMAP_MACRO_DELAY); 344 send_string_with_delay(data, DYNAMIC_KEYMAP_MACRO_DELAY);