add colemak support. add sticky toggling to colemak

check in our generated layout files
pull/18/head
Jesse Vincent 11 years ago
parent 71059ad363
commit 27f9bd493c

@ -19,6 +19,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <EEPROM.h>
@ -55,6 +56,25 @@ float carriedOverY =0;
#include "keymaps.h" #include "keymaps.h"
#define EEPROM_LAYER_LOCATION 0
void save_current_layer(byte layer) {
Serial.print("telling eeprom thinks we're on layer ");
Serial.println(layer);
EEPROM.write(EEPROM_LAYER_LOCATION, layer);
}
byte load_current_layer() {
byte layer = EEPROM.read(EEPROM_LAYER_LOCATION);
Serial.print("eeprom thinks we're on layer ");
Serial.println(layer);
if (layer >= LAYERS ) {
return 0; // undefined positions get saved as 255
}
return layer;
}
void release_keys_not_being_pressed() void release_keys_not_being_pressed()
{ {
@ -282,8 +302,14 @@ void scan_matrix()
if (key_is_pressed(matrixState[row][col])) { if (key_is_pressed(matrixState[row][col])) {
active_layer = keymaps[current_layer][row][col].rawKey; active_layer = keymaps[current_layer][row][col].rawKey;
} } }
else if (! (keymaps[active_layer][row][col].flags ^ ( SWITCH_TO_LAYER))) { // switch layer and stay there
if (key_toggled_on(matrixState[row][col])) {
current_layer = active_layer = keymaps[current_layer][row][col].rawKey;
save_current_layer(current_layer);
} }
}
} }
digitalWrite(rowPins[row], HIGH); digitalWrite(rowPins[row], HIGH);
} }
@ -330,6 +356,7 @@ void setup()
Serial.begin(115200); Serial.begin(115200);
#endif #endif
setup_matrix(); setup_matrix();
current_layer = load_current_layer();
} }
void loop() void loop()

@ -347,5 +347,16 @@
#define META_NEXT_KEYMAP_MOMENTARY 0xFF #define META_NEXT_KEYMAP_MOMENTARY 0xFF
#define Key_NextKeymap (Key){ KEY_FLAGS | SWITCH_TO_LAYER | MOMENTARY, LAYER_1 } #define Key_Keymap0 (Key){ KEY_FLAGS | SWITCH_TO_LAYER , LAYER_0 }
#define Key_Keymap1 (Key){ KEY_FLAGS | SWITCH_TO_LAYER , LAYER_1 }
#define Key_Keymap2 (Key){ KEY_FLAGS | SWITCH_TO_LAYER , LAYER_2 }
#define Key_Keymap3 (Key){ KEY_FLAGS | SWITCH_TO_LAYER , LAYER_3 }
#define Key_Keymap4 (Key){ KEY_FLAGS | SWITCH_TO_LAYER , LAYER_4 }
#define Key_Keymap5 (Key){ KEY_FLAGS | SWITCH_TO_LAYER , LAYER_5 }
#define Key_Keymap0_Momentary (Key){ KEY_FLAGS | SWITCH_TO_LAYER | MOMENTARY, LAYER_0 }
#define Key_Keymap1_Momentary (Key){ KEY_FLAGS | SWITCH_TO_LAYER | MOMENTARY, LAYER_1 }
#define Key_Keymap2_Momentary (Key){ KEY_FLAGS | SWITCH_TO_LAYER | MOMENTARY, LAYER_2 }
#define Key_Keymap3_Momentary (Key){ KEY_FLAGS | SWITCH_TO_LAYER | MOMENTARY, LAYER_3 }
#define Key_Keymap4_Momentary (Key){ KEY_FLAGS | SWITCH_TO_LAYER | MOMENTARY, LAYER_4 }
#define Key_Keymap5_Momentary (Key){ KEY_FLAGS | SWITCH_TO_LAYER | MOMENTARY, LAYER_5 }

@ -1,54 +1,12 @@
#include "layouts-generated/qwerty.h" #include "layouts-generated/qwerty.h"
#include "layouts-generated/qwerty_fn2.h" #include "layouts-generated/qwerty_fn2.h"
#include "layouts-generated/colemak.h"
#include "layouts-generated/colemak_fn2.h"
static const Key keymaps[LAYERS][ROWS][COLS] = { static const Key keymaps[LAYERS][ROWS][COLS] = {
KEYMAP_QWERTY KEYMAP_QWERTY
/* { KEYMAP_QWERTY_FN2
{ Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, Key_NoKey, Key_6, Key_7, Key_8, Key_9, Key_0, Key_NoKey }, KEYMAP_COLEMAK
{ Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_NoKey, Key_NoKey, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals}, KEYMAP_COLEMAK_FN2
{ Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, Key_Tab, Key_Return, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote },
{ Key_PageDn, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Esc, Key_Return, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus},
{ Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NextKeymap, Key_NoKey, Key_NoKey, Key_NoKey, Key_NoKey, Key_NextKeymap, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt }
},
*/
KEYMAP_QWERTY_FN2
/*{
{ Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, Key_NoKey, Key_6, Key_7, Key_8, Key_9, Key_0, Key_NoKey },
{ Key_Backtick, Key_macroKey1, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_T, Key_NoKey, Key_NoKey, Key_LCurlyBracket, Key_RCurlyBracket, Key_LSquareBracket, Key_RSquareBracket, Key_P, Key_Equals},
{ Key_PageUp, Key_mouseL, Key_mouseUp, Key_mouseDn, Key_mouseR, Key_G, Key_Tab, Key_Return, Key_LArrow, Key_DnArrow, Key_UpArrow, Key_RArrow, Key_Semicolon, Key_Quote},
{ Key_PageDn, Key_Z, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_B, Key_Esc, Key_Return, Key_Pipe, Key_M, Key_Comma, Key_Period, Key_Backslash, Key_Minus},
{ Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NextKeymap, Key_NoKey, Key_NoKey, Key_NoKey, Key_NoKey, Key_NextKeymap, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt }
},
*/
{
{ Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, Key_NoKey, Key_6, Key_7, Key_8, Key_9, Key_0, Key_NoKey },
{ Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_NoKey, Key_NoKey, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals},
{ Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, Key_Tab, Key_Return, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote },
{ Key_PageDn, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Esc, Key_Return, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus},
{ Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NextKeymap, Key_NoKey, Key_NoKey, Key_NoKey, Key_NoKey, Key_NextKeymap, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt }
},
{
{ Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, Key_NoKey, Key_6, Key_7, Key_8, Key_9, Key_0, Key_NoKey },
{ Key_Backtick, Key_Q, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_T, Key_NoKey, Key_NoKey, Key_LCurlyBracket, Key_RCurlyBracket, Key_LSquareBracket, Key_RSquareBracket, Key_P, Key_Equals},
{ Key_PageUp, Key_mouseL, Key_mouseUp, Key_mouseDn, Key_mouseR, Key_G, Key_Tab, Key_Return, Key_LArrow, Key_DnArrow, Key_UpArrow, Key_RArrow, Key_Semicolon, Key_Quote},
{ Key_PageDn, Key_Z, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_B, Key_Esc, Key_Return, Key_Pipe, Key_M, Key_Comma, Key_Period, Key_Backslash, Key_Minus},
{ Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NextKeymap, Key_NoKey, Key_NoKey, Key_NoKey, Key_NoKey, Key_NextKeymap, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt }
},
{
{ Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, Key_NoKey, Key_6, Key_7, Key_8, Key_9, Key_0, Key_NoKey },
{ Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_NoKey, Key_NoKey, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals},
{ Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, Key_Tab, Key_Return, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote },
{ Key_PageDn, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Esc, Key_Return, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus},
{ Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NextKeymap, Key_NoKey, Key_NoKey, Key_NoKey, Key_NoKey, Key_NextKeymap, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt }
},
{
{ Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, Key_NoKey, Key_6, Key_7, Key_8, Key_9, Key_0, Key_NoKey },
{ Key_Backtick, Key_Q, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_T, Key_NoKey, Key_NoKey, Key_LCurlyBracket, Key_RCurlyBracket, Key_LSquareBracket, Key_RSquareBracket, Key_P, Key_Equals},
{ Key_PageUp, Key_mouseL, Key_mouseUp, Key_mouseDn, Key_mouseR, Key_G, Key_Tab, Key_Return, Key_LArrow, Key_DnArrow, Key_UpArrow, Key_RArrow, Key_Semicolon, Key_Quote},
{ Key_PageDn, Key_Z, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_B, Key_Esc, Key_Return, Key_Pipe, Key_M, Key_Comma, Key_Period, Key_Backslash, Key_Minus},
{ Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NextKeymap, Key_NoKey, Key_NoKey, Key_NoKey, Key_NoKey, Key_NextKeymap, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt }
},

@ -0,0 +1,6 @@
#define KEYMAP_COLEMAK { /* Generated keymap for COLEMAK */ {Key_skip, Key_1, Key_2, Key_3, Key_4, Key_5, Key_skip, Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip},\
{Key_Backtick, Key_Q, Key_W, Key_F, Key_P, Key_G, Key_skip, Key_skip, Key_J, Key_L, Key_U, Key_Y, Key_Semicolon, Key_Equals},\
{Key_PageUp, Key_A, Key_R, Key_S, Key_T, Key_D, Key_Tab, Key_Return, Key_H, Key_N, Key_E, Key_I, Key_O, Key_Quote},\
{Key_PageDn, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Esc, Key_Keymap0, Key_K, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus},\
{Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_Keymap3_Momentary, Key_skip, Key_skip, Key_skip, Key_skip, Key_Keymap3_Momentary, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt},\
},

@ -0,0 +1,6 @@
#define KEYMAP_COLEMAK_FN2 { /* Generated keymap for COLEMAK_FN2 */ {Key_skip, Key_1, Key_2, Key_3, Key_4, Key_5, Key_skip, Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip},\
{Key_Backtick, Key_macroKey1, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_NoKey, Key_NoKey, Key_NoKey, Key_LCurlyBracket, Key_RCurlyBracket, Key_LSquareBracket, Key_RSquareBracket, Key_NoKey, Key_Equals},\
{Key_PageUp, Key_mouseL, Key_mouseUp, Key_mouseDn, Key_mouseR, Key_NoKey, Key_Tab, Key_Return, Key_LArrow, Key_DnArrow, Key_UpArrow, Key_RArrow, Key_Semicolon, Key_Quote},\
{Key_PageDn, Key_Keymap0, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_NoKey, Key_Esc, Key_Enter, Key_Pipe, Key_NoKey, Key_Comma, Key_Period, Key_Backslash, Key_Minus},\
{Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NoKey, Key_skip, Key_skip, Key_skip, Key_skip, Key_NoKey, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt},\
},

@ -0,0 +1,6 @@
#define KEYMAP_QWERTY { /* Generated keymap for QWERTY */ {Key_skip, Key_1, Key_2, Key_3, Key_4, Key_5, Key_skip, Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip},\
{Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_skip, Key_skip, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals},\
{Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, Key_Tab, Key_Return, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote},\
{Key_PageDn, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Esc, Key_Keymap2, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus},\
{Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_Keymap1_Momentary, Key_skip, Key_skip, Key_skip, Key_skip, Key_Keymap1_Momentary, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt},\
},

@ -0,0 +1,6 @@
#define KEYMAP_QWERTY_FN2 { /* Generated keymap for QWERTY_FN2 */ {Key_skip, Key_1, Key_2, Key_3, Key_4, Key_5, Key_skip, Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip},\
{Key_Backtick, Key_macroKey1, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_T, Key_NoKey, Key_NoKey, Key_LCurlyBracket, Key_RCurlyBracket, Key_LSquareBracket, Key_RSquareBracket, Key_P, Key_Equals},\
{Key_PageUp, Key_mouseL, Key_mouseUp, Key_mouseDn, Key_mouseR, Key_G, Key_Tab, Key_Return, Key_LArrow, Key_DnArrow, Key_UpArrow, Key_RArrow, Key_Semicolon, Key_Quote},\
{Key_PageDn, Key_Keymap2, Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, Key_B, Key_Esc, Key_Enter, Key_Pipe, Key_M, Key_Comma, Key_Period, Key_Backslash, Key_Minus},\
{Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_NoKey, Key_skip, Key_skip, Key_skip, Key_skip, Key_NoKey, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt},\
},

@ -0,0 +1,6 @@
#NAME: COLEMAK
skip 1 2 3 4 5 skip skip 6 7 8 9 0 skip
` Q W F P G skip skip J L U Y ; =
PageUp A R S T D Tab Return H N E I O '
PageDn Z X C V B Esc Keymap0 K M , . / -
LGUI Backspace LShift LCtrl Keymap3_Momentary skip skip skip skip Keymap3_Momentary RCtrl RShift Space RAlt

@ -0,0 +1,6 @@
#NAME: COLEMAK_FN2
skip 1 2 3 4 5 skip skip 6 7 8 9 0 skip
` macroKey1 mouseBtnL mouseBtnM mouseBtnR NoKey NoKey NoKey { } [ ] NoKey =
PageUp mouseL mouseUp mouseDn mouseR NoKey Tab Return LArrow DnArrow UpArrow RArrow ; '
PageDn Keymap0 mouseBtnL mouseBtnM mouseBtnR NoKey Esc Enter | NoKey , . \ -
LGUI Backspace LShift LCtrl NoKey skip skip skip skip NoKey RCtrl RShift Space RAlt

@ -2,5 +2,5 @@
skip 1 2 3 4 5 skip skip 6 7 8 9 0 skip skip 1 2 3 4 5 skip skip 6 7 8 9 0 skip
` Q W E R T skip skip Y U I O P = ` Q W E R T skip skip Y U I O P =
PageUp A S D F G Tab Return H J K L ; ' PageUp A S D F G Tab Return H J K L ; '
PageDn Z X C V B Esc Enter N M , . / - PageDn Z X C V B Esc Keymap2 N M , . / -
LGUI Backspace LShift LCtrl NextKeymap skip skip skip skip NextKeymap RCtrl RShift Space RAlt LGUI Backspace LShift LCtrl Keymap1_Momentary skip skip skip skip Keymap1_Momentary RCtrl RShift Space RAlt

@ -2,5 +2,5 @@
skip 1 2 3 4 5 skip skip 6 7 8 9 0 skip skip 1 2 3 4 5 skip skip 6 7 8 9 0 skip
` macroKey1 mouseBtnL mouseBtnM mouseBtnR T NoKey NoKey { } [ ] P = ` macroKey1 mouseBtnL mouseBtnM mouseBtnR T NoKey NoKey { } [ ] P =
PageUp mouseL mouseUp mouseDn mouseR G Tab Return LArrow DnArrow UpArrow RArrow ; ' PageUp mouseL mouseUp mouseDn mouseR G Tab Return LArrow DnArrow UpArrow RArrow ; '
PageDn Z mouseBtnL mouseBtnM mouseBtnR B Esc Enter | M , . \ - PageDn Keymap2 mouseBtnL mouseBtnM mouseBtnR B Esc Enter | M , . \ -
LGUI Backspace LShift LCtrl NextKeymap skip skip skip skip NextKeymap RCtrl RShift Space RAlt LGUI Backspace LShift LCtrl NoKey skip skip skip skip NoKey RCtrl RShift Space RAlt

Loading…
Cancel
Save