]> git.donarmstrong.com Git - qmk_firmware.git/blob - layouts/community/ergodox/emacs_osx_dk/keymap.c
Creates a layouts/ folder for keymaps shared between keyboards (#1609)
[qmk_firmware.git] / layouts / community / ergodox / emacs_osx_dk / keymap.c
1 #include QMK_KEYBOARD_H
2 #include "debug.h"
3 #include "action_layer.h"
4
5 #define BASE 0 // default layer
6 #define SYMB 1 // symbols
7 #define MDIA 2 // media keys
8
9 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
10 /* Keymap 0: Basic layer
11  *
12  * ,--------------------------------------------------.           ,--------------------------------------------------.
13  * |   Grv  |   1  |   2  |   3  |   4  |   5  |  L1  |           |  L2  |   6  |   7  |   8  |   9  |   0  |   =    |
14  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
15  * |   Tab  |   Q  |   W  |   E  |   R  |   T  |  [   |           |   ]  |   Y  |   U  |   I  |   O  |   P  |   -    |
16  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
17  * | \/LCtrl|   A  |   S  |   D  |   F  |   G  |------|           |------|   H  |   J  |   K  |   L  |   ;  |'/RCtrl |
18  * |--------+------+------+------+------+------| RAlt |           | RAlt |------+------+------+------+------+--------|
19  * | LShift |   Z  |   X  |   C  |   V  |   B  |      |           |      |   N  |   M  |   ,  |   .  |   /  | RShift |
20  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
21  *   | ~L1  | LCtrl|  Left| Right| LAlt |                                       | LAlt | Up   | Down | RCtrl|  ~L2 |
22  *   `----------------------------------'                                       `----------------------------------'
23  *                                        ,-------------.       ,-------------.
24  *                                        | Del  | Ins  |       | Esc  | App  |
25  *                                 ,------|------|------|       |------+--------+------.
26  *                                 |      |      | Home |       | PgUp |        |      |
27  *                                 | Space|Backsp|------|       |------|  LGui  |Enter |
28  *                                 |      |ace   | End  |       | PgDn |        |      |
29  *                                 `--------------------'       `----------------------'
30  */
31 // If it accepts an argument (i.e, is a function), it doesn't need KC_.
32 // Otherwise, it needs KC_*
33 [BASE] = LAYOUT_ergodox(  // layer 0 : default
34         // left hand
35         KC_GRV,         KC_1,         KC_2,   KC_3,   KC_4,   KC_5,   TG(SYMB),
36         KC_TAB,         KC_Q,         KC_W,   KC_E,   KC_R,   KC_T,   KC_LBRC,
37         CTL_T(KC_BSLS), KC_A,         KC_S,   KC_D,   KC_F,   KC_G,
38         KC_LSFT,        KC_Z,         KC_X,   KC_C,   KC_V,   KC_B,   KC_RALT,
39         MO(SYMB),       KC_LCTRL,     KC_LEFT,KC_RGHT,KC_LALT,
40                                                       KC_DELT,KC_INS,
41                                                               KC_HOME,
42                                                KC_SPC,KC_BSPC,KC_END,
43         // right hand
44              TG(MDIA),    KC_6,   KC_7,   KC_8,   KC_9,   KC_0,             KC_EQL,
45              KC_RBRC,     KC_Y,   KC_U,   KC_I,   KC_O,   KC_P,             KC_MINS,
46                           KC_H,   KC_J,   KC_K,   KC_L,   KC_SCLN,          CTL_T(KC_QUOT),
47              KC_RALT,     KC_N,   KC_M,   KC_COMM,KC_DOT, KC_SLSH,          KC_RSFT,
48                                   KC_LALT,KC_UP,  KC_DOWN,KC_RCTRL,         MO(MDIA),
49              KC_ESC,      KC_APP,
50              KC_PGUP,
51              KC_PGDN,     KC_LGUI, KC_ENT
52     ),
53 /* Keymap 1: Symbol Layer
54  *
55  * ,--------------------------------------------------.           ,--------------------------------------------------.
56  * |        |  F1  |  F2  |  F3  |  F4  |  F5  |      |           |      |  F6  |  F7  |  F8  |  F9  |  F10 |   F11  |
57  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
58  * |        |   !  |   @  |   {  |   }  |   |  |      |           |      |   Up |   7  |   8  |   9  |   *  |   F12  |
59  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
60  * |        |   #  |   $  |   (  |   )  |   `  |------|           |------| Down |   4  |   5  |   6  |   +  |        |
61  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
62  * |        |   %  |   ^  |   [  |   ]  |   ~  |      |           |      |   &  |   1  |   2  |   3  |   \  |        |
63  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
64  *   |      |      |      |      |      |                                       |   0  |    0 |   .  |   =  |      |
65  *   `----------------------------------'                                       `----------------------------------'
66  *                                        ,-------------.       ,-------------.
67  *                                        |      |      |       |      |      |
68  *                                 ,------|------|------|       |------+------+------.
69  *                                 |      |      |      |       |      |      |      |
70  *                                 |      |      |------|       |------|      |      |
71  *                                 |      |      |      |       |      |      |      |
72  *                                 `--------------------'       `--------------------'
73  */
74 // SYMBOLS
75 [SYMB] = LAYOUT_ergodox(
76        // left hand
77        KC_TRNS,KC_F1,  KC_F2,  KC_F3,  KC_F4,  KC_F5,  KC_TRNS,
78        KC_TRNS,KC_EXLM,KC_AT,  KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS,
79        KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV,
80        KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS,
81        KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
82                                        KC_TRNS,KC_TRNS,
83                                                KC_TRNS,
84                                KC_TRNS,KC_TRNS,KC_TRNS,
85        // right hand
86        KC_TRNS, KC_F6,   KC_F7,  KC_F8,   KC_F9,   KC_F10,  KC_F11,
87        KC_TRNS, KC_UP,   KC_7,   KC_8,    KC_9,    KC_ASTR, KC_F12,
88                 KC_DOWN, KC_4,   KC_5,    KC_6,    KC_PLUS, KC_TRNS,
89        KC_TRNS, KC_AMPR, KC_1,   KC_2,    KC_3,    KC_BSLS, KC_TRNS,
90                          KC_0,   KC_0,    KC_DOT,  KC_EQL,  KC_TRNS,
91        KC_TRNS, KC_TRNS,
92        KC_TRNS,
93        KC_TRNS, KC_TRNS, KC_TRNS
94 ),
95 /* Keymap 2: Media and mouse keys
96  *
97  * ,--------------------------------------------------.           ,--------------------------------------------------.
98  * |        |      |      |      |      |      |      |           |      |      |      |      |      |      |        |
99  * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
100  * |        |      |      | MsUp |      |      |      |           |      |      |      |      |      |      |        |
101  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
102  * |        |      |MsLeft|MsDown|MsRght|      |------|           |------|      |      |      |      |      |  Play  |
103  * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
104  * |        |      |      |      |      |      |      |           |      |      |      | Prev | Next |      |        |
105  * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
106  *   |      |      |      | Lclk | Rclk |                                       |VolUp |VolDn | Mute |      |      |
107  *   `----------------------------------'                                       `----------------------------------'
108  *                                        ,-------------.       ,-------------.
109  *                                        |      |      |       |      |      |
110  *                                 ,------|------|------|       |------+------+------.
111  *                                 |      |      |      |       |      |      |Brwser|
112  *                                 |      |      |------|       |------|      |Back  |
113  *                                 |      |      |      |       |      |      |      |
114  *                                 `--------------------'       `--------------------'
115  */
116 // MEDIA AND MOUSE
117 [MDIA] = LAYOUT_ergodox(
118        KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
119        KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS,
120        KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
121        KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
122        KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2,
123                                            KC_TRNS, KC_TRNS,
124                                                     KC_TRNS,
125                                   KC_TRNS, KC_TRNS, KC_TRNS,
126     // right hand
127        KC_TRNS,  KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
128        KC_TRNS,  KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
129                  KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
130        KC_TRNS,  KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
131                           KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS,
132        KC_TRNS, KC_TRNS,
133        KC_TRNS,
134        KC_TRNS, KC_TRNS, KC_WBAK
135 ),
136 };
137
138 const uint16_t PROGMEM fn_actions[] = {
139     [1] = ACTION_LAYER_TAP_TOGGLE(SYMB)                // FN1 - Momentary Layer 1 (Symbols)
140 };
141
142 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
143 {
144   // MACRODOWN only works in this function
145       switch(id) {
146         case 0:
147         if (record->event.pressed) {
148           register_code(KC_RSFT);
149         } else {
150           unregister_code(KC_RSFT);
151         }
152         break;
153       }
154     return MACRO_NONE;
155 };
156
157 // Runs just one time when the keyboard initializes.
158 void matrix_init_user(void) {
159
160 };
161
162 // Runs constantly in the background, in a loop.
163 void matrix_scan_user(void) {
164
165     uint8_t layer = biton32(layer_state);
166
167     ergodox_board_led_off();
168     ergodox_right_led_1_off();
169     ergodox_right_led_2_off();
170     ergodox_right_led_3_off();
171     switch (layer) {
172       // TODO: Make this relevant to the ErgoDox EZ.
173         case 1:
174             ergodox_right_led_1_on();
175             break;
176         case 2:
177             ergodox_right_led_2_on();
178             break;
179         default:
180             // none
181             break;
182     }
183
184 };