From 4972c81a96eb35105d4c065e6cefa0fa9d8180c1 Mon Sep 17 00:00:00 2001 From: Ben Blazak Date: Tue, 29 May 2012 16:53:55 -0700 Subject: [PATCH] updated matrix and layout stuff for dox's PCB --- src/keyboard/ergodox/layout.h | 4 +- src/keyboard/ergodox/layout/_defaults.h | 74 --------------------- src/keyboard/ergodox/layout/qwerty.c | 49 +++++++------- src/keyboard/ergodox/matrix.h | 87 +++++++++++++++++++++++++ src/keyboard/ergodox/matrix.md | 29 --------- 5 files changed, 115 insertions(+), 128 deletions(-) delete mode 100644 src/keyboard/ergodox/layout/_defaults.h delete mode 100644 src/keyboard/ergodox/matrix.md diff --git a/src/keyboard/ergodox/layout.h b/src/keyboard/ergodox/layout.h index 7a8517e..b0c957e 100644 --- a/src/keyboard/ergodox/layout.h +++ b/src/keyboard/ergodox/layout.h @@ -15,7 +15,8 @@ #include "lib/data-types.h" #include "lib/key-functions.h" // for `kbfun_funptr_t` - #include "matrix.h" // for number of rows and columns + #include "matrix.h" // for number of rows and columns, and layout + // to matrix macros // include the appropriate keyboard layout header // for: @@ -82,6 +83,7 @@ ( (kbfun_funptr_t) \ pgm_read_word(&( \ _kb_layout_release[layer][row][column] )) ) + #endif #endif diff --git a/src/keyboard/ergodox/layout/_defaults.h b/src/keyboard/ergodox/layout/_defaults.h deleted file mode 100644 index 1cf8c25..0000000 --- a/src/keyboard/ergodox/layout/_defaults.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ---------------------------------------------------------------------------- - * ergoDOX layout : default layers and aliases - * ---------------------------------------------------------------------------- - * Copyright (c) 2012 Ben Blazak - * Released under The MIT License (MIT) (see "license.md") - * Project located at - * ------------------------------------------------------------------------- */ - - -#ifndef LAYOUT__DEFAULTS_h - #define LAYOUT__DEFAULTS_h -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- - - -// aliases -#define NA 0 // for keys not available on the matrix -#define NOP 0 // for keys that do nothing -#define f_NA NULL // for functions not available on the matrix -#define f_NOP NULL // for functions that do nothing -// --- require "lib/key-functions.h" -#define f_press &kbfun_press -#define f_release &kbfun_release - - -#define DEFAULT_LAYER_PRESS \ -{ \ -/* right hand */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -/* 0 */ { f_press , f_press , f_press , f_press , f_press , f_press , f_press }, /* 0 */ \ -/* 1 */ { f_press , f_press , f_press , f_press , f_press , f_press , f_press }, /* 1 */ \ -/* 2 */ { f_NA , f_press , f_press , f_press , f_press , f_press , f_press }, /* 2 */ \ -/* 3 */ { f_press , f_press , f_press , f_press , f_press , f_press , f_press }, /* 3 */ \ -/* 4 */ { f_NA , f_NA , f_press , f_press , f_press , f_press , f_press }, /* 4 */ \ -/* 5 */ { f_NA , f_press , f_press , f_press , f_press , f_press , f_press }, /* 5 */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -/* left hand */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -/* 6 */ { f_press , f_press , f_press , f_press , f_press , f_press , f_press }, /* 6 */ \ -/* 7 */ { f_press , f_press , f_press , f_press , f_press , f_press , f_press }, /* 7 */ \ -/* 8 */ { f_press , f_press , f_press , f_press , f_press , f_press , f_NA }, /* 8 */ \ -/* 9 */ { f_press , f_press , f_press , f_press , f_press , f_press , f_press }, /* 9 */ \ -/* A */ { f_press , f_press , f_press , f_press , f_press , f_NA , f_NA }, /* A */ \ -/* B */ { f_press , f_press , f_press , f_press , f_press , f_press , f_NA } /* B */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -} - -#define DEFAULT_LAYER_RELEASE \ -{ \ -/* right hand */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -/* 0 */ { f_release , f_release , f_release , f_release , f_release , f_release , f_release }, /* 0 */ \ -/* 1 */ { f_release , f_release , f_release , f_release , f_release , f_release , f_release }, /* 1 */ \ -/* 2 */ { f_NA , f_release , f_release , f_release , f_release , f_release , f_release }, /* 2 */ \ -/* 3 */ { f_release , f_release , f_release , f_release , f_release , f_release , f_release }, /* 3 */ \ -/* 4 */ { f_NA , f_NA , f_release , f_release , f_release , f_release , f_release }, /* 4 */ \ -/* 5 */ { f_NA , f_release , f_release , f_release , f_release , f_release , f_release }, /* 5 */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -/* left hand */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -/* 6 */ { f_release , f_release , f_release , f_release , f_release , f_release , f_release }, /* 6 */ \ -/* 7 */ { f_release , f_release , f_release , f_release , f_release , f_release , f_release }, /* 7 */ \ -/* 8 */ { f_release , f_release , f_release , f_release , f_release , f_release , f_NA }, /* 8 */ \ -/* 9 */ { f_release , f_release , f_release , f_release , f_release , f_release , f_release }, /* 9 */ \ -/* A */ { f_release , f_release , f_release , f_release , f_release , f_NA , f_NA }, /* A */ \ -/* B */ { f_release , f_release , f_release , f_release , f_release , f_release , f_NA } /* B */ \ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ \ -} - - -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -#endif - diff --git a/src/keyboard/ergodox/layout/qwerty.c b/src/keyboard/ergodox/layout/qwerty.c index 203f914..b955f61 100644 --- a/src/keyboard/ergodox/layout/qwerty.c +++ b/src/keyboard/ergodox/layout/qwerty.c @@ -14,45 +14,46 @@ #include "lib/usb/usage-page/keyboard--short-names.h" #include "lib/key-functions.h" +#define KEYBOARD_INCLUDE_PRIVATE #include "../matrix.h" #include "../layout.h" -#include "_defaults.h" // for default layers and aliases -// error check; everything below assumes these dimensions +// error check: everything below assumes these dimensions #if KB_LAYERS != 1 || KB_ROWS != 12 || KB_COLUMNS != 7 #error "Expecting different keyboard dimensions" #endif uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { -{ /* layer 0: default */ -/* right hand */ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ -/* 0 */ { NOP , _6 , _7 , _8 , _9 , _0 , _dash }, /* 0 */ -/* 1 */ { NOP , _Y , _U , _I , _O , _P , _bracketL }, /* 1 */ -/* 2 */ { NA , _H , _J , _K , _L , _semicolon, _quote }, /* 2 */ -/* 3 */ { NOP , _N , _M , _comma , _period , _slash , _shiftR }, /* 3 */ -/* 4 */ { NA , NA , _arrowU , _arrowD , _backslash, _bracketR , NOP }, /* 4 */ -/* 5 */ { NA , _ctrlR , _altR , _pageU , _pageD , _enter , _space }, /* 5 */ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ -/* left hand */ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ -/* 6 */ { _equal , _1 , _2 , _3 , _4 , _5 , NOP }, /* 6 */ -/* 7 */ { _tab , _Q , _W , _E , _R , _T , NOP }, /* 7 */ -/* 8 */ { _capsLock , _A , _S , _D , _F , _G , NA }, /* 8 */ -/* 9 */ { _shiftL , _Z , _X , _C , _V , _B , NOP }, /* 9 */ -/* A */ { NOP , _grave , _backslash, _arrowL , _arrowR , NA , NA }, /* A */ -/* B */ { _bs , _del , _end , _home , _altL , _ctrlL , NA } /* B */ -/* ---- 0 ---- ---- 1 ---- ---- 2 ---- ---- 3 ---- ---- 4 ---- ---- 5 ---- ---- 6 ---- */ -} + LAYER( // layer 0: default +// left hand +_grave, _1, _2, _3, _4, _5, _equal, +_tab, _Q, _W, _E, _R, _T, _esc, +_capsLock, _A, _S, _D, _F, _G, +_shiftL, _Z, _X, _C, _V, _B, _ctrlL, +_guiL, _arrowL, _arrowU, _arrowD, _arrowR, + _bs, + _del, _ctrlL, + _end, _home, _altL, +// right hand + _backslash, _6, _7, _8, _9, _0, _dash, + _bracketL, _Y, _U, _I, _O, _P, _bracketR, + _H, _J, _K, _L, _semicolon, _quote, + _ctrlR, _N, _M, _comma, _period, _slash, _shiftR, + _arrowL, _arrowD, _arrowU, _arrowR, _guiR, + _space, +_ctrlR, _enter, +_altR, _pageU, _pageD ) }; + kbfun_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { -/* layer 0: default */ DEFAULT_LAYER_PRESS + LAYER_SET_ALL(&kbfun_press); // layer 0: default }; + kbfun_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { -/* layer 0: default */ DEFAULT_LAYER_RELEASE + LAYER_SET_ALL(&kbfun_release); // layer 0: default }; diff --git a/src/keyboard/ergodox/matrix.h b/src/keyboard/ergodox/matrix.h index 1ee9907..01fe902 100644 --- a/src/keyboard/ergodox/matrix.h +++ b/src/keyboard/ergodox/matrix.h @@ -19,5 +19,92 @@ extern bool (*kb_was_pressed)[KB_ROWS][KB_COLUMNS]; + #ifdef KEYBOARD_INCLUDE_PRIVATE + + //error check: since these macros are used for both keycodes + // and function pointers + #if NULL != 0 + #error "NULL != 0 ; macros in matrix.h must be revised" + #endif + + + /* mapping from spatial position to matrix position + * - spatial position: where the key is spatially, relative to + * other keys both on the keyboard and in the layout + * - matrix position: the coordinate in the matrix to which + * a key is scanned by the update functions + * + * - location numbers are in the format `row##column`, where + * both 'row' and 'column' are single digit hex numbers + * corresponding to the matrix position + * - coordinates not listed are unused + * + * --- other info --------------------------------------------- + * rows x columns = positions; assigned, unassigned + * per hand: 6 x 7 = 42; 38, 4 + * total: 12 x 7 = 84; 76, 8 + * + * left hand : cols 0..6, rows 6..B + * right hand : cols 0..6, rows 0..5 + * ------------------------------------------------------------ + */ + #define LAYER( \ + /* left hand, spatial positions */ \ + kB6,kB5,kB4,kB3,kB2,kB1,kB0, \ + kA6,kA5,kA4,kA3,kA2,kA1,kA0, \ + k96,k95,k94,k93,k92,k91, \ + k86,k85,k84,k83,k82,k81,k80, \ + k76,k75,k74,k73,k72, \ + k64, \ + k63, k60, \ + k65,k62,k61, \ + \ + /* right hand, spatial positions */ \ + k50,k51,k52,k53,k54,k55,k56, \ + k40,k41,k42,k43,k44,k45,k46, \ + k31,k32,k33,k34,k35,k36, \ + k20,k21,k22,k23,k24,k25,k26, \ + k12,k13,k14,k15,k16, \ + k04, \ + k00, k03, \ + k01,k02,k05 ) \ + \ + /* matrix positions */ \ + { { k00,k01,k02,k03,k04,k05, 0,}, \ + { 0, 0,k12,k13,k14,k15,k16,}, \ + { k20,k21,k22,k23,k24,k25,k26,}, \ + { 0,k31,k32,k33,k34,k35,k36,}, \ + { k40,k41,k42,k43,k44,k45,k46,}, \ + { k50,k51,k52,k53,k54,k55,k56,}, \ + { k60,k61,k62,k63,k64,k65, 0,}, \ + { 0, 0,k72,k73,k74,k75,k76,}, \ + { k80,k81,k82,k83,k84,k85,k86,}, \ + { 0,k91,k92,k93,k94,k95,k96,}, \ + { kA0,kA1,kA2,kA3,kA4,kA5,kA6,}, \ + { kB0,kB1,kB2,kB3,kB4,kB5,kB6 } } + + + #define LAYER_SET_ALL(kxx) \ + LAYER( \ + kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx, \ + kxx, \ + kxx, kxx, \ + kxx,kxx,kxx, \ + \ + kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ + kxx,kxx,kxx,kxx,kxx, \ + kxx, \ + kxx, kxx, \ + kxx,kxx,kxx ) + + #endif + #endif diff --git a/src/keyboard/ergodox/matrix.md b/src/keyboard/ergodox/matrix.md deleted file mode 100644 index 35a8fa4..0000000 --- a/src/keyboard/ergodox/matrix.md +++ /dev/null @@ -1,29 +0,0 @@ -# Documentation : Keyboard Matrix - -## Matrix [row##column] assignments - -* row and column numbers are in hex -* coordinates without brackets are unused -* left and right hands are mostly the same except that `row += 6` for the left - - ``` - ....... rows x columns = positions; assigned, unassigned ....... - ....... per hand: 6 x 7 = 42; 38, 4 ....... - ....... total: 12 x 7 = 84; 76, 8 ....... - ---------------------------------------------------------------------------- - [60][61][62][63][64][65][66] [00][01][02][03][04][05][06] - [70][71][72][73][74][75][76] [10][11][12][13][14][15][16] - [80][81][82][83][84][85] 86 20 [21][22][23][24][25][26] - [90][91][92][93][94][95][96] [30][31][32][33][34][35][36] - [A0][A1][A2][A3][A4] A5 A6 40 41 [42][43][44][45][46] - [B0] B6 50 [56] - [B1] [B5] [51] [55] - [B2][B3][B4] [52][53][54] - ``` - -------------------------------------------------------------------------------- - -Copyright © 2012 Ben Blazak -Released under The MIT License (MIT) (see "license.md") -Project located at -