Move the hid facade out into its own namespace

pull/144/merge
Jesse Vincent 7 years ago
parent 7e73341772
commit 7919922036
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -25,8 +25,8 @@ Kaleidoscope_::loop(void) {
(*hook)(false); (*hook)(false);
} }
sendKeyboardReport(); kaleidoscope::hid::sendKeyboardReport();
releaseAllKeys(); kaleidoscope::hid::releaseAllKeys();
for (byte i = 0; loopHooks[i] != NULL && i < HOOK_MAX; i++) { for (byte i = 0; loopHooks[i] != NULL && i < HOOK_MAX; i++) {
loopHook hook = loopHooks[i]; loopHook hook = loopHooks[i];

@ -19,8 +19,10 @@ void setup();
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include KALEIDOSCOPE_HARDWARE_H #include KALEIDOSCOPE_HARDWARE_H
#include "key_events.h" #include "key_events.h"
#include "kaleidoscope/hid.h"
#include "layers.h" #include "layers.h"
#define HOOK_MAX 64 #define HOOK_MAX 64

@ -1,6 +1,8 @@
#include "Kaleidoscope.h" #include "hid.h"
#include "KeyboardioHID.h"
namespace kaleidoscope::hid { namespace kaleidoscope {
namespace hid {
void initializeKeyboard() { void initializeKeyboard() {
Keyboard.begin(); Keyboard.begin();
} }
@ -139,4 +141,5 @@ void releaseAbsoluteMouseButtons(uint8_t buttons) {
AbsoluteMouse.release(buttons); AbsoluteMouse.release(buttons);
} }
}
}; };

@ -1,7 +1,9 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#include "key_defs.h"
namespace kaleidoscope::hid { namespace kaleidoscope {
namespace hid {
// A facade on top of our HID implementation // A facade on top of our HID implementation
@ -42,4 +44,5 @@ void clickAbsoluteMouseButtons(uint8_t buttons);
void pressAbsoluteMouseButtons(uint8_t buttons); void pressAbsoluteMouseButtons(uint8_t buttons);
void releaseAbsoluteMouseButtons(uint8_t buttons); void releaseAbsoluteMouseButtons(uint8_t buttons);
}
}; };

@ -12,15 +12,15 @@ static bool handleSyntheticKeyswitchEvent(Key mappedKey, uint8_t keyState) {
return false; return false;
} else if (mappedKey.flags & IS_CONSUMER) { } else if (mappedKey.flags & IS_CONSUMER) {
if (keyIsPressed(keyState)) { if (keyIsPressed(keyState)) {
pressConsumerControl(mappedKey); kaleidoscope::hid::pressConsumerControl(mappedKey);
} else if (keyWasPressed(keyState)) { } else if (keyWasPressed(keyState)) {
releaseConsumerControl(mappedKey); kaleidoscope::hid::releaseConsumerControl(mappedKey);
} }
} else if (mappedKey.flags & IS_SYSCTL) { } else if (mappedKey.flags & IS_SYSCTL) {
if (keyIsPressed(keyState)) { if (keyIsPressed(keyState)) {
pressSystemControl(mappedKey); kaleidoscope::hid::pressSystemControl(mappedKey);
} else if (keyWasPressed(keyState)) { } else if (keyWasPressed(keyState)) {
releaseSystemControl(mappedKey); kaleidoscope::hid::releaseSystemControl(mappedKey);
} }
} else if (mappedKey.flags & SWITCH_TO_KEYMAP) { } else if (mappedKey.flags & SWITCH_TO_KEYMAP) {
// Should not happen, handled elsewhere. // Should not happen, handled elsewhere.
@ -36,9 +36,9 @@ static bool handleKeyswitchEventDefault(Key mappedKey, byte row, byte col, uint8
if (mappedKey.flags & SYNTHETIC) { if (mappedKey.flags & SYNTHETIC) {
handleSyntheticKeyswitchEvent(mappedKey, keyState); handleSyntheticKeyswitchEvent(mappedKey, keyState);
} else if (keyIsPressed(keyState)) { } else if (keyIsPressed(keyState)) {
pressKey(mappedKey); kaleidoscope::hid::pressKey(mappedKey);
} else if (keyToggledOff(keyState) && (keyState & INJECTED)) { } else if (keyToggledOff(keyState) && (keyState & INJECTED)) {
releaseKey(mappedKey); kaleidoscope::hid::releaseKey(mappedKey);
} }
return true; return true;
} }

Loading…
Cancel
Save