(changed some little things in layers)

partial-rewrite
Ben Blazak 2012-04-29 00:47:08 -07:00
parent 0b423bef70
commit 3c968c41f2
3 changed files with 40 additions and 17 deletions

View File

@ -19,7 +19,7 @@
// include the appropriate keyboard layout header // include the appropriate keyboard layout header
// for: // for:
// - number of layers // - number of layers
// - layout matrix definitions // - possible non-default layout matrix definitions
// - possible non-default layout 'get' and 'set' definitions // - possible non-default layout 'get' and 'set' definitions
#undef _str #undef _str
#undef _expstr #undef _expstr
@ -33,33 +33,42 @@
#undef _inc #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 // these are for when the matrices are stored solely in RAM. layouts
// here so layouts can redefine them if they with and use RAM, Flash, // may redefine them if they wish and use RAM, Flash, EEPROM, or any
// EEPROM, or any combination of those, while maintaining the same // combination of those, as long as they maintain the same interface.
// 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 // - 'set' functions are optional, and should be defined in the layout
// specific '.h'. they'll require the use of the EEPROM, possibly in // specific '.h'. they'll require the use of the EEPROM, possibly in
// clever conjunction with one of the other two memories (since the // 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 // - to override these macros with real functions, set the macro equal
// itself (e.g. `#define kb_layout_get kb_layout_get`) and provide // to itself (e.g. `#define kb_layout_get kb_layout_get`) and provide
// function prototypes in the layout specific '.h' // function prototypes in the layout specific '.h'
#ifndef kb_layout_get #ifndef kb_layout_get
extern uint8_t \
_kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS];
#define kb_layout_get(layer,row,column) \ #define kb_layout_get(layer,row,column) \
(_kb_layout[layer][row][column]) (_kb_layout[layer][row][column])
#endif #endif
#ifndef kb_layout_press_get #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) \ #define kb_layout_press_get(layer,row,column) \
(_kb_layout_press[layer][row][column]) (_kb_layout_press[layer][row][column])
#endif #endif
#ifndef kb_layout_release_get #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) \ #define kb_layout_release_get(layer,row,column) \
(_kb_layout_release[layer][row][column]) (_kb_layout_release[layer][row][column])
#endif #endif

View File

@ -7,6 +7,12 @@
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
#ifndef _DEFAULTS_h
#define _DEFAULTS_h
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// aliases // aliases
#define NA 0 // for keys not available on the matrix #define NA 0 // for keys not available on the matrix
#define NOP 0 // for keys that do nothing #define NOP 0 // for keys that do nothing
@ -61,3 +67,8 @@
/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ /* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \
} }
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif

View File

@ -1,7 +1,5 @@
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* ergoDOX layout : QWERTY : exports * ergoDOX layout : QWERTY : exports
*
* Meant to be included (as the last header) from "../layout.h"
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* Copyright (c) 2012 Ben Blazak <benblazak.dev@gmail.com> * Copyright (c) 2012 Ben Blazak <benblazak.dev@gmail.com>
* Released under The MIT License (MIT) (see "license.md") * Released under The MIT License (MIT) (see "license.md")
@ -10,27 +8,32 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#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 #define KB_LAYERS 1 // must match what's defined in the layout '.c' file
// override the defaults so we can use program space // 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) \ #define kb_layout_get(layer,row,column) \
( (uint8_t) (pgm_read_byte(&( \ ( (uint8_t) (pgm_read_byte(&( \
_kb_layout[layer][row][column] ))) ) _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) \ #define kb_layout_press_get(layer,row,column) \
( (kbfun_funptr_t) (pgm_read_word(&( \ ( (kbfun_funptr_t) (pgm_read_word(&( \
_kb_layout_press[layer][row][column] ))) ) _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) \ #define kb_layout_release_get(layer,row,column) \
( (kbfun_funptr_t) (pgm_read_word(&( \ ( (kbfun_funptr_t) (pgm_read_word(&( \
_kb_layout_release[layer][row][column] ))) ) _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];