You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
8 years ago
|
#include "Kaleidoscope.h"
|
||
8 years ago
|
#include <stdarg.h>
|
||
8 years ago
|
|
||
8 years ago
|
Kaleidoscope_::Kaleidoscope_(void) {
|
||
8 years ago
|
memset(eventHandlers, 0, HOOK_MAX * sizeof(custom_handler_t));
|
||
|
memset(loopHooks, 0, HOOK_MAX * sizeof(custom_handler_t));
|
||
8 years ago
|
}
|
||
|
|
||
|
void
|
||
8 years ago
|
Kaleidoscope_::setup(const byte keymap_count) {
|
||
8 years ago
|
wdt_disable();
|
||
|
delay(100);
|
||
|
Keyboard.begin();
|
||
|
KeyboardHardware.setup();
|
||
|
|
||
8 years ago
|
event_handler_hook_use (NULL);
|
||
|
loop_hook_use (NULL);
|
||
8 years ago
|
|
||
8 years ago
|
Layer.defaultLayer (KeyboardHardware.load_primary_layer (keymap_count));
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
custom_loop_t loopHooks[HOOK_MAX];
|
||
8 years ago
|
|
||
8 years ago
|
void
|
||
8 years ago
|
Kaleidoscope_::loop(void) {
|
||
8 years ago
|
KeyboardHardware.scan_matrix();
|
||
8 years ago
|
|
||
|
for (byte i = 0; loopHooks[i] != NULL && i < HOOK_MAX; i++) {
|
||
8 years ago
|
custom_loop_t hook = loopHooks[i];
|
||
|
(*hook)(false);
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
Keyboard.sendReport();
|
||
|
Keyboard.releaseAll();
|
||
8 years ago
|
|
||
|
for (byte i = 0; loopHooks[i] != NULL && i < HOOK_MAX; i++) {
|
||
8 years ago
|
custom_loop_t hook = loopHooks[i];
|
||
|
(*hook)(true);
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
void
|
||
8 years ago
|
Kaleidoscope_::use(KaleidoscopePlugin *plugin, ...) {
|
||
8 years ago
|
va_list ap;
|
||
8 years ago
|
KaleidoscopePlugin *p;
|
||
8 years ago
|
|
||
|
plugin->begin();
|
||
|
va_start(ap, plugin);
|
||
8 years ago
|
while ((p = va_arg(ap, KaleidoscopePlugin*)) != NULL) {
|
||
8 years ago
|
p->begin();
|
||
8 years ago
|
};
|
||
|
va_end(ap);
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
Kaleidoscope_ Kaleidoscope;
|