From 523cb38ff54ba43d1e84652109444bb515d16696 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 4 Jun 2017 12:30:15 +0200 Subject: [PATCH] Kaleidoscope Style Guide conformance Signed-off-by: Gergely Nagy --- README.md | 10 ++++---- examples/Escape-OneShot/Escape-OneShot.ino | 4 ++-- src/Kaleidoscope/Escape-OneShot.cpp | 27 +++++++++++----------- src/Kaleidoscope/Escape-OneShot.h | 10 ++++---- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 85bab8e8..a6662213 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-Escape-OneShot.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-Escape-OneShot - [st:stable]: https://img.shields.io/badge/stable-✔-black.png?style=flat&colorA=44cc11&colorB=494e52 - [st:broken]: https://img.shields.io/badge/broken-X-black.png?style=flat&colorA=e05d44&colorB=494e52 - [st:experimental]: https://img.shields.io/badge/experimental----black.png?style=flat&colorA=dfb317&colorB=494e52 + [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 + [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 + [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 Turn the `Esc` key into a special key, that can cancel any active `OneShot` effect - or act as the normal `Esc` key if none are active. For those times when @@ -24,9 +24,9 @@ configuration is necessary. #include void setup () { - Kaleidoscope.setup (KEYMAP_SIZE); + USE_PLUGINS(&OneShot, &EscapeOneShot); - Kaleidoscope.use (&OneShot, &EscapeOneShot, NULL); + Kaleidoscope.setup (); } ``` diff --git a/examples/Escape-OneShot/Escape-OneShot.ino b/examples/Escape-OneShot/Escape-OneShot.ino index df98ae1e..bd7614c3 100644 --- a/examples/Escape-OneShot/Escape-OneShot.ino +++ b/examples/Escape-OneShot/Escape-OneShot.ino @@ -62,8 +62,8 @@ const Key keymaps[][ROWS][COLS] PROGMEM = { }; void setup() { - Kaleidoscope.use(&OneShot, &EscapeOneShot, NULL); - Kaleidoscope.setup(KEYMAP_SIZE); + USE_PLUGINS(&OneShot, &EscapeOneShot); + Kaleidoscope.setup(); } void loop() { diff --git a/src/Kaleidoscope/Escape-OneShot.cpp b/src/Kaleidoscope/Escape-OneShot.cpp index 97fec0ea..39de674b 100644 --- a/src/Kaleidoscope/Escape-OneShot.cpp +++ b/src/Kaleidoscope/Escape-OneShot.cpp @@ -20,30 +20,29 @@ #include #include -namespace KaleidoscopePlugins { +namespace kaleidoscope { EscapeOneShot::EscapeOneShot(void) { } -void -EscapeOneShot::begin(void) { +void EscapeOneShot::begin(void) { event_handler_hook_use(eventHandlerHook); } -Key -EscapeOneShot::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) { - if (mappedKey.raw != Key_Escape.raw || - (keyState & INJECTED) || - !key_toggled_on(keyState)) - return mappedKey; +Key EscapeOneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { + if (mapped_key.raw != Key_Escape.raw || + (key_state & INJECTED) || + !key_toggled_on(key_state)) + return mapped_key; - if (!OneShot::isActive()) - return mappedKey; + if (!OneShot.isActive()) + return mapped_key; - OneShot::cancel(); + OneShot.cancel(); return Key_NoKey; } -}; -KaleidoscopePlugins::EscapeOneShot EscapeOneShot; +} + +kaleidoscope::EscapeOneShot EscapeOneShot; diff --git a/src/Kaleidoscope/Escape-OneShot.h b/src/Kaleidoscope/Escape-OneShot.h index b42b6ddb..53513cc6 100644 --- a/src/Kaleidoscope/Escape-OneShot.h +++ b/src/Kaleidoscope/Escape-OneShot.h @@ -16,9 +16,11 @@ * along with this program. If not, see . */ +#pragma once + #include -namespace KaleidoscopePlugins { +namespace kaleidoscope { class EscapeOneShot : public KaleidoscopePlugin { public: EscapeOneShot(void); @@ -26,8 +28,8 @@ class EscapeOneShot : public KaleidoscopePlugin { void begin(void) final; private: - static Key eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState); -}; + static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state); }; +} -extern KaleidoscopePlugins::EscapeOneShot EscapeOneShot; +extern kaleidoscope::EscapeOneShot EscapeOneShot;