|
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
#include "key_defs.h"
|
|
|
|
#include "keyswitch_state.h"
|
|
|
|
#include "MouseWrapper.h"
|
|
|
|
#include "LEDControl.h"
|
|
|
|
#include "Storage.h"
|
|
|
|
#include "keymap_metadata.h"
|
|
|
|
#include "generated/keymaps.h"
|
|
|
|
|
|
|
|
//static const Key keymaps[KEYMAPS][ROWS][COLS];
|
|
|
|
extern uint8_t primary_keymap;
|
|
|
|
extern uint8_t temporary_keymap;
|
|
|
|
|
|
|
|
typedef bool (*custom_handler_t)(byte row, byte col, uint8_t currentState, uint8_t previousState);
|
|
|
|
|
|
|
|
void set_custom_handler(custom_handler_t f);
|
|
|
|
custom_handler_t get_custom_handler();
|
|
|
|
|
|
|
|
// sending events to the computer
|
|
|
|
void handle_synthetic_key_event( Key mappedKey, uint8_t currentState, uint8_t previousState);
|
|
|
|
void handle_key_event(byte row, byte col, uint8_t currentState, uint8_t previousState);
|
|
|
|
void press_key(Key mappedKey);
|
|
|
|
void handle_keymap_key_event(Key keymapEntry, uint8_t currentState, uint8_t previousState);
|
|
|
|
void handle_mouse_key_event(Key mappedKey, uint8_t currentState, uint8_t previousState);
|
key_events: A way to hook into the event handling
This adds a new `handle_user_key_event` function, that will get called
before anything else, and can override what happens. If it returns true,
the event will not be processed further by the firmware. By default,
this function returns false, and is a no-op.
It is defined with a `weak` attribute, to let the linker know that any
other function with the same name should override his one. This makes it
possible to have another version of this function in a firmware Sketch,
and override the behaviour, to extend the event handling.
This is the foundation that allows it to use external libraries, and tap
into the firmware's event handler, to add new stuff. (We can already
hook into the main loop by changing the top `loop` function in the
Sketch)
This addresses #21 for the most part.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
8 years ago
|
|
|
bool handle_user_key_event(byte row, byte col, uint8_t currentState, uint8_t previousState);
|
|
|
|
|
|
|
|
Key lookup_key(byte keymap, byte row, byte col);
|