Merge pull request #76 from algernon/f/Layers/no-hook

Layers: Don't use hooks for the layer event handler
pull/77/head
Jesse Vincent 8 years ago committed by GitHub
commit 8d9ca8040c

@ -13,7 +13,6 @@ Keyboardio_::setup(const byte keymap_count) {
Keyboard.begin();
KeyboardHardware.setup();
LEDControl.setup();
Layer.begin();
Layer.defaultLayer (Storage.load_primary_keymap (keymap_count));
}

@ -93,5 +93,8 @@ void handle_key_event(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (mappedKey.raw == Key_NoKey.raw)
return;
}
mappedKey = Layer.eventHandler(mappedKey, row, col, keyState);
if (mappedKey.raw == Key_NoKey.raw)
return;
handle_key_event_default(mappedKey, row, col, keyState);
}

@ -33,8 +33,8 @@ static void handle_keymap_key_event(Key keymapEntry, uint8_t keyState) {
}
}
static Key
layerEventHandler(Key mappedKey, byte row, byte col, uint8_t keyState) {
Key
Layer_::eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState) {
if (mappedKey.flags != (SYNTHETIC | SWITCH_TO_KEYMAP))
return mappedKey;
@ -43,11 +43,7 @@ layerEventHandler(Key mappedKey, byte row, byte col, uint8_t keyState) {
}
Layer_::Layer_ (void) {
}
void Layer_::begin (void) {
defaultLayer (0);
event_handler_hook_add (layerEventHandler);
}
Key Layer_::lookup(byte row, byte col) {

@ -4,12 +4,10 @@
#include "key_defs.h"
#include "plugin.h"
class Layer_ : public KeyboardioPlugin {
class Layer_ {
public:
Layer_(void);
virtual void begin(void) final;
static Key lookup(byte row, byte col);
static void on(uint8_t layer);
static void off(uint8_t layer);
@ -25,6 +23,8 @@ class Layer_ : public KeyboardioPlugin {
static uint8_t defaultLayer(void);
static uint32_t getLayerState(void);
static Key eventHandler(Key mappedKey, byte row, byte col, uint8_t keyState);
};
extern Layer_ Layer;

Loading…
Cancel
Save