aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/quantum.c79
-rw-r--r--quantum/send_string_keycodes.h10
2 files changed, 60 insertions, 29 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 52062bb17..1b5ce3292 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include <ctype.h>
17#include "quantum.h" 18#include "quantum.h"
18 19
19#ifdef PROTOCOL_LUFA 20#ifdef PROTOCOL_LUFA
@@ -374,19 +375,32 @@ void send_string_with_delay(const char *str, uint8_t interval) {
374 while (1) { 375 while (1) {
375 char ascii_code = *str; 376 char ascii_code = *str;
376 if (!ascii_code) break; 377 if (!ascii_code) break;
377 if (ascii_code == SS_TAP_CODE) { 378 if (ascii_code == SS_QMK_PREFIX) {
378 // tap 379 ascii_code = *(++str);
379 uint8_t keycode = *(++str); 380 if (ascii_code == SS_TAP_CODE) {
380 register_code(keycode); 381 // tap
381 unregister_code(keycode); 382 uint8_t keycode = *(++str);
382 } else if (ascii_code == SS_DOWN_CODE) { 383 register_code(keycode);
383 // down 384 unregister_code(keycode);
384 uint8_t keycode = *(++str); 385 } else if (ascii_code == SS_DOWN_CODE) {
385 register_code(keycode); 386 // down
386 } else if (ascii_code == SS_UP_CODE) { 387 uint8_t keycode = *(++str);
387 // up 388 register_code(keycode);
388 uint8_t keycode = *(++str); 389 } else if (ascii_code == SS_UP_CODE) {
389 unregister_code(keycode); 390 // up
391 uint8_t keycode = *(++str);
392 unregister_code(keycode);
393 } else if (ascii_code == SS_DELAY_CODE) {
394 // delay
395 int ms = 0;
396 uint8_t keycode = *(++str);
397 while (isdigit(keycode)) {
398 ms *= 10;
399 ms += keycode - '0';
400 keycode = *(++str);
401 }
402 while (ms--) wait_ms(1);
403 }
390 } else { 404 } else {
391 send_char(ascii_code); 405 send_char(ascii_code);
392 } 406 }
@@ -403,19 +417,32 @@ void send_string_with_delay_P(const char *str, uint8_t interval) {
403 while (1) { 417 while (1) {
404 char ascii_code = pgm_read_byte(str); 418 char ascii_code = pgm_read_byte(str);
405 if (!ascii_code) break; 419 if (!ascii_code) break;
406 if (ascii_code == SS_TAP_CODE) { 420 if (ascii_code == SS_QMK_PREFIX) {
407 // tap 421 ascii_code = pgm_read_byte(++str);
408 uint8_t keycode = pgm_read_byte(++str); 422 if (ascii_code == SS_TAP_CODE) {
409 register_code(keycode); 423 // tap
410 unregister_code(keycode); 424 uint8_t keycode = pgm_read_byte(++str);
411 } else if (ascii_code == SS_DOWN_CODE) { 425 register_code(keycode);
412 // down 426 unregister_code(keycode);
413 uint8_t keycode = pgm_read_byte(++str); 427 } else if (ascii_code == SS_DOWN_CODE) {
414 register_code(keycode); 428 // down
415 } else if (ascii_code == SS_UP_CODE) { 429 uint8_t keycode = pgm_read_byte(++str);
416 // up 430 register_code(keycode);
417 uint8_t keycode = pgm_read_byte(++str); 431 } else if (ascii_code == SS_UP_CODE) {
418 unregister_code(keycode); 432 // up
433 uint8_t keycode = pgm_read_byte(++str);
434 unregister_code(keycode);
435 } else if (ascii_code == SS_DELAY_CODE) {
436 // delay
437 int ms = 0;
438 uint8_t keycode = pgm_read_byte(++str);
439 while (isdigit(keycode)) {
440 ms *= 10;
441 ms += keycode - '0';
442 keycode = pgm_read_byte(++str);
443 }
444 while (ms--) wait_ms(1);
445 }
419 } else { 446 } else {
420 send_char(ascii_code); 447 send_char(ascii_code);
421 } 448 }
diff --git a/quantum/send_string_keycodes.h b/quantum/send_string_keycodes.h
index b4a50f84d..86dc8bf00 100644
--- a/quantum/send_string_keycodes.h
+++ b/quantum/send_string_keycodes.h
@@ -382,13 +382,17 @@
382#define ADD_SLASH_X(y) STRINGIZE(\x##y) 382#define ADD_SLASH_X(y) STRINGIZE(\x##y)
383#define SYMBOL_STR(x) ADD_SLASH_X(x) 383#define SYMBOL_STR(x) ADD_SLASH_X(x)
384 384
385#define SS_QMK_PREFIX 1
386
385#define SS_TAP_CODE 1 387#define SS_TAP_CODE 1
386#define SS_DOWN_CODE 2 388#define SS_DOWN_CODE 2
387#define SS_UP_CODE 3 389#define SS_UP_CODE 3
390#define SS_DELAY_CODE 4
388 391
389#define SS_TAP(keycode) "\1" SYMBOL_STR(keycode) 392#define SS_TAP(keycode) "\1\1" SYMBOL_STR(keycode)
390#define SS_DOWN(keycode) "\2" SYMBOL_STR(keycode) 393#define SS_DOWN(keycode) "\1\2" SYMBOL_STR(keycode)
391#define SS_UP(keycode) "\3" SYMBOL_STR(keycode) 394#define SS_UP(keycode) "\1\3" SYMBOL_STR(keycode)
395#define SS_DELAY(msecs) "\1\4" STRINGIZE(msecs) "|"
392 396
393// `string` arguments must not be parenthesized 397// `string` arguments must not be parenthesized
394#define SS_LCTL(string) SS_DOWN(X_LCTL) string SS_UP(X_LCTL) 398#define SS_LCTL(string) SS_DOWN(X_LCTL) string SS_UP(X_LCTL)