1
0
Fork 0

[Keymap] Finalize Keymap Planck/Samuel (#8005)

* indent and layout changes

* finalizations

* use layout macros here instead of the raw matrix arrays
This commit is contained in:
Samuel Jahnke 2020-01-27 20:47:36 -05:00 committed by Drashna Jaelre
parent 1f0404e3c5
commit 92c62352cf
2 changed files with 465 additions and 639 deletions

View file

@ -7,85 +7,100 @@ before, so bear with me.
* Layers * Layers
#+BEGIN_COMMENT #+BEGIN_COMMENT
#+NAME: empty-layer #+NAME: empty-layer
| <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> | <6> |
|--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
| - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | - | - | - | - | - |
| - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | - | - | - | - | - |
| - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | - | - | - | - | - |
| - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | - | - | - | - | - |
|--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
#+END_COMMENT #+END_COMMENT
This is my "pretty" org mode organized table for my main dvorak layer. If you This is my "pretty" org mode organized table for my main dvorak layer. If you
don't use org mode, it won't be that exciting, but if you enjoy working in org don't use org mode, it won't be that exciting, but if you enjoy working in org
mode, you can edit this table directly, and this file is tangled to the actual mode, you can edit this table directly, and this file is tangled to the actual
keymap. No more organizing spaces or converting to and from comments. keymap. No more organizing spaces or converting to and from comments.
#+NAME: home-layer #+NAME: home-layer
|--------+--------+------+------+------+-----+-----+-----+------+-------+--------+--------| |--------+--------+------+------+-----+-----+------+-----+------+-------+--------+--------|
| T_LRSE | QUOT | COMM | DOT | P | Y | F | G | C | R | L | T_RRSE | | T_LRSE | QUOT | COMM | DOT | P | Y | F | G | C | R | L | T_RRSE |
| T_LSFT | A | O | E | U | I | D | H | T | N | S | T_RSFT | | T_LSFT | A | O | E | U | I | D | H | T | N | S | T_RSFT |
| T_LCTL | SCLN | Q | J | K | X | B | M | W | V | Z | T_RCTL | | T_LCTL | SCLN | Q | J | K | X | B | M | W | V | Z | T_RCTL |
| T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | T_RGUI | | T_LGUI | T_LALT | UP | DOWN | SPC | EQL | GRAVE | SPC | LEFT | RIGHT | T_RALT | T_RGUI |
|--------+--------+------+------+------+-----+-----+-----+------+-------+--------+--------| |--------+--------+------+------+-----+-----+------+-----+------+-------+--------+--------|
This qwerty layout is just so normal people can try out the board. Tap keys Tap keys. Used only with the "T_" keys above.
would need to be customized I think, more on that later. I also put another
dvorak key here because I have nightmares of getting trapped in this forsaken
layout.
#+NAME: qwerty-layer #+NAME: tap-layer
|--------+--------+----+------+------+-----+-----+-----+------+-------+--------+--------| |----------+------+---+---+---+---+---+---+---+---+------+----------|
| T_LRSE | Q | W | E | R | T | Y | U | I | O | P | T_RRSE | | DEL | - | - | - | - | - | - | - | - | - | - | BSPC |
| T_LSFT | A | S | D | F | G | H | J | K | L | SCLN | T_RSFT | | TAB | - | - | - | - | - | - | - | - | - | - | ENTER |
| T_LCTL | Z | X | C | V | B | N | M | COMM | DOT | QUOT | T_RCTL | | LBRACKET | - | - | - | - | - | - | - | - | - | - | RBRACKET |
| T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | DVORAK | | SLASH | LPRN | - | - | - | - | - | - | - | - | RPRN | MINS |
|--------+--------+----+------+------+-----+-----+-----+------+-------+--------+--------| |----------+------+---+---+---+---+---+---+---+---+------+----------|
I tried to keep my layout bare bones, just what would be available on a normal #+NAME: hold-layer
keyboard, minus some keys I never used. This one secondary layer should cover a |------+------+---+---+---+---+---+---+---+---+------+------|
majority of the keys not found on the home layer. The bottom left copies a normal | RISE | - | - | - | - | - | - | - | - | - | - | RISE |
keyboards symbols from shifted numbers, and the rest is placed where convenient, | LSFT | - | - | - | - | - | - | - | - | - | - | RSFT |
with some considerations for one handed use, hence the shortcuts in the top | LCTL | - | - | - | - | - | - | - | - | - | - | RCTL |
left. | LGUI | LALT | - | - | - | - | - | - | - | - | RALT | RGUI |
|------+------+---+---+---+---+---+---+---+---+------+------|
#+NAME: secondary-layer I tried to keep my layout bare bones, just what would be available on a normal
|--------+--------+--------+--------+--------+------+------+-----+--------+--------+-------+--------| keyboard, minus some keys I never used. This one secondary layer should cover a
| -- | EZUNDO | EZCOPY | EZCUT | EZPSTE | INS | EQL | 7 | 8 | 9 | -- | -- | majority of the keys not found on the home layer. The bottom left copies a normal
| EZSHFT | ESC | CAPS | PGUP | PGDN | HOME | ASTR | 4 | 5 | 6 | 0 | EZSHFT | keyboards symbols from shifted numbers, and the rest is placed where convenient,
| EZCTRL | EXLM | AT | HASH | DLR | PERC | CIRC | 1 | 2 | 3 | COM | EZCTRL | with some considerations for one handed use, hence the shortcuts in the top
| EZGUI | EZALT | EZUP | EZDOWN | SPC | AMPR | PIPE | END | EZLEFT | EZRGHT | EZALT | EZGUI | left.
|--------+--------+--------+--------+--------+------+------+-----+--------+--------+-------+--------|
Basic command layer for one-shot macros and function keys. #+NAME: secondary-layer
|--------+--------+--------+--------+--------+------+--------+-----+--------+--------+-------+--------|
| -- | EZUNDO | EZCOPY | EZCUT | EZPSTE | INS | ASTR | 7 | 8 | 9 | -- | -- |
| EZSHFT | ESC | CAPS | PGUP | PGDN | HOME | AMPR | 4 | 5 | 6 | 0 | EZSHFT |
| EZCTRL | EXLM | AT | HASH | DLR | PERC | CIRC | 1 | 2 | 3 | COM | EZCTRL |
| EZGUI | EZALT | EZUP | EZDOWN | SPC | PIPE | BSLASH | END | EZLEFT | EZRGHT | EZALT | EZGUI |
|--------+--------+--------+--------+--------+------+--------+-----+--------+--------+-------+--------|
#+NAME: command-layer Basic command layer for one-shot macros and function keys.
|----+-----+-----+-----+-----+--------+--------+------+-------+------+-----+----|
| -- | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | -- | #+NAME: command-layer
| -- | F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 | -- | |----+-----+-----+-----+-----+--------+--------+-----+-----+-----+-----+----|
| -- | F21 | F22 | F23 | F24 | QWERTY | DVORAK | USER | EMAIL | NAME | -- | -- | | -- | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | -- |
| -- | -- | -- | -- | -- | -- | -- | DIR | -- | -- | -- | -- | | -- | F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 | -- |
|----+-----+-----+-----+-----+--------+--------+------+-------+------+-----+----| | -- | F21 | F22 | F23 | F24 | QWERTY | DVORAK | -- | -- | -- | -- | -- |
| -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
|----+-----+-----+-----+-----+--------+--------+-----+-----+-----+-----+----|
This qwerty layout is just so normal people can try out the board. Tap keys
would need to be customized I think, more on that later. I also put another
dvorak key here because I have nightmares of getting trapped in this forsaken
layout.
#+NAME: qwerty-layer
|--------+--------+----+------+-----+-----+------+-----+------+-------+--------+--------|
| T_LRSE | Q | W | E | R | T | Y | U | I | O | P | T_RRSE |
| T_LSFT | A | S | D | F | G | H | J | K | L | SCLN | T_RSFT |
| T_LCTL | Z | X | C | V | B | N | M | COMM | DOT | QUOT | T_RCTL |
| T_LGUI | T_LALT | UP | DOWN | SPC | EQL | GRAVE | SPC | LEFT | RIGHT | T_RALT | DVORAK |
|--------+--------+----+------+-----+-----+------+-----+------+-------+--------+--------|
But wait, we are missing several important keys? well, yes, but the modifier keys
all do other keys when tapped. More about that in the keymap section.
* Keymap Conversion in Python * Keymap Conversion in Python
This python can convert that table into the array needed for the keymap file. It This python can convert that table into the array needed for the keymap file. It
simply prepends every key with "KC_". I used to use a dictionary to convert some simply prepends every key with "KC_". I used to use a dictionary to convert some
keys from the table into qmk keycodes, but the double convertion was keys from the table into qmk keycodes, but the double convertion was
unneccessary so I just prepended all my macros with KC and moved all the unneccessary so I just prepended all my macros with KC and moved all the
implementation to the `process-user-input` function. implementation to the `process-user-input` function.
#+NAME:layer-to-array #+NAME:layer-to-array
#+BEGIN_SRC python :var keys=secondary-layer :tangle no #+BEGIN_SRC python :var keys=secondary-layer :tangle no
results = "{" row = 0
row = 0 results = ''
while row < len(keys): while row < len(keys):
results += '{ '
key = 0 key = 0
while key < len(keys[row]): while key < len(keys[row]):
keyName = str(keys[row][key]) keyName = str(keys[row][key])
@ -95,29 +110,59 @@ while row < len(keys):
if key != 11: if key != 11:
results += ', ' results += ', '
key+=1 key+=1
results += '}'
if row != 3: if row != 3:
results += ',' results += ','
results += '\n' results += '\n'
row+=1 row+=1
results += '},\n' return results
return results #+END_SRC
#+END_SRC
Tap keys are technically defined in the mod_lift function. but this is will
implement that function from the org table.
#+NAME:define-tap-key
#+BEGIN_SRC python :var row=3 :var col=1 :var id=0 :var tapkeys=tap-layer :var holdkeys=hold-layer :tangle no
def getKey(keys, istapkey):
if istapkey == True:
keyName = str(keys[row][col])
else:
keyName = str(keys[row][col])
if keyName == '--':
keyName = 'TRANSPARENT'
if istapkey == False:
return 'KC_T_' + keyName, 'KC_' + keyName
else:
return 'KC_' + keyName
tapKeyName = getKey(tapkeys, True)
holdKeyMacro, holdKeyName = getKey(holdkeys, False)
return """case %s:
if (record->event.pressed) {
mod_press(%s, %s, %i);
} else {
mod_lift(%s, %s, %i);
}
return false;
break;""" % (holdKeyMacro, tapKeyName, holdKeyName, id, tapKeyName, holdKeyName, id)
#+END_SRC
* keymap.c * keymap.c
Now that we laid out our layout, lets lay out our kemap file. Now that we laid out our layout, lets lay out our keymap file.
#+BEGIN_SRC C :noweb yes ** Headers
#+BEGIN_SRC C :noweb yes
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
extern keymap_config_t keymap_config; extern keymap_config_t keymap_config;
#+END_SRC #+END_SRC
** Keycodes ** Keycodes
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
// where the 'T_' communicates how the key does something different when tapped. // where the 'T_' communicates how the key does something different when tapped.
enum planck_keycodes { enum planck_keycodes {
//DVORAK = SAFE_RANGE, //DVORAK = SAFE_RANGE,
@ -145,18 +190,14 @@ KC_EZGUI,
KC_EZALT, KC_EZALT,
KC_DVORAK, KC_DVORAK,
KC_QWERTY, KC_QWERTY,
KC_USER,
KC_EMAIL,
KC_NAME,
KC_DIR,
KC_COM KC_COM
}; };
#+END_SRC #+END_SRC
** Import Key table ** Import Key table
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
enum planck_layers { enum planck_layers {
_DVORAK, _DVORAK,
_QWERTY, _QWERTY,
@ -166,74 +207,46 @@ _COMMAND
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#+END_SRC #+END_SRC
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
[_DVORAK] = [_DVORAK] = LAYOUT_planck_grid(
#+END_SRC
#+BEGIN_SRC C :noweb yes
<<layer-to-array(home-layer)>> <<layer-to-array(home-layer)>>
),
#+END_SRC [_QWERTY] = LAYOUT_planck_grid(
#+BEGIN_SRC C :noweb yes
[_QWERTY] =
#+END_SRC
#+BEGIN_SRC C :noweb yes
<<layer-to-array(qwerty-layer)>> <<layer-to-array(qwerty-layer)>>
),
#+END_SRC [_RISE] = LAYOUT_planck_grid(
#+BEGIN_SRC C :noweb yes
[_RISE] =
#+END_SRC
#+BEGIN_SRC C :noweb yes
<<layer-to-array(secondary-layer)>> <<layer-to-array(secondary-layer)>>
),
#+END_SRC [_COMMAND] = LAYOUT_planck_grid(
#+BEGIN_SRC C :noweb yes
[_COMMAND] =
#+END_SRC
#+BEGIN_SRC C :noweb yes
<<layer-to-array(command-layer)>> <<layer-to-array(command-layer)>>
)
#+END_SRC
#+BEGIN_SRC C :noweb yes
}; };
#+END_SRC #+END_SRC
** Tap Keys ** Tap Keys
I don't like tap keys coming out on release. When modified, I often let go of I don't like tap keys coming out on release. When modified, I often let go of
the modifier too early because the tap button doesn't come out untill release. I the modifier too early because the tap button doesn't come out untill release. I
guess you could save the state of the board on press and then apply it after the guess you could save the state of the board on press and then apply it after the
timer, but what I really want is the keys to come out on press when they can and timer, but what I really want is the keys to come out on press when they can and
when it is most useful. For me, that is when they are modified a single time. So when it is most useful. For me, that is when they are modified a single time. So
I kind "locked" the board into only doing single modifiers, making them faster. I kind of "locked" the board into only doing single modifiers, making them faster.
Disadvantages are double modified keys must be done with one shot keys (its Disadvantages are double modified keys must be done with one shot keys (its
actually not that bad, it feels like emacs!) and triple modified keys are actually not that bad, it feels like emacs!) and triple modified keys are
impossible at the moment. impossible at the moment.
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
static uint16_t tap_timer = 0; static uint16_t tap_timer = 0;
char last_mod = 10; char last_mod = 10;
void mod_press(uint16_t tap_code, uint16_t hold_code, int id) { void mod_press(uint16_t tap_code, uint16_t hold_code, int id) {
// this first if body makes double modified keys impossible, but stops the /* this first if body makes double modified keys impossible, but stops the */
// delay when modifying a tap key which would result in the tap key not /* delay when modifying a tap key which would result in the tap key not */
// getting modified. /* getting modified. */
if (last_mod != id && last_mod != 10) { if (last_mod != id && last_mod != 10) {
tap_code16(tap_code); tap_code16(tap_code);
last_mod = 10; last_mod = 10;
@ -242,381 +255,238 @@ void mod_press(uint16_t tap_code, uint16_t hold_code, int id) {
last_mod = id; last_mod = id;
register_code(hold_code); register_code(hold_code);
} }
} }
void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) { void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) {
unregister_code(hold_code); unregister_code(hold_code);
if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) { if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(tap_code); tap_code16(tap_code);
}
last_mod = 10; last_mod = 10;
} }
}
#+END_SRC
#+END_SRC
** Process User Input ** Process User Input
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) { switch (keycode) {
#+END_SRC #+END_SRC
** Layouts *** Layouts
Set Dvorak layout Set Dvorak layout
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
case KC_DVORAK: case KC_DVORAK:
if (record->event.pressed) { if (record->event.pressed) {
set_single_persistent_default_layer(_DVORAK); set_single_persistent_default_layer(_DVORAK);
} }
return true; return true;
break; break;
#+END_SRC #+END_SRC
Set Qwerty layout. Set Qwerty layout.
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
case KC_QWERTY: case KC_QWERTY:
if (record->event.pressed) { if (record->event.pressed) {
set_single_persistent_default_layer(_QWERTY); set_single_persistent_default_layer(_QWERTY);
} }
return true; return true;
break; break;
#+END_SRC #+END_SRC
** Alt and () *** Custom Keys
**** Command Layer One Shot
Left and right alt are ( and ) when tapped. I put them on alt instead of a more #+BEGIN_SRC C :noweb yes
conveniant key like control because parentheses do not need to be shift modified case KC_COM:
ever, unlike some other tap keys seen in the next sections. if (record->event.pressed) {
layer_on(_COMMAND);
set_oneshot_layer(_COMMAND, ONESHOT_START);
last_mod = 10;
} else {
clear_oneshot_layer_state (ONESHOT_PRESSED);
}
return false;
break;
#+END_SRC
#+BEGIN_SRC C :noweb yes **** Tap Keys
case KC_T_LALT:
if (record->event.pressed) {
mod_press(S(KC_9), KC_LALT, 0);
} else {
mod_lift(S(KC_9), KC_LALT, 0);
}
return false;
break;
case KC_T_RALT:
if (record->event.pressed) {
mod_press(S(KC_0), KC_RALT, 1);
} else {
mod_lift(S(KC_0), KC_RALT, 1);
}
return false;
break;
#+END_SRC #+BEGIN_SRC C :noweb yes
<<define-tap-key(3, 1, 0)>>
<<define-tap-key(3, 10, 1)>>
<<define-tap-key(3, 0, 2)>>
<<define-tap-key(3, 11, 3)>>
<<define-tap-key(2, 0, 4)>>
<<define-tap-key(2, 11, 5)>>
<<define-tap-key(1, 0, 6)>>
<<define-tap-key(1, 11, 7)>>
#+END_SRC
** Gui and `\ **** Rise Keys
I place gui in the bottom corner because I believe it is the hardest key to #+BEGIN_SRC C :noweb yes
reach, so gui seemed like a good fit for a dedicated key that I never want to case KC_T_LRSE:
have to spam. For tap keys, I used equally unused keys that are not apart of the if (record->event.pressed) {
number pad or shifted number keys.
#+BEGIN_SRC C :noweb yes
case KC_T_LGUI:
if (record->event.pressed) {
mod_press(KC_GRAVE, KC_LGUI, 2);
} else {
mod_lift(KC_GRAVE, KC_LGUI, 2);
}
return false;
break;
case KC_T_RGUI:
if (record->event.pressed) {
mod_press(KC_BSLASH, KC_RGUI, 3);
} else {
mod_lift(KC_BSLASH, KC_RGUI, 3);
}
return false;
break;
#+END_SRC
** Ctrl and []
Left and right control are [] respectively when they are tapped, making { and }
also very convenient.
#+BEGIN_SRC C :noweb yes
case KC_T_LCTL:
if (record->event.pressed) {
mod_press(KC_LBRACKET, KC_LCTL, 4);
} else {
mod_lift(KC_LBRACKET, KC_LCTL, 4);
}
return false;
break;
case KC_T_RCTL:
if (record->event.pressed) {
mod_press(KC_RBRACKET, KC_RCTL, 5);
} else {
mod_lift(KC_RBRACKET, KC_RCTL, 5);
}
return false;
break;
#+END_SRC
** Shft and =-
I place shift on the home row, so having '-' right of my pinkie is standard, and
it only felt natural to put its opposite, '=/+' on the other side. I put an
extra one on the right side in the secondary layer for the num pad.
#+BEGIN_SRC C :noweb yes
case KC_T_LSFT:
if (record->event.pressed) {
mod_press(KC_EQUAL, KC_LSFT, 6);
} else {
mod_lift(KC_EQUAL, KC_LSFT, 6);
}
return false;
break;
case KC_T_RSFT:
if (record->event.pressed) {
mod_press(KC_MINUS, KC_RSFT, 7);
} else {
mod_lift(KC_MINUS, KC_RSFT, 7);
}
return false;
break;
#+END_SRC
** Rise, DEL, and /
I use the top corners as rise because I decided that I do not like using layers
with my thumbs. It feels uncomfortable to hold keys down with the side of my
thumb, and backspace, tab, enter, and spacebar keep them satisfied. My pinky is
for holding modifiers, so it makes sense to put the layer key with the other
modifiers. Both my left and right layer keys activate the same layer which also
makes sense to me. You wouldn't want left and right shift to do different things
I used to have escape in the top left, but I use delete a lot more, and putting
escape under a layer has not been a problem at all. I put / in the top right
corner again mimicing a standard dvorak keyboard.
#+BEGIN_SRC C :noweb yes
case KC_T_LRSE:
if (record->event.pressed) {
tap_timer = timer_read(); tap_timer = timer_read();
last_mod = 8; last_mod = 8;
layer_on(_RISE); layer_on(_RISE);
} else { } else {
layer_off(_RISE); layer_off(_RISE);
if (last_mod == 8 && timer_elapsed(tap_timer) < TAPPING_TERM) { if (last_mod == 8 && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(KC_DELETE); tap_code16(KC_DELETE);
last_mod = 10; last_mod = 10;
} }
} }
return false; return false;
break; break;
case KC_T_RRSE: case KC_T_RRSE:
if (record->event.pressed) { if (record->event.pressed) {
tap_timer = timer_read(); tap_timer = timer_read();
last_mod = 9; last_mod = 9;
layer_on(_RISE); layer_on(_RISE);
} else { } else {
layer_off(_RISE); layer_off(_RISE);
if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) { if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(KC_SLASH); tap_code16(KC_BSPACE);
last_mod = 10; last_mod = 10;
} }
} }
return false; return false;
break; break;
#+END_SRC #+END_SRC
** EZ Keys **** One Shot Keys
EZ or "easy" keys do things that can already be done on the board, but I want an Since I made modified tap keys occur on press instead of release, I need one
easier way of doing them. shot keys to press any key with more than one modifier.
*** One Shot Keys #+BEGIN_SRC C :noweb yes
case KC_EZSHFT:
Since I made modified tap keys occur on press instead of release, I need one if (record->event.pressed) {
shot keys to press any key with more than one modifier.
#+BEGIN_SRC C :noweb yes
case KC_EZSHFT:
if (record->event.pressed) {
set_oneshot_mods(MOD_LSFT); set_oneshot_mods(MOD_LSFT);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZCTRL: case KC_EZCTRL:
if (record->event.pressed) { if (record->event.pressed) {
set_oneshot_mods(MOD_LCTL); set_oneshot_mods(MOD_LCTL);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZALT: case KC_EZALT:
if (record->event.pressed) { if (record->event.pressed) {
set_oneshot_mods(MOD_LALT); set_oneshot_mods(MOD_LALT);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZGUI: case KC_EZGUI:
if (record->event.pressed) { if (record->event.pressed) {
set_oneshot_mods(MOD_LGUI); set_oneshot_mods(MOD_LGUI);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
#+END_SRC #+END_SRC
*** Arrows **** C-S Arrows
I use ctrl+shift+arrows keys a lot, so when the layer key is pressed they became I use ctrl+shift+arrows keys a lot, so when the layer key is pressed they became
lazy versions of themselves with control and shift already pressed. lazy versions of themselves with control and shift already pressed.
I also added undo, copy, paste, and cut to be easily available with only the I also added undo, copy, paste, and cut to be easily available with only the
left hand like on a qwerty or colemek keyboard. left hand like on a qwerty or colemek keyboard.
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
case KC_EZRGHT: case KC_EZRGHT:
if (record->event.pressed) { if (record->event.pressed) {
register_code(KC_LCTL); register_code(KC_LCTL);
tap_code16(S(KC_RGHT)); tap_code16(S(KC_RGHT));
unregister_code(KC_LCTL); unregister_code(KC_LCTL);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZLEFT: case KC_EZLEFT:
if (record->event.pressed) { if (record->event.pressed) {
register_code(KC_LCTL); register_code(KC_LCTL);
tap_code16(S(KC_LEFT)); tap_code16(S(KC_LEFT));
unregister_code(KC_LCTL); unregister_code(KC_LCTL);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZDOWN: case KC_EZDOWN:
if (record->event.pressed) { if (record->event.pressed) {
register_code(KC_LCTL); register_code(KC_LCTL);
tap_code16(S(KC_DOWN)); tap_code16(S(KC_DOWN));
unregister_code(KC_LCTL); unregister_code(KC_LCTL);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZUP: case KC_EZUP:
if (record->event.pressed) { if (record->event.pressed) {
register_code(KC_LCTL); register_code(KC_LCTL);
tap_code16(S(KC_UP)); tap_code16(S(KC_UP));
unregister_code(KC_LCTL); unregister_code(KC_LCTL);
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
#+END_SRC #+END_SRC
*** Undo, Copy, Cut, Paste **** Undo, Copy, Cut, Paste
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
case KC_EZUNDO: case KC_EZUNDO:
if (record->event.pressed) { if (record->event.pressed) {
tap_code16(C(KC_Z)); tap_code16(C(KC_Z));
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZCOPY: case KC_EZCOPY:
if (record->event.pressed) { if (record->event.pressed) {
tap_code16(C(KC_C)); tap_code16(C(KC_C));
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZCUT: case KC_EZCUT:
if (record->event.pressed) { if (record->event.pressed) {
tap_code16(C(KC_X)); tap_code16(C(KC_X));
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
case KC_EZPSTE: case KC_EZPSTE:
if (record->event.pressed) { if (record->event.pressed) {
tap_code16(C(KC_V)); tap_code16(C(KC_V));
last_mod = 10; last_mod = 10;
} }
return false; return false;
break; break;
#+END_SRC #+END_SRC
** Commands *** Standard inputs interupt tap
Start command layer one shot Finally, if just a standard key is tapped, set the interupted flag.
Keep this last.
#+BEGIN_SRC C :noweb yes #+BEGIN_SRC C :noweb yes
case KC_COM: }
if (record->event.pressed) {
layer_on(_COMMAND);
set_oneshot_layer(_COMMAND, ONESHOT_START);
last_mod = 10; last_mod = 10;
} else { return true;
clear_oneshot_layer_state (ONESHOT_PRESSED); }
} #+END_SRC
return false;
break;
#+END_SRC
Just some strings I notice that I type a lot.
#+BEGIN_SRC C :noweb yes
case KC_USER:
if (record->event.pressed) {
send_string("mhostley");
last_mod = 10;
}
return true;
break;
case KC_EMAIL:
if (record->event.pressed) {
send_string("mhostley@gmail.com");
last_mod = 10;
}
return true;
break;
case KC_NAME:
if (record->event.pressed) {
send_string("Samuel Jahnke");
last_mod = 10;
}
return true;
break;
case KC_DIR:
if (record->event.pressed) {
send_string("home/mhostley/");
last_mod = 10;
}
return true;
break;
#+END_SRC
** Standard inputs interupt tap
Finally, if just a standard key is tapped, set the interupted flag.
Keep this last.
#+BEGIN_SRC C :noweb yes
}
last_mod = 10;
return true;
}
#+END_SRC

View file

@ -29,10 +29,6 @@ KC_EZGUI,
KC_EZALT, KC_EZALT,
KC_DVORAK, KC_DVORAK,
KC_QWERTY, KC_QWERTY,
KC_USER,
KC_EMAIL,
KC_NAME,
KC_DIR,
KC_COM KC_COM
}; };
@ -45,47 +41,39 @@ _COMMAND
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_DVORAK] = [_DVORAK] = LAYOUT_planck_grid(
KC_T_LRSE, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_T_RRSE,
{{ KC_T_LRSE, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_T_RRSE}, KC_T_LSFT, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_T_RSFT,
{ KC_T_LSFT, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_T_RSFT}, KC_T_LCTL, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_T_RCTL,
{ KC_T_LCTL, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_T_RCTL}, KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_SPC, KC_EQL, KC_GRAVE, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_T_RGUI
{ KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_BSPC, KC_TAB, KC_ENT, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_T_RGUI} ),
}, [_QWERTY] = LAYOUT_planck_grid(
KC_T_LRSE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_T_RRSE,
[_QWERTY] = KC_T_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_T_RSFT,
KC_T_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_QUOT, KC_T_RCTL,
{{ KC_T_LRSE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_T_RRSE}, KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_SPC, KC_EQL, KC_GRAVE, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_DVORAK
{ KC_T_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_T_RSFT}, ),
{ KC_T_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_QUOT, KC_T_RCTL}, [_RISE] = LAYOUT_planck_grid(
{ KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_BSPC, KC_TAB, KC_ENT, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_DVORAK} KC_TRANSPARENT, KC_EZUNDO, KC_EZCOPY, KC_EZCUT, KC_EZPSTE, KC_INS, KC_ASTR, KC_7, KC_8, KC_9, KC_TRANSPARENT, KC_TRANSPARENT,
}, KC_EZSHFT, KC_ESC, KC_CAPS, KC_PGUP, KC_PGDN, KC_HOME, KC_AMPR, KC_4, KC_5, KC_6, KC_0, KC_EZSHFT,
KC_EZCTRL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_1, KC_2, KC_3, KC_COM, KC_EZCTRL,
[_RISE] = KC_EZGUI, KC_EZALT, KC_EZUP, KC_EZDOWN, KC_SPC, KC_PIPE, KC_BSLASH, KC_END, KC_EZLEFT, KC_EZRGHT, KC_EZALT, KC_EZGUI
),
{{ KC_TRANSPARENT, KC_EZUNDO, KC_EZCOPY, KC_EZCUT, KC_EZPSTE, KC_INS, KC_EQL, KC_7, KC_8, KC_9, KC_TRANSPARENT, KC_TRANSPARENT}, [_COMMAND] = LAYOUT_planck_grid(
{ KC_EZSHFT, KC_ESC, KC_CAPS, KC_PGUP, KC_PGDN, KC_HOME, KC_ASTR, KC_4, KC_5, KC_6, KC_0, KC_EZSHFT}, KC_TRANSPARENT, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRANSPARENT,
{ KC_EZCTRL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_1, KC_2, KC_3, KC_COM, KC_EZCTRL}, KC_TRANSPARENT, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRANSPARENT,
{ KC_EZGUI, KC_EZALT, KC_EZUP, KC_EZDOWN, KC_SPC, KC_AMPR, KC_PIPE, KC_END, KC_EZLEFT, KC_EZRGHT, KC_EZALT, KC_EZGUI} KC_TRANSPARENT, KC_F21, KC_F22, KC_F23, KC_F24, KC_QWERTY, KC_DVORAK, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT,
}, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT
)
[_COMMAND] =
{{ KC_TRANSPARENT, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRANSPARENT},
{ KC_TRANSPARENT, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRANSPARENT},
{ KC_TRANSPARENT, KC_F21, KC_F22, KC_F23, KC_F24, KC_QWERTY, KC_DVORAK, KC_USER, KC_EMAIL, KC_NAME, KC_TRANSPARENT, KC_TRANSPARENT},
{ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_DIR, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT}
},
}; };
static uint16_t tap_timer = 0; static uint16_t tap_timer = 0;
char last_mod = 10; char last_mod = 10;
void mod_press(uint16_t tap_code, uint16_t hold_code, int id) { void mod_press(uint16_t tap_code, uint16_t hold_code, int id) {
// this first if body makes double modified keys impossible, but stops the /* this first if body makes double modified keys impossible, but stops the */
// delay when modifying a tap key which would result in the tap key not /* delay when modifying a tap key which would result in the tap key not */
// getting modified. /* getting modified. */
if (last_mod != id && last_mod != 10) { if (last_mod != id && last_mod != 10) {
tap_code16(tap_code); tap_code16(tap_code);
last_mod = 10; last_mod = 10;
@ -100,8 +88,8 @@ void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) {
unregister_code(hold_code); unregister_code(hold_code);
if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) { if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(tap_code); tap_code16(tap_code);
last_mod = 10;
} }
last_mod = 10;
} }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
@ -121,73 +109,81 @@ if (record->event.pressed) {
return true; return true;
break; break;
case KC_COM:
if (record->event.pressed) {
layer_on(_COMMAND);
set_oneshot_layer(_COMMAND, ONESHOT_START);
last_mod = 10;
} else {
clear_oneshot_layer_state (ONESHOT_PRESSED);
}
return false;
break;
case KC_T_LALT: case KC_T_LALT:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(S(KC_9), KC_LALT, 0); mod_press(KC_LPRN, KC_LALT, 0);
} else { } else {
mod_lift(S(KC_9), KC_LALT, 0); mod_lift(KC_LPRN, KC_LALT, 0);
} }
return false; return false;
break; break;
case KC_T_RALT: case KC_T_RALT:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(S(KC_0), KC_RALT, 1); mod_press(KC_RPRN, KC_RALT, 1);
} else { } else {
mod_lift(S(KC_0), KC_RALT, 1); mod_lift(KC_RPRN, KC_RALT, 1);
} }
return false; return false;
break; break;
case KC_T_LGUI: case KC_T_LGUI:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(KC_GRAVE, KC_LGUI, 2); mod_press(KC_SLASH, KC_LGUI, 2);
} else { } else {
mod_lift(KC_GRAVE, KC_LGUI, 2); mod_lift(KC_SLASH, KC_LGUI, 2);
} }
return false; return false;
break; break;
case KC_T_RGUI: case KC_T_RGUI:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(KC_BSLASH, KC_RGUI, 3); mod_press(KC_MINS, KC_RGUI, 3);
} else { } else {
mod_lift(KC_BSLASH, KC_RGUI, 3); mod_lift(KC_MINS, KC_RGUI, 3);
} }
return false; return false;
break; break;
case KC_T_LCTL: case KC_T_LCTL:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(KC_LBRACKET, KC_LCTL, 4); mod_press(KC_LBRACKET, KC_LCTL, 4);
} else { } else {
mod_lift(KC_LBRACKET, KC_LCTL, 4); mod_lift(KC_LBRACKET, KC_LCTL, 4);
} }
return false; return false;
break; break;
case KC_T_RCTL: case KC_T_RCTL:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(KC_RBRACKET, KC_RCTL, 5); mod_press(KC_RBRACKET, KC_RCTL, 5);
} else { } else {
mod_lift(KC_RBRACKET, KC_RCTL, 5); mod_lift(KC_RBRACKET, KC_RCTL, 5);
} }
return false; return false;
break; break;
case KC_T_LSFT: case KC_T_LSFT:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(KC_EQUAL, KC_LSFT, 6); mod_press(KC_TAB, KC_LSFT, 6);
} else { } else {
mod_lift(KC_EQUAL, KC_LSFT, 6); mod_lift(KC_TAB, KC_LSFT, 6);
} }
return false; return false;
break; break;
case KC_T_RSFT: case KC_T_RSFT:
if (record->event.pressed) { if (record->event.pressed) {
mod_press(KC_MINUS, KC_RSFT, 7); mod_press(KC_ENTER, KC_RSFT, 7);
} else { } else {
mod_lift(KC_MINUS, KC_RSFT, 7); mod_lift(KC_ENTER, KC_RSFT, 7);
} }
return false; return false;
break; break;
case KC_T_LRSE: case KC_T_LRSE:
if (record->event.pressed) { if (record->event.pressed) {
@ -211,7 +207,7 @@ if (record->event.pressed) {
} else { } else {
layer_off(_RISE); layer_off(_RISE);
if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) { if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(KC_SLASH); tap_code16(KC_BSPACE);
last_mod = 10; last_mod = 10;
} }
} }
@ -313,46 +309,6 @@ if (record->event.pressed) {
return false; return false;
break; break;
case KC_COM:
if (record->event.pressed) {
layer_on(_COMMAND);
set_oneshot_layer(_COMMAND, ONESHOT_START);
last_mod = 10;
} else {
clear_oneshot_layer_state (ONESHOT_PRESSED);
}
return false;
break;
case KC_USER:
if (record->event.pressed) {
send_string("mhostley");
last_mod = 10;
}
return true;
break;
case KC_EMAIL:
if (record->event.pressed) {
send_string("mhostley@gmail.com");
last_mod = 10;
}
return true;
break;
case KC_NAME:
if (record->event.pressed) {
send_string("Samuel Jahnke");
last_mod = 10;
}
return true;
break;
case KC_DIR:
if (record->event.pressed) {
send_string("home/mhostley/");
last_mod = 10;
}
return true;
break;
} }
last_mod = 10; last_mod = 10;
return true; return true;