]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - keyboard/ergodox/keymap_colemak.c
Merge remote-tracking branch 'tmk/master'
[max/tmk_keyboard.git] / keyboard / ergodox / keymap_colemak.c
1 /*
2 Copyright 2016 Paul Williamson <squarefrog@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include <util/delay.h>
18 #include "bootloader.h"
19 #include "keymap_common.h"
20
21
22 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
23
24     /*
25      * Keymap 0: Default Colemak Layer
26      *
27      * This is a general purpose Colemak layout which should serve as a good
28      * basis for your own custom layout. Mac users may want to swap the
29      * position of the Alt and GUI keys.
30      *
31      * ,--------------------------------------------------.           ,--------------------------------------------------.
32      * |  Esc   |   1  |   2  |   3  |   4  |   5  |  ~   |           |  -   |   6  |   7  |   8  |   9  |   0  |   +    |
33      * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
34      * |  Tab   |   Q  |   W  |   F  |   P  |   G  |  [   |           |  ]   |   J  |   L  |   U  |   Y  |   ;  |   \    |
35      * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
36      * | CpsLk  |   A  |   R  |   S  |   T  |   D  |------|           |------|   H  |   N  |   E  |   I  |   O  |   '    |
37      * |--------+------+------+------+------+------| +L2  |           |      |------+------+------+------+------+--------|
38      * | LShift |   Z  |   X  |   C  |   V  |   B  |      |           |      |   K  |   M  |   ,  |   .  |   /  | RShift |
39      * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
40      *   | LCtrl| LGui | LAlt | Left | Rght |                                       |  Up  |  Dn  | RAlt | RGui | RCtrl |
41      *   `----------------------------------'                                       `----------------------------------'
42      *                                        ,-------------.       ,-------------.
43      *                                        |CpsLck| Del  |       | PgUp | PgDn |
44      *                                 ,------|------|------|       |------+------+------.
45      *                                 |      |      | LAlt |       | RAlt |      |      |
46      *                                 | BkSp | ~L1  |------|       |------| Enter| Space|
47      *                                 |      |      | LCtrl|       | RCtrl|      |      |
48      *                                 `--------------------'       `--------------------'
49      */
50
51     KEYMAP(
52         // left hand
53         ESC, 1,   2,   3,   4,   5,   GRV,
54         TAB, Q,   W,   F,   P,   G,   LBRC,
55         CAPS,A,   R,   S,   T,   D,
56         LSFT,Z,   X,   C,   V,   B,   FN2,
57         LCTL,LGUI,LALT,LEFT,RGHT,
58                                       CAPS,DEL,
59                                            LALT,
60                                  BSPC,FN1, LCTL,
61         // right hand
62              MINS,6,   7,   8,   9,   0,   EQL,
63              RBRC,J,   L,   U,   Y,   SCLN,BSLS,
64                   H,   N,   E,   I,   O,   QUOT,
65              NO,  K,   M,   COMM,DOT, SLSH,RSFT,
66                        UP,  DOWN,RALT,RGUI,RCTL,
67         PGUP,PGDN,
68         RALT,
69         RCTL,ENT, SPC
70     ),
71
72     /*
73      * Layer 1: Function keys
74      *
75      * This layer contains function keys, and media keys. Additionally, there
76      * are QWERTY-style Vim arrow keys. I could never get used to Colemak's
77      * rearranged Vim arrow placements.
78      *
79      * Most of the non-modifier keys are marked as NO, so it's immediately
80      * obvious if you start typing on a secondary layer.
81      *
82      * ,--------------------------------------------------.           ,--------------------------------------------------.
83      * | Teensy |  F1  |  F2  |  F3  |  F4  |  F5  |  F11 |           |  F12 |  F6  |  F7  |  F8  |  F9  |  F10 |  TRNS  |
84      * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
85      * |   TRNS |      |      |      |      |      | TRNS |           | TRNS |      |      |      |      |      |  TRNS  |
86      * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
87      * |   TRNS |      |      |      |      |      |------|           |------| Left | Down |  Up  | Right|      |  TRNS  |
88      * |--------+------+------+------+------+------| +L2  |           |      |------+------+------+------+------+--------|
89      * |   TRNS |      |      |      |      |      |      |           |      |      |      |      |      |      |  TRNS  |
90      * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
91      *   | TRNS | TRNS | Play |  RW  |  FF  |                                       | Mute | Vol- | Vol+ | TRNS | TRNS |
92      *   `----------------------------------'                                       `----------------------------------'
93      *                                        ,-------------.       ,-------------.
94      *                                        |      |      |       | HOME |  END |
95      *                                 ,------|------|------|       |------+------+------.
96      *                                 |      |      | TRNS |       | TRNS |      |      |
97      *                                 | TRNS |      |------|       |------| TRNS | TRNS |
98      *                                 |      |      | TRNS |       | TRNS |      |      |
99      *                                 `--------------------'       `--------------------'
100      */
101
102     KEYMAP(
103         // left hand
104         FN31,F1,  F2,  F3,  F4,  F5,  F11,
105         TRNS,NO,  NO,  NO,  NO,  NO,  TRNS,
106         TRNS,NO,  NO,  NO,  NO,  NO,
107         TRNS,NO,  NO,  NO,  NO,  NO,  FN2,
108         TRNS,TRNS,MPLY,MPRV,MNXT,
109                                       NO,  NO,
110                                            TRNS,
111                                  TRNS,NO,  TRNS,
112         // right hand
113              F12, F6,  F7,  F8,  F9,  F10, TRNS,
114              TRNS,NO,  NO,  NO,  NO,  NO,  TRNS,
115                   LEFT,DOWN,UP,  RGHT,NO,  TRNS,
116              NO,  NO,  NO,  NO,  NO,  NO,  TRNS,
117                        MUTE,VOLD,VOLU,TRNS,TRNS,
118         HOME,END,
119         TRNS,
120         TRNS,TRNS,TRNS
121     ),
122
123     /*
124     * Layer 2: Number Pad
125     *
126     * This layer has a number pad for quicker number entry. As with layer 1,
127     * most of the non-modifier keys are marked as NO, so it's immediately
128     * obvious if you start typing on a secondary layer.
129     *
130     * Inspired by Ben Blazak QWERTY num pad.
131     * https://git.io/voIeY
132     *
133     * ,--------------------------------------------------.           ,--------------------------------------------------.
134     * |   ESC  |      |      |      |      |      |      |           |      |      | NmLk |   /  |   *  |   -  | Bkspc  |
135     * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
136     * |   TRNS |      |      |      |      |      | TRNS |           | TRNS |      |   7  |   8  |   9  |   +  | Bkspc  |
137     * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
138     * |   TRNS |      |      |      |      |      |------|           |------|      |   4  |   5  |   6  |   +  | Enter  |
139     * |--------+------+------+------+------+------|      |           | -L0  |------+------+------+------+------+--------|
140     * |   TRNS |      |      |      |      |      |      |           |      |      |   1  |   2  |   3  | Enter| Enter  |
141     * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
142     *   | TRNS | TRNS | LALT |      |      |                                       |   0  |   0  |   .  | Enter| Enter|
143     *   `----------------------------------'                                       `----------------------------------'
144     *                                        ,-------------.       ,-------------.
145     *                                        |      |      |       | TRNS | TRNS |
146     *                                 ,------|------|------|       |------+------+------.
147     *                                 |      |      | TRNS |       | TRNS |      |      |
148     *                                 | Bkspc|      |------|       |------| Enter|      |
149     *                                 |      |      | TRNS |       | TRNS |      |      |
150     *                                 `--------------------'       `--------------------'
151     */
152
153     KEYMAP(
154         // left hand
155         ESC, NO,  NO,  NO,  NO,  NO,  NO,
156         TRNS,NO,  NO,  NO,  NO,  NO,  TRNS,
157         TRNS,NO,  NO,  NO,  NO,  NO,
158         TRNS,NO,  NO,  NO,  NO,  NO,  NO,
159         TRNS,TRNS,LALT,NO,  NO,
160                                       NO,  NO,
161                                            TRNS,
162                                  BSPC,NO,  TRNS,
163         // right hand
164              NO,  NO,  NLCK,SLSH,PAST,PMNS,BSPC,
165              TRNS,NO,  P7,  P8,  P9,  PPLS,BSPC,
166                   NO,  P4,  P5,  P6,  PPLS,PENT,
167              FN0, NO,  P1,  P2,  P3,  PENT,PENT,
168                        P0,  P0,  PDOT,PENT,PENT,
169         TRNS,TRNS,
170         TRNS,
171         TRNS,ENT, TRNS
172     ),
173 };
174
175 /* id for user defined functions */
176 enum function_id {
177     TEENSY_KEY,
178 };
179
180 /*
181  * Fn action definition
182  */
183 const action_t PROGMEM fn_actions[] = {
184     // Layer shifting
185     [0] = ACTION_LAYER_SET(0, ON_PRESS),           // Switch to Layer 0
186     [1] = ACTION_LAYER_MOMENTARY(1),               // Momentarily switch to layer 1
187     [2] = ACTION_LAYER_SET(2, ON_PRESS),           // Switch to Layer 2
188
189     // Teensy
190     [31] = ACTION_FUNCTION(TEENSY_KEY),
191 };
192
193 void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
194 {
195     if (id == TEENSY_KEY) {
196         clear_keyboard();
197         print("\n\nJump to bootloader... ");
198         _delay_ms(250);
199         bootloader_jump(); // should not return
200         print("not supported.\n");
201     }
202 }
203