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