summaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c79
1 files changed, 53 insertions, 26 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 52062bb174..1b5ce3292c 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <ctype.h>
#include "quantum.h"
#ifdef PROTOCOL_LUFA
@@ -374,19 +375,32 @@ void send_string_with_delay(const char *str, uint8_t interval) {
while (1) {
char ascii_code = *str;
if (!ascii_code) break;
- if (ascii_code == SS_TAP_CODE) {
- // tap
- uint8_t keycode = *(++str);
- register_code(keycode);
- unregister_code(keycode);
- } else if (ascii_code == SS_DOWN_CODE) {
- // down
- uint8_t keycode = *(++str);
- register_code(keycode);
- } else if (ascii_code == SS_UP_CODE) {
- // up
- uint8_t keycode = *(++str);
- unregister_code(keycode);
+ if (ascii_code == SS_QMK_PREFIX) {
+ ascii_code = *(++str);
+ if (ascii_code == SS_TAP_CODE) {
+ // tap
+ uint8_t keycode = *(++str);
+ register_code(keycode);
+ unregister_code(keycode);
+ } else if (ascii_code == SS_DOWN_CODE) {
+ // down
+ uint8_t keycode = *(++str);
+ register_code(keycode);
+ } else if (ascii_code == SS_UP_CODE) {
+ // up
+ uint8_t keycode = *(++str);
+ unregister_code(keycode);
+ } else if (ascii_code == SS_DELAY_CODE) {
+ // delay
+ int ms = 0;
+ uint8_t keycode = *(++str);
+ while (isdigit(keycode)) {
+ ms *= 10;
+ ms += keycode - '0';
+ keycode = *(++str);
+ }
+ while (ms--) wait_ms(1);
+ }
} else {
send_char(ascii_code);
}
@@ -403,19 +417,32 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
while (1) {
char ascii_code = pgm_read_byte(str);
if (!ascii_code) break;
- if (ascii_code == SS_TAP_CODE) {
- // tap
- uint8_t keycode = pgm_read_byte(++str);
- register_code(keycode);
- unregister_code(keycode);
- } else if (ascii_code == SS_DOWN_CODE) {
- // down
- uint8_t keycode = pgm_read_byte(++str);
- register_code(keycode);
- } else if (ascii_code == SS_UP_CODE) {
- // up
- uint8_t keycode = pgm_read_byte(++str);
- unregister_code(keycode);
+ if (ascii_code == SS_QMK_PREFIX) {
+ ascii_code = pgm_read_byte(++str);
+ if (ascii_code == SS_TAP_CODE) {
+ // tap
+ uint8_t keycode = pgm_read_byte(++str);
+ register_code(keycode);
+ unregister_code(keycode);
+ } else if (ascii_code == SS_DOWN_CODE) {
+ // down
+ uint8_t keycode = pgm_read_byte(++str);
+ register_code(keycode);
+ } else if (ascii_code == SS_UP_CODE) {
+ // up
+ uint8_t keycode = pgm_read_byte(++str);
+ unregister_code(keycode);
+ } else if (ascii_code == SS_DELAY_CODE) {
+ // delay
+ int ms = 0;
+ uint8_t keycode = pgm_read_byte(++str);
+ while (isdigit(keycode)) {
+ ms *= 10;
+ ms += keycode - '0';
+ keycode = pgm_read_byte(++str);
+ }
+ while (ms--) wait_ms(1);
+ }
} else {
send_char(ascii_code);
}