From 7919922036828d23cedd4b2b5e6ac7fb6e0dac7a Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 25 Jul 2017 00:46:02 -0700 Subject: [PATCH] Move the hid facade out into its own namespace --- src/Kaleidoscope.cpp | 4 ++-- src/Kaleidoscope.h | 2 ++ src/kaleidoscope/hid.cpp | 7 +++++-- src/kaleidoscope/hid.h | 5 ++++- src/key_events.cpp | 12 ++++++------ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Kaleidoscope.cpp b/src/Kaleidoscope.cpp index 4b538700..e5c38a1e 100644 --- a/src/Kaleidoscope.cpp +++ b/src/Kaleidoscope.cpp @@ -25,8 +25,8 @@ Kaleidoscope_::loop(void) { (*hook)(false); } - sendKeyboardReport(); - releaseAllKeys(); + kaleidoscope::hid::sendKeyboardReport(); + kaleidoscope::hid::releaseAllKeys(); for (byte i = 0; loopHooks[i] != NULL && i < HOOK_MAX; i++) { loopHook hook = loopHooks[i]; diff --git a/src/Kaleidoscope.h b/src/Kaleidoscope.h index aa8f16db..25846149 100644 --- a/src/Kaleidoscope.h +++ b/src/Kaleidoscope.h @@ -19,8 +19,10 @@ void setup(); #include #include + #include KALEIDOSCOPE_HARDWARE_H #include "key_events.h" +#include "kaleidoscope/hid.h" #include "layers.h" #define HOOK_MAX 64 diff --git a/src/kaleidoscope/hid.cpp b/src/kaleidoscope/hid.cpp index bb274863..460e6e97 100644 --- a/src/kaleidoscope/hid.cpp +++ b/src/kaleidoscope/hid.cpp @@ -1,6 +1,8 @@ -#include "Kaleidoscope.h" +#include "hid.h" +#include "KeyboardioHID.h" -namespace kaleidoscope::hid { +namespace kaleidoscope { +namespace hid { void initializeKeyboard() { Keyboard.begin(); } @@ -139,4 +141,5 @@ void releaseAbsoluteMouseButtons(uint8_t buttons) { AbsoluteMouse.release(buttons); } +} }; diff --git a/src/kaleidoscope/hid.h b/src/kaleidoscope/hid.h index f30b2219..2e3f38e6 100644 --- a/src/kaleidoscope/hid.h +++ b/src/kaleidoscope/hid.h @@ -1,7 +1,9 @@ #pragma once #include +#include "key_defs.h" -namespace kaleidoscope::hid { +namespace kaleidoscope { +namespace hid { // A facade on top of our HID implementation @@ -42,4 +44,5 @@ void clickAbsoluteMouseButtons(uint8_t buttons); void pressAbsoluteMouseButtons(uint8_t buttons); void releaseAbsoluteMouseButtons(uint8_t buttons); +} }; diff --git a/src/key_events.cpp b/src/key_events.cpp index a79f3c6d..981c34b8 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -12,15 +12,15 @@ static bool handleSyntheticKeyswitchEvent(Key mappedKey, uint8_t keyState) { return false; } else if (mappedKey.flags & IS_CONSUMER) { if (keyIsPressed(keyState)) { - pressConsumerControl(mappedKey); + kaleidoscope::hid::pressConsumerControl(mappedKey); } else if (keyWasPressed(keyState)) { - releaseConsumerControl(mappedKey); + kaleidoscope::hid::releaseConsumerControl(mappedKey); } } else if (mappedKey.flags & IS_SYSCTL) { if (keyIsPressed(keyState)) { - pressSystemControl(mappedKey); + kaleidoscope::hid::pressSystemControl(mappedKey); } else if (keyWasPressed(keyState)) { - releaseSystemControl(mappedKey); + kaleidoscope::hid::releaseSystemControl(mappedKey); } } else if (mappedKey.flags & SWITCH_TO_KEYMAP) { // Should not happen, handled elsewhere. @@ -36,9 +36,9 @@ static bool handleKeyswitchEventDefault(Key mappedKey, byte row, byte col, uint8 if (mappedKey.flags & SYNTHETIC) { handleSyntheticKeyswitchEvent(mappedKey, keyState); } else if (keyIsPressed(keyState)) { - pressKey(mappedKey); + kaleidoscope::hid::pressKey(mappedKey); } else if (keyToggledOff(keyState) && (keyState & INJECTED)) { - releaseKey(mappedKey); + kaleidoscope::hid::releaseKey(mappedKey); } return true; }