diff options
| author | Samuel Jahnke <118westmaine@gmail.com> | 2019-03-17 10:22:35 -0700 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-03-17 10:22:35 -0700 |
| commit | c74b11a959f58ba52f14f4c1061abc6f84042e29 (patch) | |
| tree | e03862fce9f7ed682c2a050e114a85851ba8a1f1 | |
| parent | fcc9b4b8e7eed87d25d744e3891baf878816d427 (diff) | |
| download | qmk_firmware-c74b11a959f58ba52f14f4c1061abc6f84042e29.tar.gz qmk_firmware-c74b11a959f58ba52f14f4c1061abc6f84042e29.zip | |
[Keymap] Improvements to Samuel's literate keymap (#5428)
* added my own keymap
* changed thing
* updated keymap Samuel
* updated laypout for better one handed use
* updated stuff I want
* happy with my lagout
* formatting
* Added new literate config
* made everything nice
* cleaned
* fixed spelling and two small bugs in macros
* Made press and lift function for modifiers
* made taps occur on press instead of release
* added oneshot keys and chars cant be negative!
* removed debug message
* Added command and qwerty layers
* fixed bug with oneshot layer
* same bug, different key
| -rw-r--r-- | keyboards/planck/keymaps/samuel/README.org | 509 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/samuel/keymap.c | 372 |
2 files changed, 593 insertions, 288 deletions
diff --git a/keyboards/planck/keymaps/samuel/README.org b/keyboards/planck/keymaps/samuel/README.org index d0750ee03..3c0f08a9d 100644 --- a/keyboards/planck/keymaps/samuel/README.org +++ b/keyboards/planck/keymaps/samuel/README.org | |||
| @@ -5,7 +5,7 @@ This is my qmk firmware for my keyboard. I grew tired of organizing the keycode | |||
| 5 | array in plain text so I made it a literate .org file. I've never done this | 5 | array in plain text so I made it a literate .org file. I've never done this |
| 6 | before, so bear with me. | 6 | before, so bear with me. |
| 7 | 7 | ||
| 8 | * Keymap | 8 | * Layers |
| 9 | 9 | ||
| 10 | #+BEGIN_COMMENT | 10 | #+BEGIN_COMMENT |
| 11 | #+NAME: empty-layer | 11 | #+NAME: empty-layer |
| @@ -19,7 +19,7 @@ before, so bear with me. | |||
| 19 | #+END_COMMENT | 19 | #+END_COMMENT |
| 20 | 20 | ||
| 21 | This is my "pretty" org mode organized table for my main dvorak layer. If you | 21 | This is my "pretty" org mode organized table for my main dvorak layer. If you |
| 22 | don't use org mode, it won't be that exiting, but if you enjoy working in org | 22 | don't use org mode, it won't be that exciting, but if you enjoy working in org |
| 23 | mode, you can edit this table directly, and this file is tangled to the actual | 23 | mode, you can edit this table directly, and this file is tangled to the actual |
| 24 | keymap. No more organizing spaces or converting to and from comments. | 24 | keymap. No more organizing spaces or converting to and from comments. |
| 25 | 25 | ||
| @@ -31,23 +31,45 @@ keymap. No more organizing spaces or converting to and from comments. | |||
| 31 | | T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | T_RGUI | | 31 | | T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | T_RGUI | |
| 32 | |--------+--------+------+------+------+-----+-----+-----+------+-------+--------+--------| | 32 | |--------+--------+------+------+------+-----+-----+-----+------+-------+--------+--------| |
| 33 | 33 | ||
| 34 | This qwerty layout is just so normal people can try out the board. Tap keys | ||
| 35 | would need to be customized I think, more on that later. I also put another | ||
| 36 | dvorak key here because I have nightmares of getting trapped in this forsaken | ||
| 37 | layout. | ||
| 38 | |||
| 39 | #+NAME: qwerty-layer | ||
| 40 | |--------+--------+----+------+------+-----+-----+-----+------+-------+--------+--------| | ||
| 41 | | T_LRSE | Q | W | E | R | T | Y | U | I | O | P | T_RRSE | | ||
| 42 | | T_LSFT | A | S | D | F | G | H | J | K | L | SCLN | T_RSFT | | ||
| 43 | | T_LCTL | Z | X | C | V | B | N | M | COMM | DOT | QUOT | T_RCTL | | ||
| 44 | | T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | DVORAK | | ||
| 45 | |--------+--------+----+------+------+-----+-----+-----+------+-------+--------+--------| | ||
| 46 | |||
| 34 | I tried to keep my layout bare bones, just what would be available on a normal | 47 | I tried to keep my layout bare bones, just what would be available on a normal |
| 35 | keyboard, minus some keys I never used. The bottom left copies a normal | 48 | keyboard, minus some keys I never used. This one secondary layer should cover a |
| 49 | majority of the keys not found on the home layer. The bottom left copies a normal | ||
| 36 | keyboards symbols from shifted numbers, and the rest is placed where convenient, | 50 | keyboards symbols from shifted numbers, and the rest is placed where convenient, |
| 37 | with some considerations for one handed use, hence the shortcuts in the top | 51 | with some considerations for one handed use, hence the shortcuts in the top |
| 38 | left. | 52 | left. |
| 39 | 53 | ||
| 40 | #+TODO: qwerty layer for ma friends | ||
| 41 | |||
| 42 | #+NAME: secondary-layer | 54 | #+NAME: secondary-layer |
| 43 | |----+--------+--------+--------+--------+------+------+----+--------+--------+-----+----| | 55 | |--------+--------+--------+--------+--------+------+------+-----+--------+--------+-------+--------| |
| 44 | | -- | EZUNDO | EZCOPY | EZCUT | EZPSTE | INS | EQL | 7 | 8 | 9 | F11 | -- | | 56 | | -- | EZUNDO | EZCOPY | EZCUT | EZPSTE | INS | EQL | 7 | 8 | 9 | -- | -- | |
| 45 | | -- | ESC | CAPS | PGUP | PGDN | F4 | ASTR | 4 | 5 | 6 | 0 | -- | | 57 | | EZSHFT | ESC | CAPS | PGUP | PGDN | HOME | ASTR | 4 | 5 | 6 | 0 | EZSHFT | |
| 46 | | -- | EXLM | AT | HASH | DLR | PERC | CIRC | 1 | 2 | 3 | F12 | -- | | 58 | | EZCTRL | EXLM | AT | HASH | DLR | PERC | CIRC | 1 | 2 | 3 | COM | EZCTRL | |
| 47 | | -- | -- | EZUP | EZDOWN | -- | AMPR | PIPE | -- | EZLEFT | EZRGHT | -- | -- | | 59 | | EZGUI | EZALT | EZUP | EZDOWN | SPC | AMPR | PIPE | END | EZLEFT | EZRGHT | EZALT | EZGUI | |
| 48 | |----+--------+--------+--------+--------+------+------+----+--------+--------+-----+----| | 60 | |--------+--------+--------+--------+--------+------+------+-----+--------+--------+-------+--------| |
| 49 | 61 | ||
| 50 | But wait, we are missing several important keys!? yes, well, the modifier keys | 62 | Basic command layer for one-shot macros and function keys. |
| 63 | |||
| 64 | #+NAME: command-layer | ||
| 65 | |----+-----+-----+-----+-----+--------+--------+------+-------+------+-----+----| | ||
| 66 | | -- | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | -- | | ||
| 67 | | -- | F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 | -- | | ||
| 68 | | -- | F21 | F22 | F23 | F24 | QWERTY | DVORAK | USER | EMAIL | NAME | -- | -- | | ||
| 69 | | -- | -- | -- | -- | -- | -- | -- | DIR | -- | -- | -- | -- | | ||
| 70 | |----+-----+-----+-----+-----+--------+--------+------+-------+------+-----+----| | ||
| 71 | |||
| 72 | But wait, we are missing several important keys? well, yes, but the modifier keys | ||
| 51 | all do other keys when tapped. More about that in the keymap section. | 73 | all do other keys when tapped. More about that in the keymap section. |
| 52 | 74 | ||
| 53 | * Keymap Conversion in Python | 75 | * Keymap Conversion in Python |
| @@ -55,7 +77,7 @@ all do other keys when tapped. More about that in the keymap section. | |||
| 55 | This python can convert that table into the array needed for the keymap file. It | 77 | This python can convert that table into the array needed for the keymap file. It |
| 56 | simply prepends every key with "KC_". I used to use a dictionary to convert some | 78 | simply prepends every key with "KC_". I used to use a dictionary to convert some |
| 57 | keys from the table into qmk keycodes, but the double convertion was | 79 | keys from the table into qmk keycodes, but the double convertion was |
| 58 | unneccessary so I simply prepended all my macros with KC and moved all the | 80 | unneccessary so I just prepended all my macros with KC and moved all the |
| 59 | implementation to the `process-user-input` function. | 81 | implementation to the `process-user-input` function. |
| 60 | 82 | ||
| 61 | #+NAME:layer-to-array | 83 | #+NAME:layer-to-array |
| @@ -84,55 +106,69 @@ return results | |||
| 84 | 106 | ||
| 85 | * keymap.c | 107 | * keymap.c |
| 86 | 108 | ||
| 87 | Now that we have done all the hard work, lets layout our keymap file then define | 109 | Now that we laid out our layout, lets lay out our kemap file. |
| 88 | our macros. | ||
| 89 | |||
| 90 | ** Headers And Layer Declaration | ||
| 91 | 110 | ||
| 92 | #+BEGIN_SRC C :noweb yes | 111 | #+BEGIN_SRC C :noweb yes |
| 93 | #include QMK_KEYBOARD_H | 112 | #include QMK_KEYBOARD_H |
| 94 | 113 | ||
| 95 | extern keymap_config_t keymap_config; | 114 | extern keymap_config_t keymap_config; |
| 96 | 115 | ||
| 97 | static uint16_t tap_timers[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 116 | #+END_SRC |
| 98 | |||
| 99 | char last_mod = -1; | ||
| 100 | 117 | ||
| 101 | enum planck_layers { | 118 | ** Keycodes |
| 102 | _DVORAK, | ||
| 103 | _RISE | ||
| 104 | }; | ||
| 105 | 119 | ||
| 120 | #+BEGIN_SRC C :noweb yes | ||
| 106 | // where the 'T_' communicates how the key does something different when tapped. | 121 | // where the 'T_' communicates how the key does something different when tapped. |
| 107 | enum planck_keycodes { | 122 | enum planck_keycodes { |
| 108 | DVORAK = SAFE_RANGE, | 123 | //DVORAK = SAFE_RANGE, |
| 109 | KC_T_LALT, | 124 | KC_T_LALT = SAFE_RANGE, |
| 110 | KC_T_RALT, | 125 | KC_T_RALT, |
| 111 | KC_T_LGUI, | 126 | KC_T_LGUI, |
| 112 | KC_T_RGUI, | 127 | KC_T_RGUI, |
| 113 | KC_T_LCTL, | 128 | KC_T_LCTL, |
| 114 | KC_T_RCTL, | 129 | KC_T_RCTL, |
| 115 | KC_T_LSFT, | 130 | KC_T_LSFT, |
| 116 | KC_T_RSFT, | 131 | KC_T_RSFT, |
| 117 | KC_T_LRSE, | 132 | KC_T_LRSE, |
| 118 | KC_T_RRSE, | 133 | KC_T_RRSE, |
| 119 | KC_EZRGHT, | 134 | KC_EZRGHT, |
| 120 | KC_EZLEFT, | 135 | KC_EZLEFT, |
| 121 | KC_EZUP, | 136 | KC_EZUP, |
| 122 | KC_EZDOWN, | 137 | KC_EZDOWN, |
| 123 | KC_EZUNDO, | 138 | KC_EZUNDO, |
| 124 | KC_EZCOPY, | 139 | KC_EZCOPY, |
| 125 | KC_EZCUT, | 140 | KC_EZCUT, |
| 126 | KC_EZPSTE | 141 | KC_EZPSTE, |
| 142 | KC_EZSHFT, | ||
| 143 | KC_EZCTRL, | ||
| 144 | KC_EZGUI, | ||
| 145 | KC_EZALT, | ||
| 146 | KC_DVORAK, | ||
| 147 | KC_QWERTY, | ||
| 148 | KC_USER, | ||
| 149 | KC_EMAIL, | ||
| 150 | KC_NAME, | ||
| 151 | KC_DIR, | ||
| 152 | KC_COM | ||
| 127 | }; | 153 | }; |
| 128 | 154 | ||
| 129 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 130 | |||
| 131 | #+END_SRC | 155 | #+END_SRC |
| 132 | 156 | ||
| 133 | ** Import Key table | 157 | ** Import Key table |
| 134 | 158 | ||
| 135 | #+BEGIN_SRC C :noweb yes | 159 | #+BEGIN_SRC C :noweb yes |
| 160 | enum planck_layers { | ||
| 161 | _DVORAK, | ||
| 162 | _QWERTY, | ||
| 163 | _RISE, | ||
| 164 | _COMMAND | ||
| 165 | }; | ||
| 166 | |||
| 167 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 168 | |||
| 169 | #+END_SRC | ||
| 170 | |||
| 171 | #+BEGIN_SRC C :noweb yes | ||
| 136 | [_DVORAK] = | 172 | [_DVORAK] = |
| 137 | 173 | ||
| 138 | #+END_SRC | 174 | #+END_SRC |
| @@ -143,6 +179,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 143 | #+END_SRC | 179 | #+END_SRC |
| 144 | 180 | ||
| 145 | #+BEGIN_SRC C :noweb yes | 181 | #+BEGIN_SRC C :noweb yes |
| 182 | [_QWERTY] = | ||
| 183 | |||
| 184 | #+END_SRC | ||
| 185 | |||
| 186 | #+BEGIN_SRC C :noweb yes | ||
| 187 | <<layer-to-array(qwerty-layer)>> | ||
| 188 | |||
| 189 | #+END_SRC | ||
| 190 | |||
| 191 | #+BEGIN_SRC C :noweb yes | ||
| 146 | [_RISE] = | 192 | [_RISE] = |
| 147 | 193 | ||
| 148 | #+END_SRC | 194 | #+END_SRC |
| @@ -152,50 +198,96 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 152 | 198 | ||
| 153 | #+END_SRC | 199 | #+END_SRC |
| 154 | 200 | ||
| 155 | ** Process User Input | 201 | #+BEGIN_SRC C :noweb yes |
| 156 | *** Tap Key Functionality | 202 | [_COMMAND] = |
| 157 | 203 | ||
| 158 | These methods define how I implemented the tap mechanic. Basically, I believe | 204 | #+END_SRC |
| 159 | that /pressing/ any other key should be grounds for the hold functionality to be | 205 | |
| 160 | assumed. My natuaral typing style experiences no delays from my method. | 206 | #+BEGIN_SRC C :noweb yes |
| 207 | <<layer-to-array(command-layer)>> | ||
| 208 | |||
| 209 | #+END_SRC | ||
| 161 | 210 | ||
| 162 | #+BEGIN_SRC C :noweb yes | 211 | #+BEGIN_SRC C :noweb yes |
| 163 | }; | 212 | }; |
| 164 | 213 | ||
| 165 | void mod_press(uint16_t hold_code, int id) { | 214 | #+END_SRC |
| 166 | tap_timers[id] = timer_read(); | 215 | |
| 167 | last_mod = id; | 216 | ** Tap Keys |
| 168 | register_code(hold_code); | 217 | |
| 218 | I don't like tap keys coming out on release. When modified, I often let go of | ||
| 219 | the modifier too early because the tap button doesn't come out untill release. I | ||
| 220 | guess you could save the state of the board on press and then apply it after the | ||
| 221 | timer, but what I really want is the keys to come out on press when they can and | ||
| 222 | when it is most useful. For me, that is when they are modified a single time. So | ||
| 223 | I kind "locked" the board into only doing single modifiers, making them faster. | ||
| 224 | Disadvantages are double modified keys must be done with one shot keys (its | ||
| 225 | actually not that bad, it feels like emacs!) and triple modified keys are | ||
| 226 | impossible at the moment. | ||
| 227 | |||
| 228 | #+BEGIN_SRC C :noweb yes | ||
| 229 | |||
| 230 | static uint16_t tap_timer = 0; | ||
| 231 | char last_mod = 10; | ||
| 232 | |||
| 233 | void mod_press(uint16_t tap_code, uint16_t hold_code, int id) { | ||
| 234 | // this first if body makes double modified keys impossible, but stops the | ||
| 235 | // delay when modifying a tap key which would result in the tap key not | ||
| 236 | // getting modified. | ||
| 237 | if (last_mod != id && last_mod != 10) { | ||
| 238 | tap_code16(tap_code); | ||
| 239 | last_mod = 10; | ||
| 240 | } else { | ||
| 241 | tap_timer = timer_read(); | ||
| 242 | last_mod = id; | ||
| 243 | register_code(hold_code); | ||
| 244 | } | ||
| 169 | } | 245 | } |
| 170 | 246 | ||
| 171 | void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) { | 247 | void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) { |
| 172 | unregister_code(hold_code); | 248 | unregister_code(hold_code); |
| 173 | if (last_mod == id && timer_elapsed(tap_timers[id]) < TAPPING_TERM) { | 249 | if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) { |
| 174 | tap_code16(tap_code); | 250 | tap_code16(tap_code); |
| 175 | last_mod = -1; | 251 | last_mod = 10; |
| 176 | } | 252 | } |
| 177 | } | 253 | } |
| 178 | 254 | ||
| 179 | #+END_SRC | 255 | #+END_SRC |
| 180 | 256 | ||
| 181 | *** Set DVORAK layout | 257 | ** Process User Input |
| 182 | |||
| 183 | The function that filter's user inputs and applies macros, the begginning is | ||
| 184 | pretty basic, setting our main layer and configuring our secondary layer. | ||
| 185 | 258 | ||
| 186 | #+BEGIN_SRC C :noweb yes | 259 | #+BEGIN_SRC C :noweb yes |
| 187 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 260 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 188 | switch (keycode) { | 261 | switch (keycode) { |
| 189 | case DVORAK: | 262 | #+END_SRC |
| 190 | if (record->event.pressed) { | 263 | |
| 191 | set_single_persistent_default_layer(_DVORAK); | 264 | ** Layouts |
| 192 | } | 265 | |
| 193 | return false; | 266 | Set Dvorak layout |
| 194 | break; | 267 | |
| 268 | #+BEGIN_SRC C :noweb yes | ||
| 269 | case KC_DVORAK: | ||
| 270 | if (record->event.pressed) { | ||
| 271 | set_single_persistent_default_layer(_DVORAK); | ||
| 272 | } | ||
| 273 | return true; | ||
| 274 | break; | ||
| 275 | |||
| 276 | #+END_SRC | ||
| 277 | |||
| 278 | Set Qwerty layout. | ||
| 279 | |||
| 280 | #+BEGIN_SRC C :noweb yes | ||
| 281 | case KC_QWERTY: | ||
| 282 | if (record->event.pressed) { | ||
| 283 | set_single_persistent_default_layer(_QWERTY); | ||
| 284 | } | ||
| 285 | return true; | ||
| 286 | break; | ||
| 195 | 287 | ||
| 196 | #+END_SRC | 288 | #+END_SRC |
| 197 | 289 | ||
| 198 | *** Alt and () | 290 | ** Alt and () |
| 199 | 291 | ||
| 200 | Left and right alt are ( and ) when tapped. I put them on alt instead of a more | 292 | Left and right alt are ( and ) when tapped. I put them on alt instead of a more |
| 201 | conveniant key like control because parentheses do not need to be shift modified | 293 | conveniant key like control because parentheses do not need to be shift modified |
| @@ -204,24 +296,24 @@ ever, unlike some other tap keys seen in the next sections. | |||
| 204 | #+BEGIN_SRC C :noweb yes | 296 | #+BEGIN_SRC C :noweb yes |
| 205 | case KC_T_LALT: | 297 | case KC_T_LALT: |
| 206 | if (record->event.pressed) { | 298 | if (record->event.pressed) { |
| 207 | mod_press(KC_LALT, 0); | 299 | mod_press(S(KC_9), KC_LALT, 0); |
| 208 | } else { | 300 | } else { |
| 209 | mod_lift(S(KC_9), KC_LALT, 0); | 301 | mod_lift(S(KC_9), KC_LALT, 0); |
| 210 | } | 302 | } |
| 211 | return false; | 303 | return false; |
| 212 | break; | 304 | break; |
| 213 | case KC_T_RALT: | 305 | case KC_T_RALT: |
| 214 | if (record->event.pressed) { | 306 | if (record->event.pressed) { |
| 215 | mod_press(KC_RALT, 1); | 307 | mod_press(S(KC_0), KC_RALT, 1); |
| 216 | } else { | 308 | } else { |
| 217 | mod_lift(S(KC_0), KC_RALT, 1); | 309 | mod_lift(S(KC_0), KC_RALT, 1); |
| 218 | } | 310 | } |
| 219 | return false; | 311 | return false; |
| 220 | break; | 312 | break; |
| 221 | 313 | ||
| 222 | #+END_SRC | 314 | #+END_SRC |
| 223 | 315 | ||
| 224 | *** Gui and `\ | 316 | ** Gui and `\ |
| 225 | 317 | ||
| 226 | I place gui in the bottom corner because I believe it is the hardest key to | 318 | I place gui in the bottom corner because I believe it is the hardest key to |
| 227 | reach, so gui seemed like a good fit for a dedicated key that I never want to | 319 | reach, so gui seemed like a good fit for a dedicated key that I never want to |
| @@ -231,24 +323,24 @@ number pad or shifted number keys. | |||
| 231 | #+BEGIN_SRC C :noweb yes | 323 | #+BEGIN_SRC C :noweb yes |
| 232 | case KC_T_LGUI: | 324 | case KC_T_LGUI: |
| 233 | if (record->event.pressed) { | 325 | if (record->event.pressed) { |
| 234 | mod_press(KC_LGUI, 2); | 326 | mod_press(KC_GRAVE, KC_LGUI, 2); |
| 235 | } else { | 327 | } else { |
| 236 | mod_lift(KC_GRAVE, KC_LGUI, 2); | 328 | mod_lift(KC_GRAVE, KC_LGUI, 2); |
| 237 | } | 329 | } |
| 238 | return false; | 330 | return false; |
| 239 | break; | 331 | break; |
| 240 | case KC_T_RGUI: | 332 | case KC_T_RGUI: |
| 241 | if (record->event.pressed) { | 333 | if (record->event.pressed) { |
| 242 | mod_press(KC_RGUI, 3); | 334 | mod_press(KC_BSLASH, KC_RGUI, 3); |
| 243 | } else { | 335 | } else { |
| 244 | mod_lift(KC_BSLASH, KC_RGUI, 3); | 336 | mod_lift(KC_BSLASH, KC_RGUI, 3); |
| 245 | } | 337 | } |
| 246 | return false; | 338 | return false; |
| 247 | break; | 339 | break; |
| 248 | 340 | ||
| 249 | #+END_SRC | 341 | #+END_SRC |
| 250 | 342 | ||
| 251 | *** Ctrl and [] | 343 | ** Ctrl and [] |
| 252 | 344 | ||
| 253 | Left and right control are [] respectively when they are tapped, making { and } | 345 | Left and right control are [] respectively when they are tapped, making { and } |
| 254 | also very convenient. | 346 | also very convenient. |
| @@ -256,24 +348,24 @@ also very convenient. | |||
| 256 | #+BEGIN_SRC C :noweb yes | 348 | #+BEGIN_SRC C :noweb yes |
| 257 | case KC_T_LCTL: | 349 | case KC_T_LCTL: |
| 258 | if (record->event.pressed) { | 350 | if (record->event.pressed) { |
| 259 | mod_press(KC_LCTL, 4); | 351 | mod_press(KC_LBRACKET, KC_LCTL, 4); |
| 260 | } else { | 352 | } else { |
| 261 | mod_lift(KC_LBRACKET, KC_LCTL, 4); | 353 | mod_lift(KC_LBRACKET, KC_LCTL, 4); |
| 262 | } | 354 | } |
| 263 | return false; | 355 | return false; |
| 264 | break; | 356 | break; |
| 265 | case KC_T_RCTL: | 357 | case KC_T_RCTL: |
| 266 | if (record->event.pressed) { | 358 | if (record->event.pressed) { |
| 267 | mod_press(KC_RCTL, 5); | 359 | mod_press(KC_RBRACKET, KC_RCTL, 5); |
| 268 | } else { | 360 | } else { |
| 269 | mod_lift(KC_RBRACKET, KC_RCTL, 5); | 361 | mod_lift(KC_RBRACKET, KC_RCTL, 5); |
| 270 | } | 362 | } |
| 271 | return false; | 363 | return false; |
| 272 | break; | 364 | break; |
| 273 | 365 | ||
| 274 | #+END_SRC | 366 | #+END_SRC |
| 275 | 367 | ||
| 276 | *** Shft and =- | 368 | ** Shft and =- |
| 277 | 369 | ||
| 278 | I place shift on the home row, so having '-' right of my pinkie is standard, and | 370 | I place shift on the home row, so having '-' right of my pinkie is standard, and |
| 279 | it only felt natural to put its opposite, '=/+' on the other side. I put an | 371 | it only felt natural to put its opposite, '=/+' on the other side. I put an |
| @@ -282,24 +374,24 @@ extra one on the right side in the secondary layer for the num pad. | |||
| 282 | #+BEGIN_SRC C :noweb yes | 374 | #+BEGIN_SRC C :noweb yes |
| 283 | case KC_T_LSFT: | 375 | case KC_T_LSFT: |
| 284 | if (record->event.pressed) { | 376 | if (record->event.pressed) { |
| 285 | mod_press(KC_LSFT, 6); | 377 | mod_press(KC_EQUAL, KC_LSFT, 6); |
| 286 | } else { | 378 | } else { |
| 287 | mod_lift(KC_EQUAL, KC_LSFT, 6); | 379 | mod_lift(KC_EQUAL, KC_LSFT, 6); |
| 288 | } | 380 | } |
| 289 | return false; | 381 | return false; |
| 290 | break; | 382 | break; |
| 291 | case KC_T_RSFT: | 383 | case KC_T_RSFT: |
| 292 | if (record->event.pressed) { | 384 | if (record->event.pressed) { |
| 293 | mod_press(KC_RSFT, 7); | 385 | mod_press(KC_MINUS, KC_RSFT, 7); |
| 294 | } else { | 386 | } else { |
| 295 | mod_lift(KC_MINUS, KC_RSFT, 7); | 387 | mod_lift(KC_MINUS, KC_RSFT, 7); |
| 296 | } | 388 | } |
| 297 | return false; | 389 | return false; |
| 298 | break; | 390 | break; |
| 299 | 391 | ||
| 300 | #+END_SRC | 392 | #+END_SRC |
| 301 | 393 | ||
| 302 | *** Rise, DEL, and / | 394 | ** Rise, DEL, and / |
| 303 | 395 | ||
| 304 | I use the top corners as rise because I decided that I do not like using layers | 396 | I use the top corners as rise because I decided that I do not like using layers |
| 305 | with my thumbs. It feels uncomfortable to hold keys down with the side of my | 397 | with my thumbs. It feels uncomfortable to hold keys down with the side of my |
| @@ -315,36 +407,78 @@ corner again mimicing a standard dvorak keyboard. | |||
| 315 | #+BEGIN_SRC C :noweb yes | 407 | #+BEGIN_SRC C :noweb yes |
| 316 | case KC_T_LRSE: | 408 | case KC_T_LRSE: |
| 317 | if (record->event.pressed) { | 409 | if (record->event.pressed) { |
| 318 | tap_timers[8] = timer_read(); | 410 | tap_timer = timer_read(); |
| 319 | last_mod = 8; | 411 | last_mod = 8; |
| 320 | layer_on(_RISE); | 412 | layer_on(_RISE); |
| 321 | } else { | 413 | } else { |
| 322 | layer_off(_RISE); | 414 | layer_off(_RISE); |
| 323 | if (last_mod == 8 && timer_elapsed(tap_timers[8]) < TAPPING_TERM) { | 415 | if (last_mod == 8 && timer_elapsed(tap_timer) < TAPPING_TERM) { |
| 324 | tap_code16(KC_DELETE); | 416 | tap_code16(KC_DELETE); |
| 325 | last_mod = -1; | 417 | last_mod = 10; |
| 326 | } | 418 | } |
| 327 | } | 419 | } |
| 328 | return false; | 420 | return false; |
| 329 | break; | 421 | break; |
| 330 | case KC_T_RRSE: | 422 | case KC_T_RRSE: |
| 331 | if (record->event.pressed) { | 423 | if (record->event.pressed) { |
| 332 | tap_timers[9] = timer_read(); | 424 | tap_timer = timer_read(); |
| 333 | last_mod = 9; | 425 | last_mod = 9; |
| 334 | layer_on(_RISE); | 426 | layer_on(_RISE); |
| 335 | } else { | 427 | } else { |
| 336 | layer_off(_RISE); | 428 | layer_off(_RISE); |
| 337 | if (last_mod == 9 && timer_elapsed(tap_timers[9]) < TAPPING_TERM) { | 429 | if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) { |
| 338 | tap_code16(KC_SLASH); | 430 | tap_code16(KC_SLASH); |
| 339 | last_mod = -1; | 431 | last_mod = 10; |
| 340 | } | 432 | } |
| 341 | } | 433 | } |
| 342 | return false; | 434 | return false; |
| 343 | break; | 435 | break; |
| 344 | 436 | ||
| 345 | #+END_SRC | 437 | #+END_SRC |
| 346 | 438 | ||
| 347 | *** EZ keys | 439 | ** EZ Keys |
| 440 | |||
| 441 | EZ or "easy" keys do things that can already be done on the board, but I want an | ||
| 442 | easier way of doing them. | ||
| 443 | |||
| 444 | *** One Shot Keys | ||
| 445 | |||
| 446 | Since I made modified tap keys occur on press instead of release, I need one | ||
| 447 | shot keys to press any key with more than one modifier. | ||
| 448 | |||
| 449 | #+BEGIN_SRC C :noweb yes | ||
| 450 | case KC_EZSHFT: | ||
| 451 | if (record->event.pressed) { | ||
| 452 | set_oneshot_mods(MOD_LSFT); | ||
| 453 | last_mod = 10; | ||
| 454 | } | ||
| 455 | return false; | ||
| 456 | break; | ||
| 457 | case KC_EZCTRL: | ||
| 458 | if (record->event.pressed) { | ||
| 459 | set_oneshot_mods(MOD_LCTL); | ||
| 460 | last_mod = 10; | ||
| 461 | } | ||
| 462 | return false; | ||
| 463 | break; | ||
| 464 | case KC_EZALT: | ||
| 465 | if (record->event.pressed) { | ||
| 466 | set_oneshot_mods(MOD_LALT); | ||
| 467 | last_mod = 10; | ||
| 468 | } | ||
| 469 | return false; | ||
| 470 | break; | ||
| 471 | case KC_EZGUI: | ||
| 472 | if (record->event.pressed) { | ||
| 473 | set_oneshot_mods(MOD_LGUI); | ||
| 474 | last_mod = 10; | ||
| 475 | } | ||
| 476 | return false; | ||
| 477 | break; | ||
| 478 | |||
| 479 | #+END_SRC | ||
| 480 | |||
| 481 | *** Arrows | ||
| 348 | 482 | ||
| 349 | I use ctrl+shift+arrows keys a lot, so when the layer key is pressed they became | 483 | I use ctrl+shift+arrows keys a lot, so when the layer key is pressed they became |
| 350 | lazy versions of themselves with control and shift already pressed. | 484 | lazy versions of themselves with control and shift already pressed. |
| @@ -355,77 +489,134 @@ left hand like on a qwerty or colemek keyboard. | |||
| 355 | #+BEGIN_SRC C :noweb yes | 489 | #+BEGIN_SRC C :noweb yes |
| 356 | case KC_EZRGHT: | 490 | case KC_EZRGHT: |
| 357 | if (record->event.pressed) { | 491 | if (record->event.pressed) { |
| 358 | register_code(KC_LCTL); | 492 | register_code(KC_LCTL); |
| 359 | tap_code16(S(KC_RGHT)); | 493 | tap_code16(S(KC_RGHT)); |
| 360 | unregister_code(KC_LCTL); | 494 | unregister_code(KC_LCTL); |
| 361 | last_mod = -1; | 495 | last_mod = 10; |
| 362 | } | 496 | } |
| 363 | return false; | 497 | return false; |
| 364 | break; | 498 | break; |
| 365 | case KC_EZLEFT: | 499 | case KC_EZLEFT: |
| 366 | if (record->event.pressed) { | 500 | if (record->event.pressed) { |
| 367 | register_code(KC_LCTL); | 501 | register_code(KC_LCTL); |
| 368 | tap_code16(S(KC_LEFT)); | 502 | tap_code16(S(KC_LEFT)); |
| 369 | unregister_code(KC_LCTL); | 503 | unregister_code(KC_LCTL); |
| 370 | last_mod = -1; | 504 | last_mod = 10; |
| 371 | } | 505 | } |
| 372 | return false; | 506 | return false; |
| 373 | break; | 507 | break; |
| 374 | case KC_EZDOWN: | 508 | case KC_EZDOWN: |
| 375 | if (record->event.pressed) { | 509 | if (record->event.pressed) { |
| 376 | register_code(KC_LCTL); | 510 | register_code(KC_LCTL); |
| 377 | tap_code16(S(KC_DOWN)); | 511 | tap_code16(S(KC_DOWN)); |
| 378 | unregister_code(KC_LCTL); | 512 | unregister_code(KC_LCTL); |
| 379 | last_mod = -1; | 513 | last_mod = 10; |
| 380 | } | 514 | } |
| 381 | return false; | 515 | return false; |
| 382 | break; | 516 | break; |
| 383 | case KC_EZUP: | 517 | case KC_EZUP: |
| 384 | if (record->event.pressed) { | 518 | if (record->event.pressed) { |
| 385 | register_code(KC_LCTL); | 519 | register_code(KC_LCTL); |
| 386 | tap_code16(S(KC_UP)); | 520 | tap_code16(S(KC_UP)); |
| 387 | unregister_code(KC_LCTL); | 521 | unregister_code(KC_LCTL); |
| 388 | last_mod = -1; | 522 | last_mod = 10; |
| 389 | } | 523 | } |
| 390 | return false; | 524 | return false; |
| 391 | break; | 525 | break; |
| 526 | #+END_SRC | ||
| 527 | |||
| 528 | *** Undo, Copy, Cut, Paste | ||
| 529 | |||
| 530 | #+BEGIN_SRC C :noweb yes | ||
| 392 | case KC_EZUNDO: | 531 | case KC_EZUNDO: |
| 393 | if (record->event.pressed) { | 532 | if (record->event.pressed) { |
| 394 | tap_code16(C(KC_Z)); | 533 | tap_code16(C(KC_Z)); |
| 395 | last_mod = -1; | 534 | last_mod = 10; |
| 396 | } | 535 | } |
| 397 | return false; | 536 | return false; |
| 398 | break; | 537 | break; |
| 399 | case KC_EZCOPY: | 538 | case KC_EZCOPY: |
| 400 | if (record->event.pressed) { | 539 | if (record->event.pressed) { |
| 401 | tap_code16(C(KC_C)); | 540 | tap_code16(C(KC_C)); |
| 402 | last_mod = -1; | 541 | last_mod = 10; |
| 403 | } | 542 | } |
| 404 | return false; | 543 | return false; |
| 405 | break; | 544 | break; |
| 406 | case KC_EZCUT: | 545 | case KC_EZCUT: |
| 407 | if (record->event.pressed) { | 546 | if (record->event.pressed) { |
| 408 | tap_code16(C(KC_X)); | 547 | tap_code16(C(KC_X)); |
| 409 | last_mod = -1; | 548 | last_mod = 10; |
| 410 | } | 549 | } |
| 411 | return false; | 550 | return false; |
| 412 | break; | 551 | break; |
| 413 | case KC_EZPSTE: | 552 | case KC_EZPSTE: |
| 414 | if (record->event.pressed) { | 553 | if (record->event.pressed) { |
| 415 | tap_code16(C(KC_P)); | 554 | tap_code16(C(KC_V)); |
| 416 | last_mod = -1; | 555 | last_mod = 10; |
| 556 | } | ||
| 557 | return false; | ||
| 558 | break; | ||
| 559 | #+END_SRC | ||
| 560 | |||
| 561 | ** Commands | ||
| 562 | |||
| 563 | Start command layer one shot | ||
| 564 | |||
| 565 | #+BEGIN_SRC C :noweb yes | ||
| 566 | case KC_COM: | ||
| 567 | if (record->event.pressed) { | ||
| 568 | layer_on(_COMMAND); | ||
| 569 | set_oneshot_layer(_COMMAND, ONESHOT_START); | ||
| 570 | last_mod = 10; | ||
| 571 | } else { | ||
| 572 | clear_oneshot_layer_state (ONESHOT_PRESSED); | ||
| 417 | } | 573 | } |
| 418 | return false; | 574 | return false; |
| 419 | break; | 575 | break; |
| 420 | #+END_SRC | 576 | #+END_SRC |
| 421 | 577 | ||
| 422 | *** Standard inputs interupt tap | 578 | Just some strings I notice that I type a lot. |
| 579 | |||
| 580 | #+BEGIN_SRC C :noweb yes | ||
| 581 | case KC_USER: | ||
| 582 | if (record->event.pressed) { | ||
| 583 | send_string("mhostley"); | ||
| 584 | last_mod = 10; | ||
| 585 | } | ||
| 586 | return true; | ||
| 587 | break; | ||
| 588 | case KC_EMAIL: | ||
| 589 | if (record->event.pressed) { | ||
| 590 | send_string("mhostley@gmail.com"); | ||
| 591 | last_mod = 10; | ||
| 592 | } | ||
| 593 | return true; | ||
| 594 | break; | ||
| 595 | case KC_NAME: | ||
| 596 | if (record->event.pressed) { | ||
| 597 | send_string("Samuel Jahnke"); | ||
| 598 | last_mod = 10; | ||
| 599 | } | ||
| 600 | return true; | ||
| 601 | break; | ||
| 602 | case KC_DIR: | ||
| 603 | if (record->event.pressed) { | ||
| 604 | send_string("home/mhostley/"); | ||
| 605 | last_mod = 10; | ||
| 606 | } | ||
| 607 | return true; | ||
| 608 | break; | ||
| 609 | |||
| 610 | #+END_SRC | ||
| 611 | |||
| 612 | ** Standard inputs interupt tap | ||
| 423 | 613 | ||
| 424 | Finally, if just a standard key is tapped, set the interupted flag. | 614 | Finally, if just a standard key is tapped, set the interupted flag. |
| 615 | Keep this last. | ||
| 425 | 616 | ||
| 426 | #+BEGIN_SRC C :noweb yes | 617 | #+BEGIN_SRC C :noweb yes |
| 427 | } | 618 | } |
| 428 | last_mod = -1; | 619 | last_mod = 10; |
| 429 | return true; | 620 | return true; |
| 430 | } | 621 | } |
| 431 | #+END_SRC | 622 | #+END_SRC |
diff --git a/keyboards/planck/keymaps/samuel/keymap.c b/keyboards/planck/keymaps/samuel/keymap.c index 53760da76..ff1424489 100644 --- a/keyboards/planck/keymaps/samuel/keymap.c +++ b/keyboards/planck/keymaps/samuel/keymap.c | |||
| @@ -2,36 +2,45 @@ | |||
| 2 | 2 | ||
| 3 | extern keymap_config_t keymap_config; | 3 | extern keymap_config_t keymap_config; |
| 4 | 4 | ||
| 5 | static uint16_t tap_timers[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
| 6 | |||
| 7 | char last_mod = -1; | ||
| 8 | |||
| 9 | enum planck_layers { | ||
| 10 | _DVORAK, | ||
| 11 | _RISE | ||
| 12 | }; | ||
| 13 | |||
| 14 | // where the 'T_' communicates how the key does something different when tapped. | 5 | // where the 'T_' communicates how the key does something different when tapped. |
| 15 | enum planck_keycodes { | 6 | enum planck_keycodes { |
| 16 | DVORAK = SAFE_RANGE, | 7 | //DVORAK = SAFE_RANGE, |
| 17 | KC_T_LALT, | 8 | KC_T_LALT = SAFE_RANGE, |
| 18 | KC_T_RALT, | 9 | KC_T_RALT, |
| 19 | KC_T_LGUI, | 10 | KC_T_LGUI, |
| 20 | KC_T_RGUI, | 11 | KC_T_RGUI, |
| 21 | KC_T_LCTL, | 12 | KC_T_LCTL, |
| 22 | KC_T_RCTL, | 13 | KC_T_RCTL, |
| 23 | KC_T_LSFT, | 14 | KC_T_LSFT, |
| 24 | KC_T_RSFT, | 15 | KC_T_RSFT, |
| 25 | KC_T_LRSE, | 16 | KC_T_LRSE, |
| 26 | KC_T_RRSE, | 17 | KC_T_RRSE, |
| 27 | KC_EZRGHT, | 18 | KC_EZRGHT, |
| 28 | KC_EZLEFT, | 19 | KC_EZLEFT, |
| 29 | KC_EZUP, | 20 | KC_EZUP, |
| 30 | KC_EZDOWN, | 21 | KC_EZDOWN, |
| 31 | KC_EZUNDO, | 22 | KC_EZUNDO, |
| 32 | KC_EZCOPY, | 23 | KC_EZCOPY, |
| 33 | KC_EZCUT, | 24 | KC_EZCUT, |
| 34 | KC_EZPSTE | 25 | KC_EZPSTE, |
| 26 | KC_EZSHFT, | ||
| 27 | KC_EZCTRL, | ||
| 28 | KC_EZGUI, | ||
| 29 | KC_EZALT, | ||
| 30 | KC_DVORAK, | ||
| 31 | KC_QWERTY, | ||
| 32 | KC_USER, | ||
| 33 | KC_EMAIL, | ||
| 34 | KC_NAME, | ||
| 35 | KC_DIR, | ||
| 36 | KC_COM | ||
| 37 | }; | ||
| 38 | |||
| 39 | enum planck_layers { | ||
| 40 | _DVORAK, | ||
| 41 | _QWERTY, | ||
| 42 | _RISE, | ||
| 43 | _COMMAND | ||
| 35 | }; | 44 | }; |
| 36 | 45 | ||
| 37 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 46 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| @@ -44,202 +53,307 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 44 | { 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} | 53 | { 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} |
| 45 | }, | 54 | }, |
| 46 | 55 | ||
| 56 | [_QWERTY] = | ||
| 57 | |||
| 58 | {{ 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}, | ||
| 59 | { 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}, | ||
| 60 | { 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}, | ||
| 61 | { 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} | ||
| 62 | }, | ||
| 63 | |||
| 47 | [_RISE] = | 64 | [_RISE] = |
| 48 | 65 | ||
| 49 | {{ KC_TRANSPARENT, KC_EZUNDO, KC_EZCOPY, KC_EZCUT, KC_EZPSTE, KC_INS, KC_EQL, KC_7, KC_8, KC_9, KC_F11, KC_TRANSPARENT}, | 66 | {{ KC_TRANSPARENT, KC_EZUNDO, KC_EZCOPY, KC_EZCUT, KC_EZPSTE, KC_INS, KC_EQL, KC_7, KC_8, KC_9, KC_TRANSPARENT, KC_TRANSPARENT}, |
| 50 | { KC_TRANSPARENT, KC_ESC, KC_CAPS, KC_PGUP, KC_PGDN, KC_F4, KC_ASTR, KC_4, KC_5, KC_6, KC_0, KC_TRANSPARENT}, | 67 | { KC_EZSHFT, KC_ESC, KC_CAPS, KC_PGUP, KC_PGDN, KC_HOME, KC_ASTR, KC_4, KC_5, KC_6, KC_0, KC_EZSHFT}, |
| 51 | { KC_TRANSPARENT, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_1, KC_2, KC_3, KC_F12, KC_TRANSPARENT}, | 68 | { KC_EZCTRL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_1, KC_2, KC_3, KC_COM, KC_EZCTRL}, |
| 52 | { KC_TRANSPARENT, KC_TRANSPARENT, KC_EZUP, KC_EZDOWN, KC_TRANSPARENT, KC_AMPR, KC_PIPE, KC_TRANSPARENT, KC_EZLEFT, KC_EZRGHT, KC_TRANSPARENT, KC_TRANSPARENT} | 69 | { KC_EZGUI, KC_EZALT, KC_EZUP, KC_EZDOWN, KC_SPC, KC_AMPR, KC_PIPE, KC_END, KC_EZLEFT, KC_EZRGHT, KC_EZALT, KC_EZGUI} |
| 70 | }, | ||
| 71 | |||
| 72 | [_COMMAND] = | ||
| 73 | |||
| 74 | {{ KC_TRANSPARENT, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRANSPARENT}, | ||
| 75 | { KC_TRANSPARENT, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRANSPARENT}, | ||
| 76 | { KC_TRANSPARENT, KC_F21, KC_F22, KC_F23, KC_F24, KC_QWERTY, KC_DVORAK, KC_USER, KC_EMAIL, KC_NAME, KC_TRANSPARENT, KC_TRANSPARENT}, | ||
| 77 | { KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_DIR, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT} | ||
| 53 | }, | 78 | }, |
| 54 | 79 | ||
| 55 | }; | 80 | }; |
| 56 | 81 | ||
| 57 | void mod_press(uint16_t hold_code, int id) { | 82 | static uint16_t tap_timer = 0; |
| 58 | tap_timers[id] = timer_read(); | 83 | char last_mod = 10; |
| 59 | last_mod = id; | 84 | |
| 60 | register_code(hold_code); | 85 | void mod_press(uint16_t tap_code, uint16_t hold_code, int id) { |
| 86 | // this first if body makes double modified keys impossible, but stops the | ||
| 87 | // delay when modifying a tap key which would result in the tap key not | ||
| 88 | // getting modified. | ||
| 89 | if (last_mod != id && last_mod != 10) { | ||
| 90 | tap_code16(tap_code); | ||
| 91 | last_mod = 10; | ||
| 92 | } else { | ||
| 93 | tap_timer = timer_read(); | ||
| 94 | last_mod = id; | ||
| 95 | register_code(hold_code); | ||
| 96 | } | ||
| 61 | } | 97 | } |
| 62 | 98 | ||
| 63 | void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) { | 99 | void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) { |
| 64 | unregister_code(hold_code); | 100 | unregister_code(hold_code); |
| 65 | if (last_mod == id && timer_elapsed(tap_timers[id]) < TAPPING_TERM) { | 101 | if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) { |
| 66 | tap_code16(tap_code); | 102 | tap_code16(tap_code); |
| 67 | last_mod = -1; | 103 | last_mod = 10; |
| 68 | } | 104 | } |
| 69 | } | 105 | } |
| 70 | 106 | ||
| 71 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 107 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 72 | switch (keycode) { | 108 | switch (keycode) { |
| 73 | case DVORAK: | 109 | |
| 74 | if (record->event.pressed) { | 110 | case KC_DVORAK: |
| 75 | set_single_persistent_default_layer(_DVORAK); | 111 | if (record->event.pressed) { |
| 76 | } | 112 | set_single_persistent_default_layer(_DVORAK); |
| 77 | return false; | 113 | } |
| 78 | break; | 114 | return true; |
| 115 | break; | ||
| 116 | |||
| 117 | case KC_QWERTY: | ||
| 118 | if (record->event.pressed) { | ||
| 119 | set_single_persistent_default_layer(_QWERTY); | ||
| 120 | } | ||
| 121 | return true; | ||
| 122 | break; | ||
| 79 | 123 | ||
| 80 | case KC_T_LALT: | 124 | case KC_T_LALT: |
| 81 | if (record->event.pressed) { | 125 | if (record->event.pressed) { |
| 82 | mod_press(KC_LALT, 0); | 126 | mod_press(S(KC_9), KC_LALT, 0); |
| 83 | } else { | 127 | } else { |
| 84 | mod_lift(S(KC_9), KC_LALT, 0); | 128 | mod_lift(S(KC_9), KC_LALT, 0); |
| 85 | } | 129 | } |
| 86 | return false; | 130 | return false; |
| 87 | break; | 131 | break; |
| 88 | case KC_T_RALT: | 132 | case KC_T_RALT: |
| 89 | if (record->event.pressed) { | 133 | if (record->event.pressed) { |
| 90 | mod_press(KC_RALT, 1); | 134 | mod_press(S(KC_0), KC_RALT, 1); |
| 91 | } else { | 135 | } else { |
| 92 | mod_lift(S(KC_0), KC_RALT, 1); | 136 | mod_lift(S(KC_0), KC_RALT, 1); |
| 93 | } | 137 | } |
| 94 | return false; | 138 | return false; |
| 95 | break; | 139 | break; |
| 96 | 140 | ||
| 97 | case KC_T_LGUI: | 141 | case KC_T_LGUI: |
| 98 | if (record->event.pressed) { | 142 | if (record->event.pressed) { |
| 99 | mod_press(KC_LGUI, 2); | 143 | mod_press(KC_GRAVE, KC_LGUI, 2); |
| 100 | } else { | 144 | } else { |
| 101 | mod_lift(KC_GRAVE, KC_LGUI, 2); | 145 | mod_lift(KC_GRAVE, KC_LGUI, 2); |
| 102 | } | 146 | } |
| 103 | return false; | 147 | return false; |
| 104 | break; | 148 | break; |
| 105 | case KC_T_RGUI: | 149 | case KC_T_RGUI: |
| 106 | if (record->event.pressed) { | 150 | if (record->event.pressed) { |
| 107 | mod_press(KC_RGUI, 3); | 151 | mod_press(KC_BSLASH, KC_RGUI, 3); |
| 108 | } else { | 152 | } else { |
| 109 | mod_lift(KC_BSLASH, KC_RGUI, 3); | 153 | mod_lift(KC_BSLASH, KC_RGUI, 3); |
| 110 | } | 154 | } |
| 111 | return false; | 155 | return false; |
| 112 | break; | 156 | break; |
| 113 | 157 | ||
| 114 | case KC_T_LCTL: | 158 | case KC_T_LCTL: |
| 115 | if (record->event.pressed) { | 159 | if (record->event.pressed) { |
| 116 | mod_press(KC_LCTL, 4); | 160 | mod_press(KC_LBRACKET, KC_LCTL, 4); |
| 117 | } else { | 161 | } else { |
| 118 | mod_lift(KC_LBRACKET, KC_LCTL, 4); | 162 | mod_lift(KC_LBRACKET, KC_LCTL, 4); |
| 119 | } | 163 | } |
| 120 | return false; | 164 | return false; |
| 121 | break; | 165 | break; |
| 122 | case KC_T_RCTL: | 166 | case KC_T_RCTL: |
| 123 | if (record->event.pressed) { | 167 | if (record->event.pressed) { |
| 124 | mod_press(KC_RCTL, 5); | 168 | mod_press(KC_RBRACKET, KC_RCTL, 5); |
| 125 | } else { | 169 | } else { |
| 126 | mod_lift(KC_RBRACKET, KC_RCTL, 5); | 170 | mod_lift(KC_RBRACKET, KC_RCTL, 5); |
| 127 | } | 171 | } |
| 128 | return false; | 172 | return false; |
| 129 | break; | 173 | break; |
| 130 | 174 | ||
| 131 | case KC_T_LSFT: | 175 | case KC_T_LSFT: |
| 132 | if (record->event.pressed) { | 176 | if (record->event.pressed) { |
| 133 | mod_press(KC_LSFT, 6); | 177 | mod_press(KC_EQUAL, KC_LSFT, 6); |
| 134 | } else { | 178 | } else { |
| 135 | mod_lift(KC_EQUAL, KC_LSFT, 6); | 179 | mod_lift(KC_EQUAL, KC_LSFT, 6); |
| 136 | } | 180 | } |
| 137 | return false; | 181 | return false; |
| 138 | break; | 182 | break; |
| 139 | case KC_T_RSFT: | 183 | case KC_T_RSFT: |
| 140 | if (record->event.pressed) { | 184 | if (record->event.pressed) { |
| 141 | mod_press(KC_RSFT, 7); | 185 | mod_press(KC_MINUS, KC_RSFT, 7); |
| 142 | } else { | 186 | } else { |
| 143 | mod_lift(KC_MINUS, KC_RSFT, 7); | 187 | mod_lift(KC_MINUS, KC_RSFT, 7); |
| 144 | } | 188 | } |
| 145 | return false; | 189 | return false; |
| 146 | break; | 190 | break; |
| 147 | 191 | ||
| 148 | case KC_T_LRSE: | 192 | case KC_T_LRSE: |
| 149 | if (record->event.pressed) { | 193 | if (record->event.pressed) { |
| 150 | tap_timers[8] = timer_read(); | 194 | tap_timer = timer_read(); |
| 151 | last_mod = 8; | 195 | last_mod = 8; |
| 152 | layer_on(_RISE); | 196 | layer_on(_RISE); |
| 153 | } else { | 197 | } else { |
| 154 | layer_off(_RISE); | 198 | layer_off(_RISE); |
| 155 | if (last_mod == 8 && timer_elapsed(tap_timers[8]) < TAPPING_TERM) { | 199 | if (last_mod == 8 && timer_elapsed(tap_timer) < TAPPING_TERM) { |
| 156 | tap_code16(KC_DELETE); | 200 | tap_code16(KC_DELETE); |
| 157 | last_mod = -1; | 201 | last_mod = 10; |
| 158 | } | 202 | } |
| 159 | } | 203 | } |
| 160 | return false; | 204 | return false; |
| 161 | break; | 205 | break; |
| 162 | case KC_T_RRSE: | 206 | case KC_T_RRSE: |
| 163 | if (record->event.pressed) { | 207 | if (record->event.pressed) { |
| 164 | tap_timers[9] = timer_read(); | 208 | tap_timer = timer_read(); |
| 165 | last_mod = 9; | 209 | last_mod = 9; |
| 166 | layer_on(_RISE); | 210 | layer_on(_RISE); |
| 167 | } else { | 211 | } else { |
| 168 | layer_off(_RISE); | 212 | layer_off(_RISE); |
| 169 | if (last_mod == 9 && timer_elapsed(tap_timers[9]) < TAPPING_TERM) { | 213 | if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) { |
| 170 | tap_code16(KC_SLASH); | 214 | tap_code16(KC_SLASH); |
| 171 | last_mod = -1; | 215 | last_mod = 10; |
| 172 | } | 216 | } |
| 173 | } | 217 | } |
| 218 | return false; | ||
| 219 | break; | ||
| 220 | |||
| 221 | case KC_EZSHFT: | ||
| 222 | if (record->event.pressed) { | ||
| 223 | set_oneshot_mods(MOD_LSFT); | ||
| 224 | last_mod = 10; | ||
| 225 | } | ||
| 226 | return false; | ||
| 227 | break; | ||
| 228 | case KC_EZCTRL: | ||
| 229 | if (record->event.pressed) { | ||
| 230 | set_oneshot_mods(MOD_LCTL); | ||
| 231 | last_mod = 10; | ||
| 232 | } | ||
| 233 | return false; | ||
| 234 | break; | ||
| 235 | case KC_EZALT: | ||
| 236 | if (record->event.pressed) { | ||
| 237 | set_oneshot_mods(MOD_LALT); | ||
| 238 | last_mod = 10; | ||
| 239 | } | ||
| 240 | return false; | ||
| 241 | break; | ||
| 242 | case KC_EZGUI: | ||
| 243 | if (record->event.pressed) { | ||
| 244 | set_oneshot_mods(MOD_LGUI); | ||
| 245 | last_mod = 10; | ||
| 246 | } | ||
| 174 | return false; | 247 | return false; |
| 175 | break; | 248 | break; |
| 176 | 249 | ||
| 177 | case KC_EZRGHT: | 250 | case KC_EZRGHT: |
| 178 | if (record->event.pressed) { | 251 | if (record->event.pressed) { |
| 179 | register_code(KC_LCTL); | 252 | register_code(KC_LCTL); |
| 180 | tap_code16(S(KC_RGHT)); | 253 | tap_code16(S(KC_RGHT)); |
| 181 | unregister_code(KC_LCTL); | 254 | unregister_code(KC_LCTL); |
| 182 | last_mod = -1; | 255 | last_mod = 10; |
| 183 | } | 256 | } |
| 184 | return false; | 257 | return false; |
| 185 | break; | 258 | break; |
| 186 | case KC_EZLEFT: | 259 | case KC_EZLEFT: |
| 187 | if (record->event.pressed) { | 260 | if (record->event.pressed) { |
| 188 | register_code(KC_LCTL); | 261 | register_code(KC_LCTL); |
| 189 | tap_code16(S(KC_LEFT)); | 262 | tap_code16(S(KC_LEFT)); |
| 190 | unregister_code(KC_LCTL); | 263 | unregister_code(KC_LCTL); |
| 191 | last_mod = -1; | 264 | last_mod = 10; |
| 192 | } | 265 | } |
| 193 | return false; | 266 | return false; |
| 194 | break; | 267 | break; |
| 195 | case KC_EZDOWN: | 268 | case KC_EZDOWN: |
| 196 | if (record->event.pressed) { | 269 | if (record->event.pressed) { |
| 197 | register_code(KC_LCTL); | 270 | register_code(KC_LCTL); |
| 198 | tap_code16(S(KC_DOWN)); | 271 | tap_code16(S(KC_DOWN)); |
| 199 | unregister_code(KC_LCTL); | 272 | unregister_code(KC_LCTL); |
| 200 | last_mod = -1; | 273 | last_mod = 10; |
| 201 | } | 274 | } |
| 202 | return false; | 275 | return false; |
| 203 | break; | 276 | break; |
| 204 | case KC_EZUP: | 277 | case KC_EZUP: |
| 205 | if (record->event.pressed) { | 278 | if (record->event.pressed) { |
| 206 | register_code(KC_LCTL); | 279 | register_code(KC_LCTL); |
| 207 | tap_code16(S(KC_UP)); | 280 | tap_code16(S(KC_UP)); |
| 208 | unregister_code(KC_LCTL); | 281 | unregister_code(KC_LCTL); |
| 209 | last_mod = -1; | 282 | last_mod = 10; |
| 210 | } | 283 | } |
| 211 | return false; | 284 | return false; |
| 212 | break; | 285 | break; |
| 286 | |||
| 213 | case KC_EZUNDO: | 287 | case KC_EZUNDO: |
| 214 | if (record->event.pressed) { | 288 | if (record->event.pressed) { |
| 215 | tap_code16(C(KC_Z)); | 289 | tap_code16(C(KC_Z)); |
| 216 | last_mod = -1; | 290 | last_mod = 10; |
| 217 | } | 291 | } |
| 218 | return false; | 292 | return false; |
| 219 | break; | 293 | break; |
| 220 | case KC_EZCOPY: | 294 | case KC_EZCOPY: |
| 221 | if (record->event.pressed) { | 295 | if (record->event.pressed) { |
| 222 | tap_code16(C(KC_C)); | 296 | tap_code16(C(KC_C)); |
| 223 | last_mod = -1; | 297 | last_mod = 10; |
| 224 | } | 298 | } |
| 225 | return false; | 299 | return false; |
| 226 | break; | 300 | break; |
| 227 | case KC_EZCUT: | 301 | case KC_EZCUT: |
| 228 | if (record->event.pressed) { | 302 | if (record->event.pressed) { |
| 229 | tap_code16(C(KC_X)); | 303 | tap_code16(C(KC_X)); |
| 230 | last_mod = -1; | 304 | last_mod = 10; |
| 231 | } | 305 | } |
| 232 | return false; | 306 | return false; |
| 233 | break; | 307 | break; |
| 234 | case KC_EZPSTE: | 308 | case KC_EZPSTE: |
| 235 | if (record->event.pressed) { | 309 | if (record->event.pressed) { |
| 236 | tap_code16(C(KC_P)); | 310 | tap_code16(C(KC_V)); |
| 237 | last_mod = -1; | 311 | last_mod = 10; |
| 238 | } | 312 | } |
| 239 | return false; | 313 | return false; |
| 240 | break; | 314 | break; |
| 241 | 315 | ||
| 242 | } | 316 | case KC_COM: |
| 243 | last_mod = -1; | 317 | if (record->event.pressed) { |
| 244 | return true; | 318 | layer_on(_COMMAND); |
| 319 | set_oneshot_layer(_COMMAND, ONESHOT_START); | ||
| 320 | last_mod = 10; | ||
| 321 | } else { | ||
| 322 | clear_oneshot_layer_state (ONESHOT_PRESSED); | ||
| 323 | } | ||
| 324 | return false; | ||
| 325 | break; | ||
| 326 | |||
| 327 | case KC_USER: | ||
| 328 | if (record->event.pressed) { | ||
| 329 | send_string("mhostley"); | ||
| 330 | last_mod = 10; | ||
| 331 | } | ||
| 332 | return true; | ||
| 333 | break; | ||
| 334 | case KC_EMAIL: | ||
| 335 | if (record->event.pressed) { | ||
| 336 | send_string("mhostley@gmail.com"); | ||
| 337 | last_mod = 10; | ||
| 338 | } | ||
| 339 | return true; | ||
| 340 | break; | ||
| 341 | case KC_NAME: | ||
| 342 | if (record->event.pressed) { | ||
| 343 | send_string("Samuel Jahnke"); | ||
| 344 | last_mod = 10; | ||
| 345 | } | ||
| 346 | return true; | ||
| 347 | break; | ||
| 348 | case KC_DIR: | ||
| 349 | if (record->event.pressed) { | ||
| 350 | send_string("home/mhostley/"); | ||
| 351 | last_mod = 10; | ||
| 352 | } | ||
| 353 | return true; | ||
| 354 | break; | ||
| 355 | |||
| 356 | } | ||
| 357 | last_mod = 10; | ||
| 358 | return true; | ||
| 245 | } | 359 | } |
