Skip to content

Commit

Permalink
Merge branch 'macro-delay' into vial
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzz committed Mar 29, 2021
2 parents cfd6dd6 + 72bf921 commit cc5961f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 22 additions & 8 deletions quantum/dynamic_keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,30 @@ void dynamic_keymap_macro_send(uint8_t id) {
if (data[0] == 0) {
break;
}
// If the char is magic (tap, down, up),
// add the next char (key to use) and send a 3 char string.
if (data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE) {
data[1] = data[0];
data[0] = SS_QMK_PREFIX;
data[2] = eeprom_read_byte(p++);
if (data[2] == 0) {
if (data[0] == SS_QMK_PREFIX) {
// If the char is magic, process it as indicated by the next character
// (tap, down, up, delay)
data[1] = eeprom_read_byte(p++);
if (data[1] == 0)
break;
if (data[1] == SS_TAP_CODE || data[1] == SS_DOWN_CODE || data[1] == SS_UP_CODE) {
// For tap, down, up, just stuff it into the array and send_string it
data[2] = eeprom_read_byte(p++);
if (data[2] != 0)
send_string(data);
} else if (data[1] == SS_DELAY_CODE) {
// For delay, decode the delay and wait_ms for that amount
uint8_t d0 = eeprom_read_byte(p++);
uint8_t d1 = eeprom_read_byte(p++);
if (d0 == 0 || d1 == 0)
break;
// we cannot use 0 for these, need to subtract 1 and use 255 instead of 256 for delay calculation
int ms = (d0 - 1) + (d1 - 1) * 255;
while (ms--) wait_ms(1);
}
} else {
// If the char wasn't magic, just send it
send_string(data);
}
send_string(data);
}
}
2 changes: 1 addition & 1 deletion quantum/vial.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <inttypes.h>
#include <stdbool.h>

#define VIAL_PROTOCOL_VERSION ((uint32_t)0x00000001)
#define VIAL_PROTOCOL_VERSION ((uint32_t)0x00000002)

void vial_handle_cmd(uint8_t *data, uint8_t length);

Expand Down

0 comments on commit cc5961f

Please sign in to comment.