changed the way layers are handled
note: NOT YET TESTED, only compiledpartial-rewrite
parent
dacc54fa1a
commit
7fa2155e05
6
src/TODO
6
src/TODO
|
@ -1,6 +0,0 @@
|
|||
- think about how to implement variable length arrays, and write some
|
||||
|
||||
- then i'll think about how to use them as stacks, to deal with layer issues
|
||||
|
||||
- implement the dvorak layout (see github issue)
|
||||
|
|
@ -37,10 +37,10 @@
|
|||
inkscape:bbox-nodes="true"
|
||||
inkscape:snap-bbox-edge-midpoints="false"
|
||||
inkscape:bbox-paths="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="997"
|
||||
inkscape:window-width="1440"
|
||||
inkscape:window-height="852"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="30"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-bbox-midpoints="true"
|
||||
showguides="true"
|
||||
|
@ -2129,14 +2129,14 @@
|
|||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ff7700;fill-opacity:1;stroke:none;font-family:Sans"
|
||||
x="433.5"
|
||||
y="341.86218"
|
||||
x="429.96448"
|
||||
y="346.10483"
|
||||
id="text9042"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan9044"
|
||||
x="433.5"
|
||||
y="341.86218">R = 220 Ω</tspan></text>
|
||||
x="429.96448"
|
||||
y="346.10483">R = (match to LEDs)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ff7700;fill-opacity:1;stroke:none;display:inline;font-family:Sans"
|
||||
|
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 158 KiB |
|
@ -1,5 +1,6 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* ergoDOX layout : QWERTY (modified from the Kinesis layout)
|
||||
* TODO: rewrite for new kbfun's
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2012 Ben Blazak <benblazak.dev@gmail.com>
|
||||
* Released under The MIT License (MIT) (see "license.md")
|
||||
|
@ -19,28 +20,8 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// aliases
|
||||
// --- basic
|
||||
#define f_prrel &kbfun_press_release
|
||||
#define f_toggl &kbfun_toggle
|
||||
#define f_l_inc &kbfun_layer_inc
|
||||
#define f_l_dec &kbfun_layer_dec
|
||||
// --- device
|
||||
#define f_btldr &kbfun_jump_to_bootloader
|
||||
// --- numpad
|
||||
#define f_np_to &kbfun_layermask_numpad_toggle
|
||||
#define f_np_on &kbfun_layermask_numpad_on
|
||||
#define f_np_of &kbfun_layermask_numpad_off
|
||||
// --- special
|
||||
#define f_l_iex &kbfun_layer_inc_exec
|
||||
#define f_l_dex &kbfun_layer_dec_exec
|
||||
#define f_2kcap &kbfun_2_keys_capslock_press_release
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
KB_MATRIX_LAYER( // layout: layer 0: default
|
||||
// unused
|
||||
0,
|
||||
|
@ -62,7 +43,8 @@ _capsLock, _A, _S, _D, _F, _G,
|
|||
0, _space,
|
||||
_ctrlR, 0, _enter,
|
||||
_altR, _pageU, _pageD ),
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
KB_MATRIX_LAYER( // layout: layer 1: function and symbol keys
|
||||
// unused
|
||||
0,
|
||||
|
@ -84,7 +66,8 @@ _bracketL, 0, _dash, _lt_kp, _gt_kp,_currencyUnit,_bracketR,
|
|||
0, _space,
|
||||
_ctrlR, 0, _enter,
|
||||
_altR, _pageU, _pageD ),
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
KB_MATRIX_LAYER( // layout: layer 2: numpad
|
||||
// unused
|
||||
0,
|
||||
|
@ -106,167 +89,213 @@ _ctrlR, 0, _enter,
|
|||
0, _0_kp,
|
||||
0, 0, 0,
|
||||
0, 0, 0 ),
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// aliases
|
||||
|
||||
// basic
|
||||
#define kprrel &kbfun_press_release
|
||||
#define ktog &kbfun_toggle
|
||||
#define ktrans &kbfun_transparent
|
||||
// --- layer push/pop functions
|
||||
#define lpush1 &kbfun_layer_push_1
|
||||
#define lpush2 &kbfun_layer_push_2
|
||||
#define lpush3 &kbfun_layer_push_3
|
||||
#define lpush4 &kbfun_layer_push_4
|
||||
#define lpush5 &kbfun_layer_push_5
|
||||
#define lpush6 &kbfun_layer_push_6
|
||||
#define lpush7 &kbfun_layer_push_7
|
||||
#define lpush8 &kbfun_layer_push_8
|
||||
#define lpush9 &kbfun_layer_push_9
|
||||
#define lpush10 &kbfun_layer_push_10
|
||||
#define lpop1 &kbfun_layer_pop_1
|
||||
#define lpop2 &kbfun_layer_pop_2
|
||||
#define lpop3 &kbfun_layer_pop_3
|
||||
#define lpop4 &kbfun_layer_pop_4
|
||||
#define lpop5 &kbfun_layer_pop_5
|
||||
#define lpop6 &kbfun_layer_pop_6
|
||||
#define lpop7 &kbfun_layer_pop_7
|
||||
#define lpop8 &kbfun_layer_pop_8
|
||||
#define lpop9 &kbfun_layer_pop_9
|
||||
#define lpop10 &kbfun_layer_pop_10
|
||||
// ---
|
||||
|
||||
// device
|
||||
#define dbtldr &kbfun_jump_to_bootloader
|
||||
|
||||
// special
|
||||
#define s2kcap &kbfun_2_keys_capslock_press_release
|
||||
#define slpunum &kbfun_layer_push_numpad
|
||||
#define slponum &kbfun_layer_pop_numpad
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
KB_MATRIX_LAYER( // press: layer 0: default
|
||||
// unused
|
||||
NULL,
|
||||
// left hand
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_l_inc,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_2kcap,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_l_inc,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel, NULL,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, lpush1,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, lpush1,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, NULL,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel,
|
||||
// right hand
|
||||
f_np_to,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_l_inc,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_2kcap,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
NULL,f_prrel,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel ),
|
||||
// --------------------------------------------------------------------
|
||||
slpunum, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
lpush1, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
NULL, kprrel,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel ),
|
||||
|
||||
|
||||
KB_MATRIX_LAYER( // press: layer 1: function and symbol keys
|
||||
// unused
|
||||
NULL,
|
||||
// left hand
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel, NULL,f_l_dec,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_2kcap,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel, NULL,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, NULL, lpop1,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, NULL,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, NULL,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel,
|
||||
// right hand
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel, NULL,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
NULL,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_2kcap,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
NULL,f_prrel,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel ),
|
||||
// --------------------------------------------------------------------
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, NULL, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
NULL, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
NULL, kprrel,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel ),
|
||||
|
||||
|
||||
KB_MATRIX_LAYER( // press: layer 2: numpad
|
||||
// unused
|
||||
NULL,
|
||||
// left hand
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, kprrel, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans,
|
||||
// right hand
|
||||
f_np_to, NULL,f_np_to,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL, NULL,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL, NULL,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL, NULL,f_prrel,f_prrel, NULL,
|
||||
NULL,f_prrel,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL ),
|
||||
// --------------------------------------------------------------------
|
||||
slponum, ktrans,slponum, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, ktrans, kprrel, kprrel, ktrans,
|
||||
ktrans, kprrel,
|
||||
ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans ),
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
KB_MATRIX_LAYER( // release: layer 0: default
|
||||
// unused
|
||||
NULL,
|
||||
// left hand
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_2kcap,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_l_dec,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel, NULL,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, NULL,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, lpop1,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, NULL,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel,
|
||||
// right hand
|
||||
NULL,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_l_dec,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_2kcap,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
NULL,f_prrel,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel ),
|
||||
// --------------------------------------------------------------------
|
||||
NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
lpop1, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
NULL, kprrel,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel ),
|
||||
|
||||
|
||||
KB_MATRIX_LAYER( // release: layer 1: function and symbol keys
|
||||
// unused
|
||||
NULL,
|
||||
// left hand
|
||||
NULL,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel, NULL, NULL,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_2kcap,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel, NULL,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,
|
||||
NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, NULL, NULL,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, NULL,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, NULL,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel,
|
||||
// right hand
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel, NULL,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
NULL,f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,f_2kcap,
|
||||
f_prrel,f_prrel,f_prrel,f_prrel,f_prrel,
|
||||
NULL,f_prrel,
|
||||
f_prrel, NULL,f_prrel,
|
||||
f_prrel,f_prrel,f_prrel ),
|
||||
// --------------------------------------------------------------------
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, NULL, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
NULL, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap,
|
||||
kprrel, kprrel, kprrel, kprrel, kprrel,
|
||||
NULL, kprrel,
|
||||
kprrel, NULL, kprrel,
|
||||
kprrel, kprrel, kprrel ),
|
||||
|
||||
|
||||
KB_MATRIX_LAYER( // release: layer 2: numpad
|
||||
// unused
|
||||
NULL,
|
||||
// left hand
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
|
||||
ktrans, kprrel, ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans,
|
||||
// right hand
|
||||
NULL, NULL, NULL,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL, NULL,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL, NULL,f_prrel,f_prrel,f_prrel,f_prrel, NULL,
|
||||
NULL, NULL,f_prrel,f_prrel, NULL,
|
||||
NULL,f_prrel,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL ),
|
||||
// --------------------------------------------------------------------
|
||||
NULL, ktrans, NULL, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
|
||||
ktrans, ktrans, kprrel, kprrel, ktrans,
|
||||
ktrans, kprrel,
|
||||
ktrans, ktrans, ktrans,
|
||||
ktrans, ktrans, ktrans ),
|
||||
|
||||
|
||||
KB_MATRIX_LAYER( // release: layer 3: nothing (just making sure unused
|
||||
// functions don't get compiled
|
||||
// out)
|
||||
// functions don't get compiled out)
|
||||
// unused
|
||||
NULL,
|
||||
// other
|
||||
f_prrel,f_btldr, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_toggl, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_l_inc, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_l_dec, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_l_iex, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_l_dex, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_2kcap, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_np_to, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_np_on, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
f_np_of, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
// --------------------------------------------------------------------
|
||||
kprrel, lpush8, lpop8, NULL, NULL, NULL, NULL, NULL,
|
||||
ktog, lpush9, lpop9, NULL, NULL, NULL, NULL, NULL,
|
||||
ktrans,lpush10, lpop10, NULL, NULL, NULL, NULL, NULL,
|
||||
lpush1, lpop1, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
lpush2, lpop2, dbtldr, NULL, NULL, NULL, NULL, NULL,
|
||||
lpush3, lpop3, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
lpush4, lpop4, s2kcap, NULL, NULL, NULL, NULL, NULL,
|
||||
lpush5, lpop5,slpunum, NULL, NULL, NULL, NULL, NULL,
|
||||
lpush6, lpop6,slponum, NULL, NULL, NULL, NULL, NULL,
|
||||
lpush7, lpop7, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -87,48 +87,6 @@ void _kbfun_press_release(bool press, uint8_t keycode) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set current layer
|
||||
* - Sets any keys currently set to the overall current layer to the new layer,
|
||||
* and then sets the overall current layer
|
||||
*
|
||||
* Note
|
||||
* - Leaving all non-current layer values alone allows changing layers while
|
||||
* maintaining a possibly enabled layer mask (as might be used to implement
|
||||
* firmware enabled numlock)
|
||||
*/
|
||||
void _kbfun_layer_set_current(uint8_t layer) {
|
||||
// don't switch to out-of-bounds layers
|
||||
if ( layer < 0 || layer >= KB_LAYERS )
|
||||
return;
|
||||
|
||||
for (uint8_t row=0; row<KB_ROWS; row++)
|
||||
for (uint8_t col=0; col<KB_COLUMNS; col++)
|
||||
// if a key is set to a non-current layer, leave it
|
||||
if (main_layers_press[row][col] == main_layers_current)
|
||||
main_layers_press[row][col] = layer;
|
||||
|
||||
main_layers_current = layer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set layer mask
|
||||
* - Sets the specified key positions to the specified layer
|
||||
*/
|
||||
void _kbfun_layer_set_mask(
|
||||
uint8_t layer,
|
||||
bool positions[KB_ROWS][KB_COLUMNS] ) {
|
||||
|
||||
// don't switch to out-of-bounds layers
|
||||
if ( layer < 0 || layer >= KB_LAYERS )
|
||||
return;
|
||||
|
||||
for (uint8_t row=0; row<KB_ROWS; row++)
|
||||
for (uint8_t col=0; col<KB_COLUMNS; col++)
|
||||
if (positions[row][col])
|
||||
main_layers_press[row][col] = layer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is the given keycode pressed?
|
||||
*/
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
void _kbfun_press_release (bool press, uint8_t keycode);
|
||||
void _kbfun_layer_set_current (uint8_t layer);
|
||||
void _kbfun_layer_set_mask ( uint8_t layer,
|
||||
bool positions[KB_ROWS][KB_COLUMNS] );
|
||||
bool _kbfun_is_pressed (uint8_t keycode);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,21 +18,38 @@
|
|||
// basic
|
||||
void kbfun_press_release (void);
|
||||
void kbfun_toggle (void);
|
||||
void kbfun_layer_inc (void);
|
||||
void kbfun_layer_dec (void);
|
||||
void kbfun_transparent (void);
|
||||
// --- layer push/pop functions
|
||||
void kbfun_layer_push_1 (void);
|
||||
void kbfun_layer_push_2 (void);
|
||||
void kbfun_layer_push_3 (void);
|
||||
void kbfun_layer_push_4 (void);
|
||||
void kbfun_layer_push_5 (void);
|
||||
void kbfun_layer_push_6 (void);
|
||||
void kbfun_layer_push_7 (void);
|
||||
void kbfun_layer_push_8 (void);
|
||||
void kbfun_layer_push_9 (void);
|
||||
void kbfun_layer_push_10 (void);
|
||||
void kbfun_layer_pop_1 (void);
|
||||
void kbfun_layer_pop_2 (void);
|
||||
void kbfun_layer_pop_3 (void);
|
||||
void kbfun_layer_pop_4 (void);
|
||||
void kbfun_layer_pop_5 (void);
|
||||
void kbfun_layer_pop_6 (void);
|
||||
void kbfun_layer_pop_7 (void);
|
||||
void kbfun_layer_pop_8 (void);
|
||||
void kbfun_layer_pop_9 (void);
|
||||
void kbfun_layer_pop_10 (void);
|
||||
// ---
|
||||
|
||||
|
||||
// device
|
||||
void kbfun_jump_to_bootloader (void);
|
||||
|
||||
// numpad
|
||||
void kbfun_layermask_numpad_toggle (void);
|
||||
void kbfun_layermask_numpad_on (void);
|
||||
void kbfun_layermask_numpad_off (void);
|
||||
|
||||
// special
|
||||
void kbfun_layer_inc_exec (void);
|
||||
void kbfun_layer_dec_exec (void);
|
||||
void kbfun_2_keys_capslock_press_release (void);
|
||||
void kbfun_layer_push_numpad (void);
|
||||
void kbfun_layer_pop_numpad (void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,12 +14,17 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define MAX_LAYER_PUSH_POP_FUNCTIONS 10
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// convenience macros
|
||||
#define layer main_arg_layer
|
||||
#define row main_arg_row
|
||||
#define col main_arg_col
|
||||
#define is_pressed main_arg_is_pressed
|
||||
#define was_pressed main_arg_was_pressed
|
||||
#define LAYER main_arg_layer
|
||||
#define LAYER_OFFSET main_arg_layer_offset
|
||||
#define ROW main_arg_row
|
||||
#define COL main_arg_col
|
||||
#define IS_PRESSED main_arg_is_pressed
|
||||
#define WAS_PRESSED main_arg_was_pressed
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -31,8 +36,8 @@
|
|||
* Generate a normal keypress or keyrelease
|
||||
*/
|
||||
void kbfun_press_release(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
_kbfun_press_release(is_pressed, keycode);
|
||||
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
|
||||
_kbfun_press_release(IS_PRESSED, keycode);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -43,7 +48,7 @@ void kbfun_press_release(void) {
|
|||
* Toggle the key pressed or unpressed
|
||||
*/
|
||||
void kbfun_toggle(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
|
||||
|
||||
if (_kbfun_is_pressed(keycode))
|
||||
_kbfun_press_release(false, keycode);
|
||||
|
@ -53,27 +58,285 @@ void kbfun_toggle(void) {
|
|||
|
||||
/*
|
||||
* [name]
|
||||
* Increase layer
|
||||
* Transparent
|
||||
*
|
||||
* [description]
|
||||
* Increment the current layer by the value specified in the keymap (for all
|
||||
* non-masked keys)
|
||||
* Execute the key that would have been executed if the current layer was not
|
||||
* active
|
||||
*/
|
||||
void kbfun_layer_inc(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
_kbfun_layer_set_current(main_layers_current + keycode);
|
||||
void kbfun_transparent(void) {
|
||||
LAYER_OFFSET++;
|
||||
LAYER = main_layers_peek(LAYER_OFFSET);
|
||||
main_exec_key();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* layer push/pop functions
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
static layer_ids[MAX_LAYER_PUSH_POP_FUNCTIONS];
|
||||
|
||||
static void layer_push(uint8_t local_id) {
|
||||
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
|
||||
main_layers_pop_id(layer_ids[local_id]);
|
||||
layer_ids[local_id] = main_layers_push(keycode);
|
||||
}
|
||||
|
||||
static void layer_pop(uint8_t local_id) {
|
||||
main_layers_pop_id(layer_ids[local_id]);
|
||||
layer_ids[local_id] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Decrease layer
|
||||
* Layer push #1
|
||||
*
|
||||
* [description]
|
||||
* Decrement the current layer by the value specified in the keymap (for all
|
||||
* non-masked keys)
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_dec(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
_kbfun_layer_set_current(main_layers_current - keycode);
|
||||
void kbfun_layer_push_1(void) {
|
||||
layer_push(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #1
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_1(void) {
|
||||
layer_pop(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #2
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_2(void) {
|
||||
layer_push(2);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #2
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_2(void) {
|
||||
layer_pop(2);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #3
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_3(void) {
|
||||
layer_push(3);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #3
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_3(void) {
|
||||
layer_pop(3);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #4
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_4(void) {
|
||||
layer_push(4);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #4
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_4(void) {
|
||||
layer_pop(4);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #5
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_5(void) {
|
||||
layer_push(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #5
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_5(void) {
|
||||
layer_pop(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #6
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_6(void) {
|
||||
layer_push(6);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #6
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_6(void) {
|
||||
layer_pop(6);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #7
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_7(void) {
|
||||
layer_push(7);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #7
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_7(void) {
|
||||
layer_pop(7);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #8
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_8(void) {
|
||||
layer_push(8);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #8
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_8(void) {
|
||||
layer_pop(8);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #9
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_9(void) {
|
||||
layer_push(9);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #9
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_9(void) {
|
||||
layer_pop(9);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer push #10
|
||||
*
|
||||
* [description]
|
||||
* Push a layer element containing the layer value specified in the keymap to
|
||||
* the top of the stack, and record the id of that layer element
|
||||
*/
|
||||
void kbfun_layer_push_10(void) {
|
||||
layer_push(10);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Layer pop #10
|
||||
*
|
||||
* [description]
|
||||
* Pop the layer element created by the corresponding "layer push" function
|
||||
* out of the layer stack (no matter where it is in the stack, without
|
||||
* touching any other elements)
|
||||
*/
|
||||
void kbfun_layer_pop_10(void) {
|
||||
layer_pop(10);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* key functions : numpad : code
|
||||
*
|
||||
* Numpad functions
|
||||
* - Functions to implement an embedded numpad
|
||||
*
|
||||
* Notes
|
||||
* - The numpad is toggled by shifting (without changing the overall current
|
||||
* layer) the layer of the keys specified in this function to the value
|
||||
* specified in the keymap
|
||||
* - When the numpad is toggled, the numlock is set to on (for active) or off
|
||||
* (for inactive) as well
|
||||
* - All these functions cooperate, but if more than one layer mask of this
|
||||
* type is used (by a different set of functions) at the same time, the
|
||||
* second will override the first, and any keys covered by both will be reset
|
||||
* to the overall current layer when either is released (even if the other is
|
||||
* still pressed)
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2012 Ben Blazak <benblazak.dev@gmail.com>
|
||||
* Released under The MIT License (MIT) (see "license.md")
|
||||
* Project located at <https://github.com/benblazak/ergodox-firmware>
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "../../../lib-other/pjrc/usb_keyboard/usb_keyboard.h"
|
||||
#include "../../../lib/usb/usage-page/keyboard.h"
|
||||
#include "../../../keyboard/layout.h"
|
||||
#include "../../../keyboard/matrix.h"
|
||||
#include "../../../main.h"
|
||||
#include "../public.h"
|
||||
#include "../private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// convenience macros
|
||||
#define layer main_arg_layer
|
||||
#define row main_arg_row
|
||||
#define col main_arg_col
|
||||
#define is_pressed main_arg_is_pressed
|
||||
#define was_pressed main_arg_was_pressed
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// vars
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static bool _numpad_activated = false;
|
||||
|
||||
static bool _layer_mask[KB_ROWS][KB_COLUMNS] =
|
||||
KB_MATRIX_LAYER(
|
||||
// unused
|
||||
0,
|
||||
|
||||
// left hand
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 0, 0, 0,
|
||||
0, 0,
|
||||
0, 0, 0,
|
||||
0, 0, 0,
|
||||
|
||||
// right hand
|
||||
1, 0, 1, 1, 1, 1, 0,
|
||||
0, 0, 1, 1, 1, 1, 0,
|
||||
0, 1, 1, 1, 1, 0,
|
||||
0, 0, 1, 1, 1, 1, 0,
|
||||
0, 0, 1, 1, 0,
|
||||
0, 1,
|
||||
0, 0, 0,
|
||||
0, 0, 0 );
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static inline void _toggle_numlock(void) {
|
||||
_kbfun_press_release(true, KEYPAD_NumLock_Clear);
|
||||
usb_keyboard_send();
|
||||
_kbfun_press_release(false, KEYPAD_NumLock_Clear);
|
||||
usb_keyboard_send();
|
||||
}
|
||||
|
||||
static void _toggle_numpad(uint8_t numpad_layer) {
|
||||
if (_numpad_activated) {
|
||||
// deactivate numpad
|
||||
_kbfun_layer_set_mask(main_layers_current, _layer_mask);
|
||||
_numpad_activated = false;
|
||||
|
||||
// if: numlock on
|
||||
if (keyboard_leds & (1<<0))
|
||||
_toggle_numlock();
|
||||
} else {
|
||||
// activate numpad
|
||||
_kbfun_layer_set_mask(numpad_layer, _layer_mask);
|
||||
_numpad_activated = true;
|
||||
|
||||
// if: numlock off
|
||||
if (!(keyboard_leds & (1<<0)))
|
||||
_toggle_numlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// public functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Numpad toggle
|
||||
*
|
||||
* [description]
|
||||
* Toggles the numpad and sets numlock on (for active) or off (for inactive)
|
||||
* with it, if it's not already in that state
|
||||
*/
|
||||
void kbfun_layermask_numpad_toggle(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
_toggle_numpad(keycode);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Numpad on
|
||||
*
|
||||
* [description]
|
||||
* Set the numpad on (along with numlock, if it's not already)
|
||||
*/
|
||||
void kbfun_layermask_numpad_on(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
if (!_numpad_activated)
|
||||
_toggle_numpad(keycode);
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Numpad off
|
||||
*
|
||||
* [description]
|
||||
* Set the numpad off (along with numlock, if it's not already)
|
||||
*/
|
||||
void kbfun_layermask_numpad_off(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
if (_numpad_activated)
|
||||
_toggle_numpad(keycode);
|
||||
}
|
||||
|
|
@ -19,66 +19,16 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
// convenience macros
|
||||
#define layer main_arg_layer
|
||||
#define row main_arg_row
|
||||
#define col main_arg_col
|
||||
#define is_pressed main_arg_is_pressed
|
||||
#define was_pressed main_arg_was_pressed
|
||||
#define LAYER main_arg_layer
|
||||
#define LAYER_OFFSET main_arg_layer_offset
|
||||
#define ROW main_arg_row
|
||||
#define COL main_arg_col
|
||||
#define IS_PRESSED main_arg_is_pressed
|
||||
#define WAS_PRESSED main_arg_was_pressed
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Increase layer, Execute key
|
||||
*
|
||||
* [description]
|
||||
* Increment the current layer by the value specified in the keymap (for all
|
||||
* non-masked keys), and execute (usually press|release) the key in the same
|
||||
* position on that new layer
|
||||
*
|
||||
* [note]
|
||||
* Meant to be paired with `kbfun_layer_dec_exec()`
|
||||
*/
|
||||
void kbfun_layer_inc_exec(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
|
||||
// switch layers
|
||||
_kbfun_layer_set_current(main_layers_current + keycode);
|
||||
|
||||
// exececute second key (in the same position)
|
||||
// - `layer+keycode` will be constant (under normal circumstances)
|
||||
// between the press and release
|
||||
layer += keycode;
|
||||
main_exec_key();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Decrease layer, Execute key
|
||||
*
|
||||
* [description]
|
||||
* Decrement the current layer by the value specified in the keymap (for all
|
||||
* non-masked keys), and execute (usually press|release) the key in the same
|
||||
* position on that new layer
|
||||
*
|
||||
* [note]
|
||||
* Meant to be paired with `kbfun_layer_inc_exec()`
|
||||
*/
|
||||
void kbfun_layer_dec_exec(void) {
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
|
||||
// switch layers
|
||||
_kbfun_layer_set_current(main_layers_current - keycode);
|
||||
|
||||
// exececute second key (in the same position)
|
||||
// - `layer+keycode` will be constant (under normal circumstances)
|
||||
// between the press and release
|
||||
layer += keycode;
|
||||
main_exec_key();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Two keys => capslock
|
||||
|
@ -99,15 +49,15 @@ void kbfun_2_keys_capslock_press_release(void) {
|
|||
static bool lshift_pressed;
|
||||
static bool rshift_pressed;
|
||||
|
||||
uint8_t keycode = kb_layout_get(layer, row, col);
|
||||
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
|
||||
|
||||
if (!is_pressed) keys_pressed--;
|
||||
if (!IS_PRESSED) keys_pressed--;
|
||||
|
||||
// take care of the key that was actually pressed
|
||||
_kbfun_press_release(is_pressed, keycode);
|
||||
_kbfun_press_release(IS_PRESSED, keycode);
|
||||
|
||||
// take care of capslock (only on the press of the 2nd key)
|
||||
if (keys_pressed == 1 && is_pressed) {
|
||||
if (keys_pressed == 1 && IS_PRESSED) {
|
||||
// save the state of left and right shift
|
||||
lshift_pressed = _kbfun_is_pressed(KEY_LeftShift);
|
||||
rshift_pressed = _kbfun_is_pressed(KEY_RightShift);
|
||||
|
@ -128,6 +78,61 @@ void kbfun_2_keys_capslock_press_release(void) {
|
|||
_kbfun_press_release(true, KEY_RightShift);
|
||||
}
|
||||
|
||||
if (is_pressed) keys_pressed++;
|
||||
if (IS_PRESSED) keys_pressed++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* numpad functions
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
static uint8_t numpad_layer_id;
|
||||
|
||||
static inline void numpad_toggle_numlock(void) {
|
||||
_kbfun_press_release(true, KEYPAD_NumLock_Clear);
|
||||
usb_keyboard_send();
|
||||
_kbfun_press_release(false, KEYPAD_NumLock_Clear);
|
||||
usb_keyboard_send();
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Numpad on
|
||||
*
|
||||
* [description]
|
||||
* Set the numpad to on (put the numpad layer, specified in the keymap, in an
|
||||
* element at the top of the layer stack, and record that element's id) and
|
||||
* toggle numlock (regardless of whether or not numlock is currently on)
|
||||
*
|
||||
* [note]
|
||||
* Meant to be assigned (along with "numpad off") instead of a normal numlock
|
||||
* key
|
||||
*/
|
||||
void kbfun_layer_push_numpad(void) {
|
||||
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
|
||||
main_layers_pop_id(numpad_layer_id);
|
||||
numpad_layer_id = main_layers_push(keycode);
|
||||
numpad_toggle_numlock();
|
||||
}
|
||||
|
||||
/*
|
||||
* [name]
|
||||
* Numpad off
|
||||
*
|
||||
* [description]
|
||||
* Set the numpad to off (pop the layer element created by "numpad on" out of
|
||||
* the stack) and toggle numlock (regardless of whether or not numlock is
|
||||
* currently on)
|
||||
*
|
||||
* [note]
|
||||
* Meant to be assigned (along with "numpad on") instead of a normal numlock
|
||||
* key
|
||||
*/
|
||||
void kbfun_layer_pop_numpad(void) {
|
||||
main_layers_pop_id(numpad_layer_id);
|
||||
numpad_layer_id = 0;
|
||||
numpad_toggle_numlock();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
|
|
148
src/main.c
148
src/main.c
|
@ -20,20 +20,23 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define MAX_ACTIVE_LAYERS 20
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static bool _main_kb_is_pressed[KB_ROWS][KB_COLUMNS];
|
||||
bool (*main_kb_is_pressed)[KB_ROWS][KB_COLUMNS] = &_main_kb_is_pressed;
|
||||
|
||||
static bool _main_kb_was_pressed[KB_ROWS][KB_COLUMNS];
|
||||
bool (*main_kb_was_pressed)[KB_ROWS][KB_COLUMNS] = &_main_kb_was_pressed;
|
||||
|
||||
uint8_t main_layers_current;
|
||||
uint8_t main_layers_press[KB_ROWS][KB_COLUMNS];
|
||||
uint8_t main_layers_release[KB_ROWS][KB_COLUMNS];
|
||||
uint8_t main_layers_pressed[KB_ROWS][KB_COLUMNS];
|
||||
|
||||
uint8_t main_loop_row;
|
||||
uint8_t main_loop_col;
|
||||
|
||||
uint8_t main_arg_layer;
|
||||
uint8_t main_arg_layer_offset;
|
||||
uint8_t main_arg_row;
|
||||
uint8_t main_arg_col;
|
||||
bool main_arg_is_pressed;
|
||||
|
@ -73,11 +76,11 @@ int main(void) {
|
|||
// - see the keyboard layout file ("keyboard/ergodox/layout/*.c") for
|
||||
// which key is assigned which function (per layer)
|
||||
// - see "lib/key-functions/public/*.c" for the function definitions
|
||||
#define row main_loop_row
|
||||
#define col main_loop_col
|
||||
#define layer main_arg_layer
|
||||
#define is_pressed main_arg_is_pressed
|
||||
#define was_pressed main_arg_was_pressed
|
||||
#define row main_loop_row
|
||||
#define col main_loop_col
|
||||
#define layer main_arg_layer
|
||||
#define is_pressed main_arg_is_pressed
|
||||
#define was_pressed main_arg_was_pressed
|
||||
for (row=0; row<KB_ROWS; row++) {
|
||||
for (col=0; col<KB_COLUMNS; col++) {
|
||||
is_pressed = (*main_kb_is_pressed)[row][col];
|
||||
|
@ -85,15 +88,16 @@ int main(void) {
|
|||
|
||||
if (is_pressed != was_pressed) {
|
||||
if (is_pressed) {
|
||||
layer = main_layers_press[row][col];
|
||||
main_layers_release[row][col] = layer;
|
||||
layer = main_layers_peek(0);
|
||||
main_layers_pressed[row][col] = layer;
|
||||
} else {
|
||||
layer = main_layers_release[row][col];
|
||||
layer = main_layers_pressed[row][col];
|
||||
}
|
||||
|
||||
// set remaining vars, and "execute" key
|
||||
main_arg_row = row;
|
||||
main_arg_col = col;
|
||||
main_arg_row = row;
|
||||
main_arg_col = col;
|
||||
main_arg_layer_offset = 0;
|
||||
main_exec_key();
|
||||
}
|
||||
}
|
||||
|
@ -150,5 +154,121 @@ void main_exec_key(void) {
|
|||
(*key_function)();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Layer Functions
|
||||
* ----------------------------------------------------------------------------
|
||||
* We keep track of which layer is foremost by placing it on a stack. Layers
|
||||
* may appear in the stack more than once. The base layer will always be
|
||||
* layer-0.
|
||||
*
|
||||
* Implemented as a fixed size stack.
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
struct layers {
|
||||
uint8_t layer;
|
||||
uint8_t id;
|
||||
};
|
||||
struct layers_info {
|
||||
uint8_t head;
|
||||
bool ids_in_use[MAX_ACTIVE_LAYERS];
|
||||
};
|
||||
|
||||
static struct layers layers[MAX_ACTIVE_LAYERS];
|
||||
static struct layers_info layers_info = {
|
||||
// .head = 0, // default
|
||||
.ids_in_use = {true}, // id 0 = true; id's 1..max = false
|
||||
};
|
||||
|
||||
/*
|
||||
* peek()
|
||||
*
|
||||
* Arguments
|
||||
* - 'offset': the offset (down the stack) from the head element
|
||||
*
|
||||
* Returns
|
||||
* - success: the layer-number of the requested element (which may be 0)
|
||||
* - failure: 0 (default) (out of bounds)
|
||||
*/
|
||||
uint8_t main_layers_peek(uint8_t offset) {
|
||||
if (offset > layers_info.head) // uint8_t, so they're both >0
|
||||
return 0; // default
|
||||
|
||||
return layers[layers_info.head - offset].layer;
|
||||
}
|
||||
|
||||
/*
|
||||
* push()
|
||||
*
|
||||
* Arguments
|
||||
* - 'layer': the layer-number to push to the top of the stack
|
||||
*
|
||||
* Returns
|
||||
* - success: the id assigned to the newly added element
|
||||
* - failure: 0 (the stack was already full)
|
||||
*/
|
||||
uint8_t main_layers_push(uint8_t layer) {
|
||||
if (layers_info.head == MAX_ACTIVE_LAYERS)
|
||||
return 0; // error
|
||||
|
||||
layers_info.head++;
|
||||
|
||||
for (uint8_t id=1; id<MAX_ACTIVE_LAYERS; id++)
|
||||
if (layers_info.ids_in_use[id] == false) {
|
||||
// claim the unused id
|
||||
layers_info.ids_in_use[id] = true;
|
||||
// assign the element values
|
||||
layers[layers_info.head].layer = layer;
|
||||
layers[layers_info.head].id = id;
|
||||
// return the id
|
||||
return id;
|
||||
}
|
||||
|
||||
// if no id was found
|
||||
// (this should never happen, since we check if the array's full above)
|
||||
return 0; // error
|
||||
}
|
||||
|
||||
/*
|
||||
* pop_id()
|
||||
*
|
||||
* Arguments
|
||||
* - 'id': the id of the element to pop from the stack
|
||||
*/
|
||||
void main_layers_pop_id(uint8_t id) {
|
||||
for (uint8_t i=1; i<MAX_ACTIVE_LAYERS; i++)
|
||||
if (layers[i].id == id) {
|
||||
// clear the entry
|
||||
layers[i].layer = 0;
|
||||
layers[i].id = 0;
|
||||
// if there are elements above it, move them down
|
||||
for (uint8_t pos=i+1; i<=layers_info.head; i++)
|
||||
layers[pos-1] = layers[pos];
|
||||
// decrement 'head'
|
||||
layers_info.head--;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* get_offset_id()
|
||||
*
|
||||
* Arguments
|
||||
* - 'id': the id of the element you want the offset of
|
||||
*
|
||||
* Returns
|
||||
* - success: the offset (down the stack from the head element) of the element
|
||||
* with the given id
|
||||
* - failure: 0 (default) (id unassigned)
|
||||
*/
|
||||
uint8_t main_layers_get_offset_id(uint8_t id) {
|
||||
for (uint8_t i=1; i<=layers_info.head; i++)
|
||||
if (layers[i].id == id)
|
||||
return layers_info.head - i;
|
||||
|
||||
// if no element with the given id was found
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
|
|
13
src/main.h
13
src/main.h
|
@ -20,14 +20,13 @@
|
|||
extern bool (*main_kb_is_pressed)[KB_ROWS][KB_COLUMNS];
|
||||
extern bool (*main_kb_was_pressed)[KB_ROWS][KB_COLUMNS];
|
||||
|
||||
extern uint8_t main_layers_current;
|
||||
extern uint8_t main_layers_press[KB_ROWS][KB_COLUMNS];
|
||||
extern uint8_t main_layers_release[KB_ROWS][KB_COLUMNS];
|
||||
extern uint8_t main_layers_pressed[KB_ROWS][KB_COLUMNS];
|
||||
|
||||
extern uint8_t main_loop_row;
|
||||
extern uint8_t main_loop_col;
|
||||
|
||||
extern uint8_t main_arg_layer;
|
||||
extern uint8_t main_arg_layer_offset;
|
||||
extern uint8_t main_arg_row;
|
||||
extern uint8_t main_arg_col;
|
||||
extern bool main_arg_is_pressed;
|
||||
|
@ -35,7 +34,13 @@
|
|||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void main_exec_key(void);
|
||||
void main_exec_key (void);
|
||||
|
||||
uint8_t main_layers_peek (uint8_t offset);
|
||||
uint8_t main_layers_push (uint8_t layer);
|
||||
void main_layers_pop_id (uint8_t id);
|
||||
uint8_t main_layers_get_offset_id (uint8_t id);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue