diff --git a/Makefile b/Makefile index 1d6862d6..ef0c9ed5 100644 --- a/Makefile +++ b/Makefile @@ -86,8 +86,8 @@ astyle: find . -type f -name \*.h |xargs -n 1 astyle --style=google generate-keymaps: - -rm src/generated/keymaps.h - cd layouts && ( find . -type f |xargs -n 1 -I % sh -c 'perl ../tools/generate_keymaps.pl < % >> ../src/generated/keymaps.h' ) + -rm examples/KeyboardioFirmware/generated/keymaps.h + cd examples/KeyboardioFirmware/layouts && ( find . -type f | sort | xargs -n 1 -I % sh -c 'perl ../../../tools/generate_keymaps.pl < % >> ../generated/keymaps.h' ) dirs: mkdir -p $(OUTPUT_PATH) diff --git a/examples/KeyboardioFirmware/KeyboardioFirmware.ino b/examples/KeyboardioFirmware/KeyboardioFirmware.ino index def1b25f..274f4243 100644 --- a/examples/KeyboardioFirmware/KeyboardioFirmware.ino +++ b/examples/KeyboardioFirmware/KeyboardioFirmware.ino @@ -1,15 +1,23 @@ +// -*- mode: c++ -*- // Copyright 2016 Keyboardio, inc. // See "LICENSE" for license details #define DEBUG_SERIAL false #include "KeyboardioFirmware.h" +#include "generated/keymaps.h" uint8_t primary_keymap = 0; uint8_t temporary_keymap = 0; +#define KEYMAPS 3 +#define NUMPAD_KEYMAP 2 +#define KEYMAP_LIST KEYMAP_QWERTY KEYMAP_GENERIC_FN2 KEYMAP_NUMPAD + +const Key keymaps[][ROWS][COLS] PROGMEM = { KEYMAP_LIST }; + void setup() { - Keyboardio.setup(); + Keyboardio.setup(KEYMAPS, NUMPAD_KEYMAP); } diff --git a/src/generated/keymaps.h b/examples/KeyboardioFirmware/generated/keymaps.h similarity index 100% rename from src/generated/keymaps.h rename to examples/KeyboardioFirmware/generated/keymaps.h diff --git a/layouts/colemak b/examples/KeyboardioFirmware/layouts/colemak similarity index 100% rename from layouts/colemak rename to examples/KeyboardioFirmware/layouts/colemak diff --git a/layouts/dvorak b/examples/KeyboardioFirmware/layouts/dvorak similarity index 100% rename from layouts/dvorak rename to examples/KeyboardioFirmware/layouts/dvorak diff --git a/layouts/generic_fn2 b/examples/KeyboardioFirmware/layouts/generic_fn2 similarity index 100% rename from layouts/generic_fn2 rename to examples/KeyboardioFirmware/layouts/generic_fn2 diff --git a/layouts/generic_fn2-moo b/examples/KeyboardioFirmware/layouts/generic_fn2-moo similarity index 100% rename from layouts/generic_fn2-moo rename to examples/KeyboardioFirmware/layouts/generic_fn2-moo diff --git a/layouts/maltron b/examples/KeyboardioFirmware/layouts/maltron similarity index 100% rename from layouts/maltron rename to examples/KeyboardioFirmware/layouts/maltron diff --git a/layouts/numpad b/examples/KeyboardioFirmware/layouts/numpad similarity index 100% rename from layouts/numpad rename to examples/KeyboardioFirmware/layouts/numpad diff --git a/layouts/qwerty b/examples/KeyboardioFirmware/layouts/qwerty similarity index 100% rename from layouts/qwerty rename to examples/KeyboardioFirmware/layouts/qwerty diff --git a/layouts/qwerty-moo b/examples/KeyboardioFirmware/layouts/qwerty-moo similarity index 100% rename from layouts/qwerty-moo rename to examples/KeyboardioFirmware/layouts/qwerty-moo diff --git a/layouts/qwerty_alt_cmd b/examples/KeyboardioFirmware/layouts/qwerty_alt_cmd similarity index 100% rename from layouts/qwerty_alt_cmd rename to examples/KeyboardioFirmware/layouts/qwerty_alt_cmd diff --git a/layouts/qwerty_piers b/examples/KeyboardioFirmware/layouts/qwerty_piers similarity index 100% rename from layouts/qwerty_piers rename to examples/KeyboardioFirmware/layouts/qwerty_piers diff --git a/layouts/workman b/examples/KeyboardioFirmware/layouts/workman similarity index 100% rename from layouts/workman rename to examples/KeyboardioFirmware/layouts/workman diff --git a/src/KeyboardioFirmware.cpp b/src/KeyboardioFirmware.cpp index 00ac2a5c..6909c0df 100644 --- a/src/KeyboardioFirmware.cpp +++ b/src/KeyboardioFirmware.cpp @@ -1,10 +1,12 @@ #include "KeyboardioFirmware.h" +byte NUMPAD_KEYMAP = 0; + Keyboardio_::Keyboardio_(void) { } void -Keyboardio_::setup(void) { +Keyboardio_::setup(const byte keymap_count, const byte numpad_layer) { event_handler_hook_add (handle_key_event_default); wdt_disable(); delay(100); @@ -14,7 +16,8 @@ Keyboardio_::setup(void) { KeyboardHardware.setup(); LEDControl.boot_animation(); - temporary_keymap = primary_keymap = Storage.load_primary_keymap(KEYMAPS); + NUMPAD_KEYMAP = numpad_layer; + temporary_keymap = primary_keymap = Storage.load_primary_keymap(keymap_count); } custom_loop_t loopHooks[HOOK_MAX] = {NULL}; diff --git a/src/KeyboardioFirmware.h b/src/KeyboardioFirmware.h index a88821cc..3cbe9de4 100644 --- a/src/KeyboardioFirmware.h +++ b/src/KeyboardioFirmware.h @@ -22,7 +22,6 @@ void setup(); #include #include "KeyboardConfig.h" -#include "generated/keymaps.h" #include "key_events.h" extern HARDWARE_IMPLEMENTATION KeyboardHardware; @@ -38,7 +37,7 @@ class Keyboardio_ { public: Keyboardio_(void); - void setup(void); + void setup(const byte keymap_count, const byte numpad_layer); void loop(void); }; diff --git a/src/LEDControl.h b/src/LEDControl.h index 7ea36e3c..bea7be8d 100644 --- a/src/LEDControl.h +++ b/src/LEDControl.h @@ -91,3 +91,5 @@ class LEDControl_ { }; extern LEDControl_ LEDControl; + +extern byte NUMPAD_KEYMAP; diff --git a/src/key_events.cpp b/src/key_events.cpp index a1f6541c..d1753ba5 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -1,7 +1,5 @@ #include "key_events.h" -static const Key keymaps[KEYMAPS][ROWS][COLS] PROGMEM = { KEYMAP_LIST }; - void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t previousState) { if (mappedKey.flags & IS_MOUSE_KEY && !( mappedKey.rawKey & KEY_MOUSE_WARP) ) { handle_mouse_key_event(mappedKey, currentState, previousState); diff --git a/src/key_events.h b/src/key_events.h index da687301..633f9f0a 100644 --- a/src/key_events.h +++ b/src/key_events.h @@ -7,12 +7,12 @@ #include "LEDControl.h" #include "Storage.h" #include "keymap_metadata.h" -#include "generated/keymaps.h" #include "hooks.h" //static const Key keymaps[KEYMAPS][ROWS][COLS]; extern uint8_t primary_keymap; extern uint8_t temporary_keymap; +extern const Key keymaps[][ROWS][COLS]; // sending events to the computer void handle_synthetic_key_event( Key mappedKey, uint8_t currentState, uint8_t previousState); diff --git a/src/keymap_metadata.h b/src/keymap_metadata.h index ab3c8d2a..81207eba 100644 --- a/src/keymap_metadata.h +++ b/src/keymap_metadata.h @@ -2,6 +2,3 @@ #define COLS 16 #define ROWS 4 -#define KEYMAPS 3 -#define NUMPAD_KEYMAP 2 -#define KEYMAP_LIST KEYMAP_QWERTY KEYMAP_GENERIC_FN2 KEYMAP_NUMPAD