diff options
| -rw-r--r-- | quantum/dynamic_keymap.c | 18 | ||||
| -rw-r--r-- | quantum/quantum.c | 12 | ||||
| -rw-r--r-- | quantum/quantum.h | 4 |
3 files changed, 23 insertions, 11 deletions
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 14627a93d..38400e36f 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c | |||
| @@ -210,19 +210,27 @@ void dynamic_keymap_macro_send( uint8_t id ) | |||
| 210 | ++p; | 210 | ++p; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | // Send the macro string one char at a time | 213 | // Send the macro string one or two chars at a time |
| 214 | // by making temporary 1 char strings | 214 | // by making temporary 1 or 2 char strings |
| 215 | char data[2] = { 0, 0 }; | 215 | char data[3] = { 0, 0, 0 }; |
| 216 | // We already checked there was a null at the end of | 216 | // We already checked there was a null at the end of |
| 217 | // the buffer, so this cannot go past the end | 217 | // the buffer, so this cannot go past the end |
| 218 | while ( 1 ) { | 218 | while ( 1 ) { |
| 219 | data[0] = eeprom_read_byte(p); | 219 | data[0] = eeprom_read_byte(p++); |
| 220 | data[1] = 0; | ||
| 220 | // Stop at the null terminator of this macro string | 221 | // Stop at the null terminator of this macro string |
| 221 | if ( data[0] == 0 ) { | 222 | if ( data[0] == 0 ) { |
| 222 | break; | 223 | break; |
| 223 | } | 224 | } |
| 225 | // If the char is magic (tap, down, up), | ||
| 226 | // add the next char (key to use) and send a 2 char string. | ||
| 227 | if ( data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE ) { | ||
| 228 | data[1] = eeprom_read_byte(p++); | ||
| 229 | if ( data[1] == 0 ) { | ||
| 230 | break; | ||
| 231 | } | ||
| 232 | } | ||
| 224 | send_string(data); | 233 | send_string(data); |
| 225 | ++p; | ||
| 226 | } | 234 | } |
| 227 | } | 235 | } |
| 228 | 236 | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 48c338fc8..a62368ded 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -882,16 +882,16 @@ void send_string_with_delay(const char *str, uint8_t interval) { | |||
| 882 | while (1) { | 882 | while (1) { |
| 883 | char ascii_code = *str; | 883 | char ascii_code = *str; |
| 884 | if (!ascii_code) break; | 884 | if (!ascii_code) break; |
| 885 | if (ascii_code == 1) { | 885 | if (ascii_code == SS_TAP_CODE) { |
| 886 | // tap | 886 | // tap |
| 887 | uint8_t keycode = *(++str); | 887 | uint8_t keycode = *(++str); |
| 888 | register_code(keycode); | 888 | register_code(keycode); |
| 889 | unregister_code(keycode); | 889 | unregister_code(keycode); |
| 890 | } else if (ascii_code == 2) { | 890 | } else if (ascii_code == SS_DOWN_CODE) { |
| 891 | // down | 891 | // down |
| 892 | uint8_t keycode = *(++str); | 892 | uint8_t keycode = *(++str); |
| 893 | register_code(keycode); | 893 | register_code(keycode); |
| 894 | } else if (ascii_code == 3) { | 894 | } else if (ascii_code == SS_UP_CODE) { |
| 895 | // up | 895 | // up |
| 896 | uint8_t keycode = *(++str); | 896 | uint8_t keycode = *(++str); |
| 897 | unregister_code(keycode); | 897 | unregister_code(keycode); |
| @@ -908,16 +908,16 @@ void send_string_with_delay_P(const char *str, uint8_t interval) { | |||
| 908 | while (1) { | 908 | while (1) { |
| 909 | char ascii_code = pgm_read_byte(str); | 909 | char ascii_code = pgm_read_byte(str); |
| 910 | if (!ascii_code) break; | 910 | if (!ascii_code) break; |
| 911 | if (ascii_code == 1) { | 911 | if (ascii_code == SS_TAP_CODE) { |
| 912 | // tap | 912 | // tap |
| 913 | uint8_t keycode = pgm_read_byte(++str); | 913 | uint8_t keycode = pgm_read_byte(++str); |
| 914 | register_code(keycode); | 914 | register_code(keycode); |
| 915 | unregister_code(keycode); | 915 | unregister_code(keycode); |
| 916 | } else if (ascii_code == 2) { | 916 | } else if (ascii_code == SS_DOWN_CODE) { |
| 917 | // down | 917 | // down |
| 918 | uint8_t keycode = pgm_read_byte(++str); | 918 | uint8_t keycode = pgm_read_byte(++str); |
| 919 | register_code(keycode); | 919 | register_code(keycode); |
| 920 | } else if (ascii_code == 3) { | 920 | } else if (ascii_code == SS_UP_CODE) { |
| 921 | // up | 921 | // up |
| 922 | uint8_t keycode = pgm_read_byte(++str); | 922 | uint8_t keycode = pgm_read_byte(++str); |
| 923 | unregister_code(keycode); | 923 | unregister_code(keycode); |
diff --git a/quantum/quantum.h b/quantum/quantum.h index d0b2bedb1..c7fce9a0f 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -187,6 +187,10 @@ extern uint32_t default_layer_state; | |||
| 187 | #define ADD_SLASH_X(y) STRINGIZE(\x ## y) | 187 | #define ADD_SLASH_X(y) STRINGIZE(\x ## y) |
| 188 | #define SYMBOL_STR(x) ADD_SLASH_X(x) | 188 | #define SYMBOL_STR(x) ADD_SLASH_X(x) |
| 189 | 189 | ||
| 190 | #define SS_TAP_CODE 1 | ||
| 191 | #define SS_DOWN_CODE 2 | ||
| 192 | #define SS_UP_CODE 3 | ||
| 193 | |||
| 190 | #define SS_TAP(keycode) "\1" SYMBOL_STR(keycode) | 194 | #define SS_TAP(keycode) "\1" SYMBOL_STR(keycode) |
| 191 | #define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode) | 195 | #define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode) |
| 192 | #define SS_UP(keycode) "\3" SYMBOL_STR(keycode) | 196 | #define SS_UP(keycode) "\3" SYMBOL_STR(keycode) |
