Merge pull request #37 from algernon/f/layout-separation

Separate the keymap layout from the core firmware
pull/35/head
Jesse Vincent 8 years ago committed by GitHub
commit 50e2a83050

@ -86,8 +86,8 @@ astyle:
find . -type f -name \*.h |xargs -n 1 astyle --style=google find . -type f -name \*.h |xargs -n 1 astyle --style=google
generate-keymaps: generate-keymaps:
-rm src/generated/keymaps.h -rm examples/KeyboardioFirmware/generated/keymaps.h
cd layouts && ( find . -type f |xargs -n 1 -I % sh -c 'perl ../tools/generate_keymaps.pl < % >> ../src/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: dirs:
mkdir -p $(OUTPUT_PATH) mkdir -p $(OUTPUT_PATH)

@ -1,15 +1,23 @@
// -*- mode: c++ -*-
// Copyright 2016 Keyboardio, inc. <jesse@keyboard.io> // Copyright 2016 Keyboardio, inc. <jesse@keyboard.io>
// See "LICENSE" for license details // See "LICENSE" for license details
#define DEBUG_SERIAL false #define DEBUG_SERIAL false
#include "KeyboardioFirmware.h" #include "KeyboardioFirmware.h"
#include "generated/keymaps.h"
uint8_t primary_keymap = 0; uint8_t primary_keymap = 0;
uint8_t temporary_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() { void setup() {
Keyboardio.setup(); Keyboardio.setup(KEYMAPS, NUMPAD_KEYMAP);
} }

@ -1,10 +1,12 @@
#include "KeyboardioFirmware.h" #include "KeyboardioFirmware.h"
byte NUMPAD_KEYMAP = 0;
Keyboardio_::Keyboardio_(void) { Keyboardio_::Keyboardio_(void) {
} }
void void
Keyboardio_::setup(void) { Keyboardio_::setup(const byte keymap_count, const byte numpad_layer) {
event_handler_hook_add (handle_key_event_default); event_handler_hook_add (handle_key_event_default);
wdt_disable(); wdt_disable();
delay(100); delay(100);
@ -14,7 +16,8 @@ Keyboardio_::setup(void) {
KeyboardHardware.setup(); KeyboardHardware.setup();
LEDControl.boot_animation(); 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}; custom_loop_t loopHooks[HOOK_MAX] = {NULL};

@ -22,7 +22,6 @@ void setup();
#include <avr/wdt.h> #include <avr/wdt.h>
#include "KeyboardConfig.h" #include "KeyboardConfig.h"
#include "generated/keymaps.h"
#include "key_events.h" #include "key_events.h"
extern HARDWARE_IMPLEMENTATION KeyboardHardware; extern HARDWARE_IMPLEMENTATION KeyboardHardware;
@ -38,7 +37,7 @@ class Keyboardio_ {
public: public:
Keyboardio_(void); Keyboardio_(void);
void setup(void); void setup(const byte keymap_count, const byte numpad_layer);
void loop(void); void loop(void);
}; };

@ -91,3 +91,5 @@ class LEDControl_ {
}; };
extern LEDControl_ LEDControl; extern LEDControl_ LEDControl;
extern byte NUMPAD_KEYMAP;

@ -1,7 +1,5 @@
#include "key_events.h" #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) { void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t previousState) {
if (mappedKey.flags & IS_MOUSE_KEY && !( mappedKey.rawKey & KEY_MOUSE_WARP) ) { if (mappedKey.flags & IS_MOUSE_KEY && !( mappedKey.rawKey & KEY_MOUSE_WARP) ) {
handle_mouse_key_event(mappedKey, currentState, previousState); handle_mouse_key_event(mappedKey, currentState, previousState);

@ -7,12 +7,12 @@
#include "LEDControl.h" #include "LEDControl.h"
#include "Storage.h" #include "Storage.h"
#include "keymap_metadata.h" #include "keymap_metadata.h"
#include "generated/keymaps.h"
#include "hooks.h" #include "hooks.h"
//static const Key keymaps[KEYMAPS][ROWS][COLS]; //static const Key keymaps[KEYMAPS][ROWS][COLS];
extern uint8_t primary_keymap; extern uint8_t primary_keymap;
extern uint8_t temporary_keymap; extern uint8_t temporary_keymap;
extern const Key keymaps[][ROWS][COLS];
// sending events to the computer // sending events to the computer
void handle_synthetic_key_event( Key mappedKey, uint8_t currentState, uint8_t previousState); void handle_synthetic_key_event( Key mappedKey, uint8_t currentState, uint8_t previousState);

@ -2,6 +2,3 @@
#define COLS 16 #define COLS 16
#define ROWS 4 #define ROWS 4
#define KEYMAPS 3
#define NUMPAD_KEYMAP 2
#define KEYMAP_LIST KEYMAP_QWERTY KEYMAP_GENERIC_FN2 KEYMAP_NUMPAD

Loading…
Cancel
Save