From 306e4504968d2221dd45e31bacb9e706891bad13 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 16 Jun 2017 08:55:37 +0200 Subject: [PATCH] Make the .type method return MACRO_NONE This way it can be used in place of a `return MACRO(...)` construct. Signed-off-by: Gergely Nagy --- README.md | 2 +- src/Kaleidoscope-Macros.cpp | 4 +++- src/Kaleidoscope-Macros.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9462f369..b2944447 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { T(0), T(1) ); case MACRO_HELLO: if (keyToggledOn(keyState)) { - Macros.type(PSTR("Hello world!")); + return Macros.type(PSTR("Hello world!")); } break; case MACRO_SPECIAL: diff --git a/src/Kaleidoscope-Macros.cpp b/src/Kaleidoscope-Macros.cpp index 7a1ad506..72a4155d 100644 --- a/src/Kaleidoscope-Macros.cpp +++ b/src/Kaleidoscope-Macros.cpp @@ -161,7 +161,7 @@ Key Macros_::lookupAsciiCode(uint8_t ascii_code) { return key; } -void Macros_::type(const char *string) { +const macro_t *Macros_::type(const char *string) { while (true) { uint8_t ascii_code = pgm_read_byte(string++); if (!ascii_code) @@ -177,6 +177,8 @@ void Macros_::type(const char *string) { playMacroKeyswitchEvent(key, WAS_PRESSED); } + + return MACRO_NONE; } static Key handleMacroEvent(Key mappedKey, byte row, byte col, uint8_t keyState) { diff --git a/src/Kaleidoscope-Macros.h b/src/Kaleidoscope-Macros.h index 91a2ace8..7693dbdb 100644 --- a/src/Kaleidoscope-Macros.h +++ b/src/Kaleidoscope-Macros.h @@ -14,7 +14,7 @@ class Macros_ : public KaleidoscopePlugin { void begin(void) final; void play(const macro_t *macro_p); - void type(const char *string); + const macro_t *type(const char *string); static byte row, col;