Updated workman layout, added layer toggle feature

f13
Jacob McIntosh 2015-07-14 15:50:36 -05:00
parent 9fffce4cb8
commit b4e431c49b
4 changed files with 662 additions and 566 deletions

View File

@ -163,6 +163,16 @@ void kbfun_fix_shifted_press_release(void) {
#define lpop8 &kbfun_layer_pop_8
#define lpop9 &kbfun_layer_pop_9
#define lpop10 &kbfun_layer_pop_10
#define ltog1 &kbfun_layer_toggle_1
#define ltog2 &kbfun_layer_toggle_2
#define ltog3 &kbfun_layer_toggle_3
#define ltog4 &kbfun_layer_toggle_4
#define ltog5 &kbfun_layer_toggle_5
#define ltog6 &kbfun_layer_toggle_6
#define ltog7 &kbfun_layer_toggle_7
#define ltog8 &kbfun_layer_toggle_8
#define ltog9 &kbfun_layer_toggle_9
#define ltog10 &kbfun_layer_toggle_10
// device
#define dbtldr &kbfun_jump_to_bootloader
@ -230,7 +240,7 @@ KB_MATRIX_LAYER(
0, 0, 0, 0, 0, 0, 0,
/*no key*/ 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
/*no key*/ /*no key*/ MEDIAKEY_AUDIO_VOL_UP, MEDIAKEY_AUDIO_VOL_DOWN, MEDIAKEY_AUDIO_MUTE, 0, 3,
/*no key*/ /*no key*/ MEDIAKEY_AUDIO_VOL_UP, MEDIAKEY_AUDIO_VOL_DOWN, MEDIAKEY_AUDIO_MUTE, 4, 3,
// right thumb
0, 0, /*no key*/
0, 0 /*no key*/, 0 /*no key*/,
@ -252,7 +262,7 @@ KB_MATRIX_LAYER(
0, 0, 0,
// right hand
2, 0, KEYPAD_NumLock_Clear, KEYPAD_Equal, KEYPAD_Slash, KEYPAD_Asterisk, 0,
0, 0, KEYPAD_NumLock_Clear, KEYPAD_Equal, KEYPAD_Slash, KEYPAD_Asterisk, 0,
0, 0, KEYPAD_7_Home, KEYPAD_8_UpArrow, KEYPAD_9_PageUp, KEYPAD_Minus, 0,
/*no key*/ 0, KEYPAD_4_LeftArrow, KEYPAD_5, KEYPAD_6_RightArrow, KEYPAD_Plus, 0,
0, 0, KEYPAD_1_End, KEYPAD_2_DownArrow, KEYPAD_3_PageDown, KEY_ReturnEnter, 0,
@ -301,7 +311,7 @@ KB_MATRIX_LAYER(
// left thumb
/*no key*/ 0, 0,
0 /*no key*/, 0 /*no key*/, 0,
0, 0, 0,
KEY_Spacebar, 0, 0,
// right hand
0, 0, 0, 0, 0, 0, 0,
@ -312,7 +322,7 @@ KB_MATRIX_LAYER(
// right thumb
0, 0, /*no key*/
0, 0 /*no key*/, 0 /*no key*/,
0, 0, 0
0, 0, KEY_DeleteBackspace
),
// LAYER 5
KB_MATRIX_LAYER(
@ -465,7 +475,7 @@ KB_MATRIX_LAYER(
kprrel, kprrel, kprrel,
// right hand
lpush2, sinvert, sinvert, sinvert, sinvert, sinvert, kprrel,
ltog2, sinvert, sinvert, sinvert, sinvert, sinvert, kprrel,
lpush1, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
/*no key*/ kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel,
@ -495,7 +505,7 @@ KB_MATRIX_LAYER(
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ /*no key*/ mprrel, mprrel, mprrel, ktrans, lpush3,
/*no key*/ /*no key*/ mprrel, mprrel, mprrel, ltog4, ltog3,
// right thumb
ktrans, ktrans, /*no key*/
ktrans, NULL /*no key*/, NULL /*no key*/,
@ -517,7 +527,7 @@ KB_MATRIX_LAYER(
ktrans, ktrans, ktrans,
// right hand
lpop2, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
/*no key*/ ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
@ -558,26 +568,26 @@ KB_MATRIX_LAYER(
// unused
NULL /*no key*/,
// left hand
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, /*no key*/
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, /*no key*/ /*no key*/
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, /*no key*/
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, /*no key*/ /*no key*/
// left thumb
/*no key*/ NULL, NULL,
NULL /*no key*/, NULL /*no key*/, NULL,
NULL, NULL, NULL,
/*no key*/ ktrans, ktrans,
NULL /*no key*/, NULL /*no key*/, ktrans,
kprrel, ktrans, ktrans,
// right hand
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
/*no key*/ NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
/*no key*/ /*no key*/ NULL, NULL, NULL, NULL, NULL,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ /*no key*/ ktrans, ktrans, ktrans, ktrans, ktrans,
// right thumb
NULL, NULL, /*no key*/
NULL, NULL /*no key*/, NULL /*no key*/,
NULL, NULL, NULL
ktrans, ktrans, /*no key*/
ktrans, NULL /*no key*/, NULL /*no key*/,
ktrans, ktrans, kprrel
),
// LAYER 5
KB_MATRIX_LAYER(
@ -760,7 +770,7 @@ KB_MATRIX_LAYER(
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ /*no key*/ mprrel, mprrel, mprrel, ktrans, NULL,
/*no key*/ /*no key*/ mprrel, mprrel, mprrel, NULL, NULL,
// right thumb
ktrans, ktrans, /*no key*/
ktrans, NULL /*no key*/, NULL /*no key*/,
@ -782,7 +792,7 @@ KB_MATRIX_LAYER(
ktrans, ktrans, ktrans,
// right hand
NULL, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
/*no key*/ ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans,
@ -823,26 +833,26 @@ KB_MATRIX_LAYER(
// unused
NULL /*no key*/,
// left hand
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, /*no key*/
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, /*no key*/ /*no key*/
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, /*no key*/
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, /*no key*/ /*no key*/
// left thumb
/*no key*/ NULL, NULL,
NULL /*no key*/, NULL /*no key*/, NULL,
NULL, NULL, NULL,
/*no key*/ ktrans, ktrans,
NULL /*no key*/, NULL /*no key*/, ktrans,
kprrel, ktrans, ktrans,
// right hand
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
/*no key*/ NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
/*no key*/ /*no key*/ NULL, NULL, NULL, NULL, NULL,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans,
/*no key*/ /*no key*/ ktrans, ktrans, ktrans, ktrans, ktrans,
// right thumb
NULL, NULL, /*no key*/
NULL, NULL /*no key*/, NULL /*no key*/,
NULL, NULL, NULL
ktrans, ktrans, /*no key*/
ktrans, NULL /*no key*/, NULL /*no key*/,
ktrans, ktrans, kprrel
),
// LAYER 5
KB_MATRIX_LAYER(

View File

@ -51,6 +51,16 @@
void kbfun_layer_pop_8 (void);
void kbfun_layer_pop_9 (void);
void kbfun_layer_pop_10 (void);
void kbfun_layer_toggle_1 (void);
void kbfun_layer_toggle_2 (void);
void kbfun_layer_toggle_3 (void);
void kbfun_layer_toggle_4 (void);
void kbfun_layer_toggle_5 (void);
void kbfun_layer_toggle_6 (void);
void kbfun_layer_toggle_7 (void);
void kbfun_layer_toggle_8 (void);
void kbfun_layer_toggle_9 (void);
void kbfun_layer_toggle_10 (void);
// ---
// device

View File

@ -103,9 +103,17 @@ void kbfun_transparent(void) {
// layer 0 even if we will never have a push or pop function for it
static uint8_t layer_ids[1 + MAX_LAYER_PUSH_POP_FUNCTIONS];
static void layer_pop(uint8_t local_id) {
uint8_t id = layer_ids[local_id];
if (id != 0) {
main_layers_pop_id(id);
layer_ids[local_id] = 0;
}
}
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_pop(local_id);
// Only the topmost layer on the stack should be in sticky once state, pop
// the top layer if it is in sticky once state
uint8_t topSticky = main_layers_peek_sticky(0);
@ -120,7 +128,7 @@ static void layer_sticky(uint8_t local_id) {
if (IS_PRESSED) {
uint8_t topLayer = main_layers_peek(0);
uint8_t topSticky = main_layers_peek_sticky(0);
main_layers_pop_id(layer_ids[local_id]);
layer_pop(local_id);
if (topLayer == local_id) {
if (topSticky == eStickyOnceUp)
layer_ids[local_id] = main_layers_push(keycode, eStickyLock);
@ -129,7 +137,7 @@ static void layer_sticky(uint8_t local_id) {
{
// only the topmost layer on the stack should be in sticky once state
if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp) {
main_layers_pop_id(layer_ids[topLayer]);
layer_pop(topLayer);
}
layer_ids[local_id] = main_layers_push(keycode, eStickyOnceDown);
// this should be the only place we care about this flag being cleared
@ -143,7 +151,7 @@ static void layer_sticky(uint8_t local_id) {
if (topLayer == local_id) {
if (topSticky == eStickyOnceDown) {
// When releasing this sticky key, pop the layer always
main_layers_pop_id(layer_ids[local_id]);
layer_pop(local_id);
if (!main_arg_any_non_trans_key_pressed) {
// If no key defined for this layer (a non-transparent key)
// was pressed, push the layer again, but in the
@ -155,9 +163,14 @@ static void layer_sticky(uint8_t local_id) {
}
}
static void layer_pop(uint8_t local_id) {
main_layers_pop_id(layer_ids[local_id]);
layer_ids[local_id] = 0;
static void layer_toggle(uint8_t local_id) {
if (layer_ids[local_id] != 0) {
layer_pop(local_id);
}
else
{
layer_push(local_id);
}
}
/*
@ -224,13 +237,24 @@ void kbfun_layer_pop_1(void) {
layer_pop(1);
}
/*
* [name]
* Layer toggle #1
*
* [description]
* If the layer element is already in the layer stack, pop it. Otherwise,
* push the layer element to the top of the stack.
*/
void kbfun_layer_toggle_1(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_2(void) {
layer_push(2);
@ -252,21 +276,29 @@ void kbfun_layer_sticky_2 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_2(void) {
layer_pop(2);
}
/*
* [name]
* Layer toggle #2
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_2(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_3(void) {
layer_push(3);
@ -288,21 +320,29 @@ void kbfun_layer_sticky_3 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_3(void) {
layer_pop(3);
}
/*
* [name]
* Layer toggle #3
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_3(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_4(void) {
layer_push(4);
@ -324,21 +364,29 @@ void kbfun_layer_sticky_4 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_4(void) {
layer_pop(4);
}
/*
* [name]
* Layer toggle #4
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_4(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_5(void) {
layer_push(5);
@ -360,21 +408,29 @@ void kbfun_layer_sticky_5 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_5(void) {
layer_pop(5);
}
/*
* [name]
* Layer toggle #5
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_5(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_6(void) {
layer_push(6);
@ -396,21 +452,29 @@ void kbfun_layer_sticky_6 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_6(void) {
layer_pop(6);
}
/*
* [name]
* Layer toggle #6
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_6(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_7(void) {
layer_push(7);
@ -432,21 +496,29 @@ void kbfun_layer_sticky_7 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_7(void) {
layer_pop(7);
}
/*
* [name]
* Layer toggle #7
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_7(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_8(void) {
layer_push(8);
@ -468,21 +540,29 @@ void kbfun_layer_sticky_8 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_8(void) {
layer_pop(8);
}
/*
* [name]
* Layer toggle #8
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_8(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_9(void) {
layer_push(9);
@ -504,21 +584,29 @@ void kbfun_layer_sticky_9 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_9(void) {
layer_pop(9);
}
/*
* [name]
* Layer toggle #9
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_9(void) {
layer_toggle(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
* See the description of kbfun_layer_push_1()
*/
void kbfun_layer_push_10(void) {
layer_push(10);
@ -540,14 +628,23 @@ void kbfun_layer_sticky_10 (void) {
* 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)
* See the description of kbfun_layer_pop_1()
*/
void kbfun_layer_pop_10(void) {
layer_pop(10);
}
/*
* [name]
* Layer toggle #10
*
* [description]
* See the description of kbfun_layer_toggle_1()
*/
void kbfun_layer_toggle_10(void) {
layer_toggle(10);
}
/* ----------------------------------------------------------------------------
* ------------------------------------------------------------------------- */

View File

@ -250,11 +250,10 @@ uint8_t main_layers_push(uint8_t layer, uint8_t sticky) {
*/
void main_layers_pop_id(uint8_t id) {
// look for the element with the id we want to pop
for (uint8_t element=1; element<=layers_head; element++)
for (uint8_t element=1; element<=layers_head; element++) {
// if we find it
if (layers[element].id == id) {
// move all layers above it down one
for (; element<layers_head; element++) {
for(; element<layers_head; ++element) {
layers[element].layer = layers[element+1].layer;
layers[element].id = layers[element+1].id;
}
@ -264,29 +263,9 @@ void main_layers_pop_id(uint8_t id) {
// record keeping
layers_ids_in_use[id] = false;
layers_head--;
return;
}
}
}
/*
* 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) {
// look for the element with the id we want to get the offset of
for (uint8_t element=1; element<=layers_head; element++)
// if we find it
if (layers[element].id == id)
return (layers_head - element);
return 0; // default, or error
}
/* ----------------------------------------------------------------------------