From 406410a7357c3f7ab8b8335cd437d73335638f4d Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 30 Mar 2017 08:57:44 +0200 Subject: [PATCH] Focus: add fingerpainter.toggle Toggles the Edit mode. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/FingerPainter.cpp | 20 +++++++++++++++++++- src/Kaleidoscope/FingerPainter.h | 3 ++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope/FingerPainter.cpp b/src/Kaleidoscope/FingerPainter.cpp index a6e54a00..2b68ee79 100644 --- a/src/Kaleidoscope/FingerPainter.cpp +++ b/src/Kaleidoscope/FingerPainter.cpp @@ -94,9 +94,27 @@ namespace KaleidoscopePlugins { bool FingerPainter::focusHook (const char *command) { - if (strcmp_P (command, PSTR ("fingerpainter.palette")) != 0) + enum { + PALETTE, + TOGGLE, + } subCommand; + + if (strncmp_P (command, PSTR ("fingerpainter."), 14) != 0) + return false; + + if (strcmp_P (command + 14, PSTR ("palette")) == 0) + subCommand = PALETTE; + else if (strcmp_P (command + 14, PSTR ("toggle")) == 0) + subCommand = TOGGLE; + else return false; + if (subCommand == TOGGLE) { + ::FingerPainter.activate (); + toggleEdit (); + return true; + } + if (Serial.peek () == '\n') { for (uint8_t i = 0; i < 16; i++) { cRGB color; diff --git a/src/Kaleidoscope/FingerPainter.h b/src/Kaleidoscope/FingerPainter.h index 9efbfda2..49bf5d6b 100644 --- a/src/Kaleidoscope/FingerPainter.h +++ b/src/Kaleidoscope/FingerPainter.h @@ -46,4 +46,5 @@ namespace KaleidoscopePlugins { extern KaleidoscopePlugins::FingerPainter FingerPainter; #define FOCUS_HOOK_FINGERPAINTER FOCUS_HOOK(FingerPainter.focusHook, \ - "fingerpainter.palette") + "fingerpainter.palette\n" \ + "fingerpainter.toggle")