From 3c968c41f2b2a53c8c3bc723fd7f7f7a1c2c19e0 Mon Sep 17 00:00:00 2001 From: Ben Blazak Date: Sun, 29 Apr 2012 00:47:08 -0700 Subject: [PATCH] (changed some little things in layers) --- src/keyboard/ergodox/layout.h | 27 ++++++++++++++++--------- src/keyboard/ergodox/layout/_defaults.h | 11 ++++++++++ src/keyboard/ergodox/layout/qwerty.h | 19 +++++++++-------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/keyboard/ergodox/layout.h b/src/keyboard/ergodox/layout.h index 8df9877..02c2886 100644 --- a/src/keyboard/ergodox/layout.h +++ b/src/keyboard/ergodox/layout.h @@ -19,7 +19,7 @@ // include the appropriate keyboard layout header // for: // - number of layers - // - layout matrix definitions + // - possible non-default layout matrix definitions // - possible non-default layout 'get' and 'set' definitions #undef _str #undef _expstr @@ -33,33 +33,42 @@ #undef _inc - // default layout 'get' macros + // default layout 'get' macros and `extern` matrix declarations // - // these are for when the matrices are stored solely in RAM. they're - // here so layouts can redefine them if they with and use RAM, Flash, - // EEPROM, or any combination of those, while maintaining the same - // interface + // these are for when the matrices are stored solely in RAM. layouts + // may redefine them if they wish and use RAM, Flash, EEPROM, or any + // combination of those, as long as they maintain the same interface. + // + // - if the macro is overridden, the matrix declaration must be too, + // and vice versa. // // - 'set' functions are optional, and should be defined in the layout // specific '.h'. they'll require the use of the EEPROM, possibly in // clever conjunction with one of the other two memories (since the - // EEPROM is small) + // EEPROM is small). custom key functions will also need to be + // written. // - // - to override these with real functions, set the macro equal to - // itself (e.g. `#define kb_layout_get kb_layout_get`) and provide + // - to override these macros with real functions, set the macro equal + // to itself (e.g. `#define kb_layout_get kb_layout_get`) and provide // function prototypes in the layout specific '.h' #ifndef kb_layout_get + extern uint8_t \ + _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS]; #define kb_layout_get(layer,row,column) \ (_kb_layout[layer][row][column]) #endif #ifndef kb_layout_press_get + extern kbfun_funptr_t \ + _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS]; #define kb_layout_press_get(layer,row,column) \ (_kb_layout_press[layer][row][column]) #endif #ifndef kb_layout_release_get + extern kbfun_funptr_t PROGMEM \ + _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS]; #define kb_layout_release_get(layer,row,column) \ (_kb_layout_release[layer][row][column]) #endif diff --git a/src/keyboard/ergodox/layout/_defaults.h b/src/keyboard/ergodox/layout/_defaults.h index f7cc211..8727352 100644 --- a/src/keyboard/ergodox/layout/_defaults.h +++ b/src/keyboard/ergodox/layout/_defaults.h @@ -7,6 +7,12 @@ * ------------------------------------------------------------------------- */ +#ifndef _DEFAULTS_h + #define _DEFAULTS_h +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + + // aliases #define NA 0 // for keys not available on the matrix #define NOP 0 // for keys that do nothing @@ -61,3 +67,8 @@ /* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ } + +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +#endif + diff --git a/src/keyboard/ergodox/layout/qwerty.h b/src/keyboard/ergodox/layout/qwerty.h index b03c891..52099fb 100644 --- a/src/keyboard/ergodox/layout/qwerty.h +++ b/src/keyboard/ergodox/layout/qwerty.h @@ -1,7 +1,5 @@ /* ---------------------------------------------------------------------------- * ergoDOX layout : QWERTY : exports - * - * Meant to be included (as the last header) from "../layout.h" * ---------------------------------------------------------------------------- * Copyright (c) 2012 Ben Blazak * Released under The MIT License (MIT) (see "license.md") @@ -10,27 +8,32 @@ #include +#include "lib/data-types.h" +#include "lib/key-functions.h" // for `kbfun_funptr_t` + +#include "../matrix.h" // for number of rows and columns #define KB_LAYERS 1 // must match what's defined in the layout '.c' file // override the defaults so we can use program space + +extern uint8_t PROGMEM \ + _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS]; #define kb_layout_get(layer,row,column) \ ( (uint8_t) (pgm_read_byte(&( \ _kb_layout[layer][row][column] ))) ) +extern kbfun_funptr_t PROGMEM \ + _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS]; #define kb_layout_press_get(layer,row,column) \ ( (kbfun_funptr_t) (pgm_read_word(&( \ _kb_layout_press[layer][row][column] ))) ) +extern kbfun_funptr_t PROGMEM \ + _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS]; #define kb_layout_release_get(layer,row,column) \ ( (kbfun_funptr_t) (pgm_read_word(&( \ _kb_layout_release[layer][row][column] ))) ) - -extern uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS]; -extern kbfun_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS]; -extern kbfun_funptr_t PROGMEM - _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS]; -