]> git.donarmstrong.com Git - qmk_firmware.git/blob - layouts/community/ergodox/familiar/keymap.c
b359a91d367735f5f8fbc06caaa5c29db329445f
[qmk_firmware.git] / layouts / community / ergodox / familiar / keymap.c
1 #include QMK_KEYBOARD_H
2 #include "debug.h"
3 #include "action_layer.h"
4 #include "version.h"
5
6 // Layers
7 #define BASE 0 // default layer
8 #define SYMB 1 // international symbols
9 #define CSYM 2 // international symbols shifted
10 #define NUMP 3 // numpad
11 #define ARRW 4 // function, media, arrow keys
12
13 // Tap Dancing
14 void dance_lock (qk_tap_dance_state_t *state, void *user_data) {
15     if (state->count == 1) { // Press once for NUMLOCK
16         register_code (KC_NLCK);
17         unregister_code (KC_NLCK);
18     } else if (state->count == 2) { // Press twice for CAPSLOCK
19         register_code (KC_CAPS);
20         unregister_code (KC_CAPS);
21     } else if (state->count == 3) { //Press thrice for SCROLLLOCK
22         register_code (KC_SLCK);
23         unregister_code (KC_SLCK);
24     }
25 }
26 enum {LOCKS = 0};
27 qk_tap_dance_action_t tap_dance_actions[] = {
28     [LOCKS] = ACTION_TAP_DANCE_FN(dance_lock)
29 };
30
31 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
32 // If it accepts an argument (i.e, is a function), it doesn't need KC_.
33 // Otherwise, it needs KC_*
34 /* layer 0 : default
35  *
36  * ,--------------------------------------------------.           ,--------------------------------------------------.
37  * | `      |   1  |   2  |   3  |   4  |   5  |   6  |           |  7   |   8  |   9  |   0  |   -  |   =  | BCKSPC |
38  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
39  * | TAB    |   Q  |   W  |   E  |   R  |   T  | HOME |           | PGUP |   Y  |   U  |   I  |   O  |   P  | DELETE |
40  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
41  * | '      |   A  |   S  |   D  |   F  |   G  |------|           |------|   H  |   J  |   K  |   L  |   ;  |  ENTER |
42  * |--------+------+------+------+------+------|  END |           | PGDN |------+------+------+------+------+--------|
43  * | (/LSFT |   Z  |   X  |   C  |   V  |   B  |      |           |      |   N  |   M  |   ,  |   .  |  UP  | )/RSFT |
44  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
45  * | LCTRL  | LGUI | MENU | LEAD | LALT |                                       |[/RALT|]/RCTL| LEFT | DOWN |  RIGHT |
46  * `------------------------------------'                                       `------------------------------------'
47  *                                        ,-------------.       ,-------------.
48  *                                        |PRTSCR| ESC  |       | VOL- | VOL+ |
49  *                                 ,------|------|------|       |------+------+------.
50  *                                 |      |SLASH/| LOCKS|       | MUTE |WHACK/|      |
51  *                                 |  SPC | MO(4)|------|       |------|MO(4) | SPC  |
52  *                                 |      |      | TO(1)|       |TO(3) |      |      |
53  *                                 `--------------------'       `--------------------'
54  */
55 [BASE] = LAYOUT_ergodox(
56         // left hand
57         KC_GRV,     KC_1,       KC_2,       KC_3,       KC_4,       KC_5,       KC_6,
58         KC_TAB,     KC_Q,       KC_W,       KC_E,       KC_R,       KC_T,       KC_HOME,
59         KC_QUOT,    KC_A,       KC_S,       KC_D,       KC_F,       KC_G,
60         KC_LSPO,    KC_Z,       KC_X,       KC_C,       KC_V,       KC_B,       KC_END,
61         KC_LCTL,    KC_LGUI,    KC_MENU,    KC_LEAD,    KC_LALT,
62                                                                     KC_PSCR,    KC_ESC,
63                                                                                 TD(LOCKS),
64                                                 KC_SPC,     LT(ARRW, KC_SLSH),  TG(SYMB),
65         // right hand
66             KC_7,       KC_8,       KC_9,       KC_0,       KC_MINS,    KC_EQL,     KC_BSPC,
67             KC_PGUP,    KC_Y,       KC_U,       KC_I,       KC_O,       KC_P,       KC_DEL,
68                         KC_H,       KC_J,       KC_K,       KC_L,       KC_SCLN,    KC_ENTER,
69             KC_PGDN,    KC_N,       KC_M,       KC_COMM,    KC_DOT,     KC_UP,      KC_RSPC,
70                         MT(MOD_RALT, KC_LBRC),  MT(MOD_RCTL, KC_RBRC),  KC_LEFT,    KC_DOWN,    KC_RGHT,
71             KC_VOLD,    KC_VOLU,
72             KC_MUTE,
73             TG(NUMP),   LT(ARRW, KC_BSLS),   KC_SPC
74     ),
75
76 /* layer 1: International symbols, etc
77  *
78  * ,--------------------------------------------------.           ,--------------------------------------------------.
79  * |        |   ¡  |   ²  |   ³  |   ¤  |   €  |   ¼  |           |  ½   |  ¾   |  ‘   |  ’   |  ¥   |  ×   |        |
80  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
81  * |        |   ä  |   å  |   é  |   ®  |   þ  |      |           |      |  ü   |  ú   |  í   |  ó   |  ö   |        |
82  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
83  * |     ´  |   á  |   ß  |   ð  |      |      |------|           |------|      |      |      |  ø   |  ¶   |        |
84  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
85  * |MO(CSYM)|   æ  |   ¿  |   ©  |   ¬  |      |      |           |      |  ñ   |  µ   |  ç   |      |      |MO(CSYM)|
86  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
87  * |        |      |      |      |      |                                       |  «   |  »   |      |      |        |
88  * `------------------------------------'                                       `------------------------------------'
89  *                                        ,-------------.       ,-------------.
90  *                                        |      |      |       |      |      |
91  *                                 ,------|------|------|       |------+------+------.
92  *                                 |      |      |      |       |      |      |      |
93  *                                 |      |      |------|       |------|      |      |
94  *                                 |      |      |      |       |      |      |      |
95  *                                 `--------------------'       `--------------------'
96  */
97 [SYMB] = LAYOUT_ergodox(
98         // left hand
99         _______,    UC(0x00A1), UC(0x00B2), UC(0x00B3), UC(0x00A4), UC(0x20AC), UC(0x00BC),
100         _______,    UC(0x00E4), UC(0x00E5), UC(0x00E9), UC(0x00AE), UC(0x00FE), _______,
101         UC(0x00B4), UC(0x00E1), UC(0x00DF), UC(0x00F0), _______,    _______,
102         MO(CSYM),   UC(0x00E6), UC(0x00BF), _______,    UC(0x00AC), UC(0x00A9),    _______,
103         _______,    _______,    _______,    _______,    _______,
104                                             _______,    _______,
105                                                         _______,
106                             _______,        _______,    _______,
107         // right hand
108             UC(0x00BD), UC(0x00BE), UC(0x2018), UC(0x2019), UC(0x00A5), UC(0x00D7), _______,
109             _______,    UC(0x00FC), UC(0x00FA), UC(0x00ED), UC(0x00F3), UC(0x00F6), _______,
110                         _______,    _______,    _______,    UC(0x00F8), UC(0x00B6), _______,
111             _______,    UC(0x00F1), UC(0x00B5), UC(0x00E7), _______,    _______,    MO(CSYM),
112                                     UC(0x00AB), UC(0x00BB), _______,    _______,    _______,
113             _______,    _______,
114             _______,
115             _______,    _______,    _______
116     ),
117
118 /* layer 2 : international symbols, shifted
119  * This layer is an ugly workaround; it pretends that SHIFT still works normally on keys
120  * which don't produce an "upper case" or "shifted" international symobol.
121  *
122  * ,--------------------------------------------------.           ,--------------------------------------------------.
123  * |        |   ¹  |      |      |   £  |      |      |           |      |      |      |      |  —  |  ÷   |        |
124  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
125  * |        |   Ä  |   Å  |   É  |      |   Þ  |      |           |      |  Ü   |  Ú   |  Í   |  Ó   |  Ö   |        |
126  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
127  * |     ¨  |   Á  |   §  |   Ð  |      |      |------|           |------|      |      |      |  Ø   |  °   |        |
128  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
129  * |        |   Æ  |      |   ¢  |   ¦  |      |      |           |      |  Ñ   |      |  Ç   |      |      |        |
130  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
131  * |        |      |      |      |      |                                       |  “   |  ”   |      |      |        |
132  * `------------------------------------'                                       `------------------------------------'
133  *                                        ,-------------.       ,-------------.
134  *                                        |      |      |       |      |      |
135  *                                 ,------|------|------|       |------+------+------.
136  *                                 |      |      |      |       |      |      |      |
137  *                                 |      |      |------|       |------|      |      |
138  *                                 |      |      |      |       |      |      |      |
139  *                                 `--------------------'       `--------------------'
140  */
141 [CSYM] = LAYOUT_ergodox(
142         // left hand
143         _______,    UC(0x00B9), _______,    _______,    UC(0x00A3), _______,    _______,
144         _______,    UC(0x00C4), UC(0x00C5), UC(0x00C9), S(KC_R),    UC(0x00DE), _______,
145         UC(0x00A8), UC(0x00C1), UC(0x00A7), UC(0x00D0), S(KC_F),    S(KC_G),
146         _______,    UC(0x00C6), UC(0x00A6), UC(0x00A2), S(KC_V),    S(KC_B),    _______,
147         _______,    _______,    _______,    _______,    _______,
148                                                                     _______,    _______,
149                                                                                 _______,
150                                                     _______,        _______,    _______,
151         // right hand
152             _______,    _______,    _______,    _______,    UC(0x2014), UC(0x00F7), _______,
153             _______,    UC(0x00DC), UC(0x00DA), UC(0x00CD), UC(0x00D3), UC(0x00D6), _______,
154                         S(KC_H),    S(KC_J),    S(KC_K),    UC(0x00D8), UC(0x00B0), _______,
155             _______,    UC(0x00D1), _______,    UC(0x00C7), S(KC_DOT),  _______,    _______,
156                                     UC(0x201C), UC(0x201D), _______,    _______,    _______,
157             _______,    _______,
158             _______,
159             _______,    _______,    _______
160     ),
161
162 /* layer 3: numberpad
163  *
164  * ,--------------------------------------------------.           ,--------------------------------------------------.
165  * |        |      |      |      |      |      |      |           |      |      |   (  |   )  |   /  |  *   |        |
166  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
167  * |        |      |      |      |      |      |      |           |      |      |   7  |   8  |   9  |  -   |        |
168  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
169  * |        |      |      |      |      |      |------|           |------|      |   4  |   5  |   6  |  +   |        |
170  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
171  * |        |      |      |      |      |      |      |           |      |      |   1  |   2  |   3  |  =   |        |
172  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
173  * |        |      |      |      |      |                                       |0/RALT|./RCTL|   ,  | ENTER|        |
174  * `------------------------------------'                                       `------------------------------------'
175  *                                        ,-------------.       ,-------------.
176  *                                        |      |      |       |      |      |
177  *                                 ,------|------|------|       |------+------+------.
178  *                                 |      |      |      |       |      |      |      |
179  *                                 |      |      |------|       |------|      |      |
180  *                                 |      |      |      |       |      |      |      |
181  *                                 `--------------------'       `--------------------'
182  */
183 [NUMP] = LAYOUT_ergodox(
184         // left hand
185         _______,    _______,    _______,    _______,    _______,    _______,    _______,
186         _______,    _______,    _______,    _______,    _______,    _______,    _______,
187         _______,    _______,    _______,    _______,    _______,    _______,
188         _______,    _______,    _______,    _______,    _______,    _______,    _______,
189         _______,    _______,    _______,    _______,    _______,
190                                             _______,    _______,
191                                                         _______,
192                             _______,        _______,    _______,
193         // right hand
194             _______,    _______,    S(KC_9),    S(KC_0),    KC_PSLS,    KC_PAST,    _______,
195             _______,    _______,    KC_KP_7,    KC_KP_8,    KC_KP_9,    KC_PMNS,    _______,
196                         _______,    KC_KP_4,    KC_KP_5,    KC_KP_6,    KC_PPLS,    _______,
197             _______,    _______,    KC_KP_1,    KC_KP_2,    KC_KP_3,    KC_PEQL,    _______,
198                                     MT(MOD_RALT, KC_KP_0),  MT(MOD_RCTL, KC_KP_DOT),KC_PCMM,    KC_PENT,    _______,
199             _______,    _______,
200             _______,
201             _______,    _______,    _______
202     ),
203
204 /* layer 4 : functions and arrows
205  * This layer is at the top so that the functions still work no matter what layers are active.
206  *
207  * ,--------------------------------------------------.           ,--------------------------------------------------.
208  * | ESCAPE |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |           |  F7  |  F8  |  F9  | F10  | F11  | F12  |        |
209  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
210  * |        |      |      |  UP  |      |      |      |           |      |      |      |      |      |      | INSERT |
211  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
212  * |        |      | LEFT | DOWN |RIGHT |      |------|           |------| LEFT | DOWN |  UP  | RIGHT|      |        |
213  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
214  * |        |M_PREV|M_STOP|M_PLPS|M_NEXT|      |      |           |      |      |      |      |      | PGUP |        |
215  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
216  * |        |      |      |      |      |                                       |      |      | HOME | PGDN |    END |
217  * `------------------------------------'                                       `------------------------------------'
218  *                                        ,-------------.       ,-------------.
219  *                                        | SYSRQ| PAUSE|       |      |      |
220  *                                 ,------|------|------|       |------+------+------.
221  *                                 |      |      |      |       |      |      |      |
222  *                                 |      |      |------|       |------|      |      |
223  *                                 |      |      |      |       |      |      |      |
224  *                                 `--------------------'       `--------------------'
225  */
226 [ARRW] = LAYOUT_ergodox(
227         // left hand
228         KC_ESC,     KC_F1,      KC_F2,      KC_F3,      KC_F4,      KC_F5,      KC_F6,
229         _______,    _______,    _______,    KC_UP,      _______,    _______,    _______,
230         _______,    _______,    KC_LEFT,    KC_DOWN,    KC_RGHT,    _______,
231         _______,    KC_MPRV,    KC_MSTP,    KC_MPLY,    KC_MNXT,    _______,    _______,
232         _______,    _______,    _______,    _______,    _______,
233                                                                     KC_SYSREQ,  KC_PAUSE,
234                                                                                 _______,
235                                                     _______,        _______,    _______,
236         // right hand
237             KC_F7,      KC_F8,      KC_F9,      KC_F10,     KC_F11,     KC_F12,     _______,
238             _______,    _______,    _______,    _______,    _______,    _______,    KC_INS,
239                         KC_LEFT,    KC_DOWN,    KC_UP,      KC_RGHT,    _______,    _______,
240             _______,    _______,    _______,    _______,    _______,    KC_PGUP,    _______,
241                                     _______,    _______,    KC_HOME,    KC_PGDN,    KC_END,
242             _______,    _______,
243             _______,
244             _______,    _______,    _______
245     ),
246 };
247
248 // Runs just one time when the keyboard initializes.
249 void matrix_init_user(void) {
250     set_unicode_input_mode(UC_LNX); // Linux
251     //set_unicode_input_mode(UC_OSX); // Mac OSX
252     //set_unicode_input_mode(UC_WIN); // Windows (with registry key, see wiki)
253     //set_unicode_input_mode(UC_WINC); // Windows (with WinCompose, see wiki)
254 };
255
256 // Runs constantly in the background, in a loop.
257 void matrix_scan_user(void) {
258
259     uint8_t layer = biton32(layer_state);
260
261     ergodox_board_led_off();
262     ergodox_right_led_1_off();
263     ergodox_right_led_2_off();
264     ergodox_right_led_3_off();
265     switch (layer) {
266         case SYMB:
267         case CSYM:
268             ergodox_right_led_1_on();
269             break;
270         case NUMP:
271             ergodox_right_led_2_on();
272             break;
273         case ARRW:
274             ergodox_right_led_3_on();
275             break;
276         default:
277             // none
278             break;
279     }
280
281 };