summaryrefslogtreecommitdiff
path: root/keyboards/ergodox_ez/keymaps/colemak_es_osx/keymap.c
blob: 15692b18d1e72310062a2521da9027dae03ede13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
/*
  Copyright 2019 Mario Arias <mario@marioarias.org>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include QMK_KEYBOARD_H
#include "version.h"

#include "keymap_spanish.h"

enum layers {
    BASE = 0,   //Colemak
    QWERTY,     //Qwerty
    FN,         //Colemak but FN1 to FN12 instead of numbers
    NUM,        //Numpad
    MOUSE,      //Mouse and media controls
    IDEA        //Shortcuts for IDEA / Other tools
};

//Special paste
#define S_PASTE     LSFT(LGUI(KC_V))
//tmux prefix
#define T_PREFIX    LCTL(KC_B)
// Column mode
#define I_COLUMN    ALGR(LCTL(LGUI(ES_MINS)))
// Terminal
#define I_TERM      ALGR(KC_F12)
// Line comment
#define I_LN_COM    LCTL(LGUI(KC_7))
// Block comment
#define I_BK_COM    LCTL(LGUI(KC_8))
// Reformat code
#define I_REFORM    LALT(LGUI(KC_L))
// Rename
#define I_RENAME    LSFT(KC_F6)
// Find usages
#define I_FUSAGE    LALT(KC_F7)
// Code for Packt
#define P_CODE      LCTL(ALGR(KC_X))
// Search
#define I_SEARCH    LCTL(LSFT(KC_F))


const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Colemak MacOS Spanish layer
 * ,--------------------------------------------------.           ,--------------------------------------------------.
 * |   Esc  |  1 ! | 2 "  | 3 ·  | 4 $  | 5 %  |  º \ |           | ¡ ¿  |  6 & | 7 /  |  8 ( | 9 )  | 0 =  | Backsp |
 * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
 * |   TAB  |   Q  |   W  |   F  |   P  |   G  | Home |           | End  |   J  |   L  |   U  |   Y  |  Ñ   |  ' ?   |
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 * |  CAPS  |   A  |   R  |   S  |   T  |   D  |------|           |------|   H  |   N  |   E  |   I  |  O   |  ENT   |
 * |--------+------+------+------+------+------|  <>  |           |  -_  |------+------+------+------+------+--------|
 * | Shift  |   Z  |   X  |   C  |   V  |   B  |      |           |      |   K  |   M  |  , ; |  . : |  UP  | Shift  |
 * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
 *   | Del  | PgUp |Ctl/PD|Alt/[ |Cmd/] |                                       |Cmd/{ |Alt/} | LEFT | DOWN | RIGHT|
 *   `----------------------------------'                                       `----------------------------------'
 *                                        ,--------------.        ,--------------.
 *                                        | Num  | Mouse |        | Qwer | Ctrl  |
 *                                 ,------|------|-------|        |------+-------+------.
 *                                 |      |      | FN    |        |SPaste|       |      |
 *                                 |LShift|Backsp|-------|        |------|  ENT  |Space |
 *                                 |      |      | IDEA  |        | T-pre|       |      |
 *                                 `---------------------'        `---------------------'
 */
[BASE] = LAYOUT_ergodox(
// left hand
        KC_ESC,     KC_1,       KC_2,           KC_3,           KC_4,        KC_5,        ES_LABK,
        KC_TAB,     KC_Q,       KC_W,           KC_F,           KC_P,        KC_G,        KC_HOME,
        KC_CAPS,    KC_A,       KC_R,           KC_S,           KC_T,        KC_D,
        KC_LSFT,    KC_Z,       KC_X,           KC_C,           KC_V,        KC_B,        KC_GRV,
        KC_DEL,     KC_PGUP,    CTL_T(KC_PGDN), ALT_T(ES_GRV),  GUI_T(ES_PLUS),

                                                                            DF(NUM),    DF(MOUSE),
                                                                                        DF(FN),
                                                                KC_LSFT,    KC_BSPC,    MO(IDEA),

// right hand
        ES_IEXL,        KC_6,           KC_7,       KC_8,       KC_9,       KC_0,       KC_BSPC,
        KC_END,         KC_J,           KC_L,       KC_U,       KC_Y,       ES_NTIL,    ES_QUOT,
                        KC_H,           KC_N,       KC_E,       KC_I,       KC_O,       KC_ENT,
        ES_MINS,        KC_K,           KC_M,       KC_COMM,    KC_DOT,     KC_UP,      KC_RSFT,
                                GUI_T(ES_ACUT), ALT_T(KC_BSLS), KC_LEFT,    KC_DOWN,    KC_RIGHT,

        DF(QWERTY),     KC_RCTL,
        S_PASTE,
        T_PREFIX,       KC_ENT,     KC_SPC
),
/* Keymap 1: Spanish QWERTY layer (games) //Will probably change it for a Linux/Windows Colemak layer
 *
 * ,--------------------------------------------------.           ,--------------------------------------------------.
 * |        |      |      |      |      |      |      |           |      |      |      |      |      |      |        |
 * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
 * |        |   Q  |   W  |   E  |   R  |   T  |      |           |      |   Y  |   U  |   I  |   O  |   P  |        |
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 * |        |   A  |   S  |   D  |   F  |   G  |------|           |------|   H  |   J  |   K  |   L  |   Ñ  |        |
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 * |        |   Z  |   X  |   C  |   V  |   B  |      |           |      |   N  |   M  |      |      |      |        |
 * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
 *   |      |      |      |      |      |                                       |      |      |      |      |      |
 *   `----------------------------------'                                       `----------------------------------'
 *                                        ,-------------.       ,-------------.
 *                                        |      |      |       | Base |      |
 *                                 ,------|------|------|       |------+--------+------.
 *                                 |      |      |      |       |      |        |      |
 *                                 |      |      |------|       |------|        |      |
 *                                 |      |      |      |       |      |        |      |
 *                                 `--------------------'       `----------------------'
 */
[QWERTY] = LAYOUT_ergodox(
  // left hand
        _______,        _______,    _______,    _______,    _______,    _______,    _______,
        _______,        KC_Q,       KC_W,       KC_E,       KC_R,       KC_T,       _______,
        _______,        KC_A,       KC_S,       KC_D,       KC_F,       KC_G,
        _______,        KC_Z,       KC_X,       KC_C,       KC_V,       KC_B,       _______,
        _______,        _______,    _______,    _______,    _______,

                                                                        _______,    _______,
                                                                                    _______,
                                                        _______,        _______,    _______,

// right hand
        _______,        _______,    _______,    _______,    _______,    _______,    _______,
        _______,        KC_Y,       KC_U,       KC_I,       KC_O,       KC_P,       _______,
                        KC_H,       KC_J,       KC_K,       KC_L,       KC_SCLN,    _______,
        _______,        KC_N,       KC_M,       _______,    _______,    _______,    _______,
                                    _______,    _______,    _______,    _______,    _______,
        DF(BASE),   _______,
        _______,
        _______,    _______,    _______
),
/* Keymap 2: Function Layer
*
* ,--------------------------------------------------.           ,--------------------------------------------------.
* |        |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |           |  F7  |  F8  |  F9  | F10  | F11  | F12  |        |
* |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
* |        |      |      |      |      |      |      |           |      |      |      |      |      |      |        |
* |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
* |        |      |      |      |      |      |------|           |------|      |      |      |      |      |        |
* |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
* |        |      |      |      |      |      |      |           |      |      |      |      |      |      |        |
* `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
*   |      |      |      |      |      |                                       |      |      |      |      |      |
*   `----------------------------------'                                       `----------------------------------'
*                                        ,-------------.       ,-------------.
*                                        |      |      |       |      |      |
*                                 ,------|------|------|       |------+------+------.
*                                 |      |      | Base |       |      |      |      |
*                                 |      |      |------|       |------|      |      |
*                                 |      |      |      |       |      |      |      |
*                                 `--------------------'       `--------------------'
*/
[FN] = LAYOUT_ergodox(
        // left hand
        _______,        KC_F1,        KC_F2,       KC_F3,      KC_F4,       KC_F5,      KC_F6,
        _______,        _______,      _______,     _______,    _______,     _______,    _______,
        _______,        _______,      _______,     _______,    _______,     _______,
        _______,        _______,      _______,     _______,    _______,     _______,    _______,
        _______,        _______,      _______,     _______,    _______,

                                                                            _______,    _______,
        DF(BASE),
        _______,        _______,      _______,

// right hand
        KC_F7,          KC_F8,        KC_F9,        KC_F10,     KC_F11,     KC_F12,     _______,
        _______,        _______,      _______,      _______,    _______,    _______,    _______,
                        _______,      _______,      _______,    _______,    _______,    _______,
        _______,        _______,      _______,      _______,    _______,    _______,    _______,
        _______,        _______,      _______,      _______,    _______,

        _______,        _______,
        _______,
        _______,        _______,      _______
),
/* Mouse and media controls
 *
 * ,--------------------------------------------------.           ,--------------------------------------------------.
 * |   Esc  |      |      |      |      |      | Play |           | Vol+ |      |      |      |      |      |        |
 * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
 * |        |      |      | Ms U |      |      |      |           |      |      |      | Wh U |      |      |        |
 * |--------+------+------+------+------+------| Rwd  |           | Vol- |------+------+------+------+------+--------|
 * |        |      | Ms L | Ms D | Ms R |      |------|           |------|      | Wh L | Wh D | Wh R |      |        |
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 * |        |      | Acc0 | Acc1 | Acc2 |      | Fwd  |           | Mute |      | Btn1 | Btn2 | Btn3 |      |        |
 * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
 *   |      |      |      |      |      |                                       |      |      |      |      |      |
 *   `----------------------------------'                                       `----------------------------------'
 *                                        ,-------------.       ,-------------.
 *                                        |  Num | Base |       |      |      |
 *                                 ,------|------|------|       |------+------+------.
 *                                 |      |      |      |       |      |      |      |
 *                                 |      |      |------        |------|      |      |
 *                                 |      |      |      |       |      |      |      |
 *                                 `--------------------'       `--------------------'
 */
[MOUSE] = LAYOUT_ergodox(
// left hand
        KC_ESC,         XXXXXXX,    XXXXXXX,    XXXXXXX,    XXXXXXX,    XXXXXXX,    KC_MPLY,
        XXXXXXX,        XXXXXXX,    XXXXXXX,    KC_MS_U,    XXXXXXX,    XXXXXXX,    KC_MRWD,
        XXXXXXX,        XXXXXXX,    KC_MS_L,    KC_MS_D,    KC_MS_R,    XXXXXXX,
        XXXXXXX,        XXXXXXX,    KC_ACL0,    KC_ACL1,    KC_ACL2,    XXXXXXX,    KC_MFFD,
        XXXXXXX,        XXXXXXX,    XXXXXXX,    XXXXXXX,    XXXXXXX,

                                                                            DF(NUM),   DF(BASE),
                                                                                        XXXXXXX,
                                                                XXXXXXX,    XXXXXXX,    XXXXXXX,

// right hand
        KC_VOLU,        XXXXXXX,    XXXXXXX,    XXXXXXX,    XXXXXXX,    XXXXXXX,    XXXXXXX,
        KC_VOLD,        XXXXXXX,    XXXXXXX,    KC_WH_U,    XXXXXXX,    XXXXXXX,    XXXXXXX,
                        XXXXXXX,    KC_WH_L,    KC_WH_D,    KC_WH_R,    XXXXXXX,    XXXXXXX,
        KC_MUTE,        XXXXXXX,    KC_BTN1,    KC_BTN2,    KC_BTN3,    XXXXXXX,    XXXXXXX,
        XXXXXXX,        XXXXXXX,    XXXXXXX,    XXXXXXX,    XXXXXXX,

        XXXXXXX,        XXXXXXX,
        XXXXXXX,
        XXXXXXX,        XXXXXXX,    XXXXXXX
),
/* Num pad
 *
 * ,--------------------------------------------------.           ,--------------------------------------------------.
 * |        |      |      |      |      |      |      |           |      |  (   |  )   |  =   |  /   |  *   |        |
 * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
 * |        |      |      |  Up  |      |      |      |           |      |      |  7   |  8   |  9   |  -   |        |
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 * |        |      | Left | Down |Right |      |------|           |------|      |  4   |  5   |  6   |  +   |        |
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 * |        |      |      |      |      |      |      |           |      |      |  1   |  2   |  3   |Enter |        |
 * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
 *   |      |      |      |      |      |                                       |  0   |  0   |  ,   |Enter |  .   |
 *   `----------------------------------'                                       `----------------------------------'
 *                                        ,-------------.       ,-------------.
 *                                        | Base |      |       |      |      |
 *                                 ,------|------|------|       |------+------+------.
 *                                 |      |      |      |       |      |      |      |
 *                                 |      |      |------        |------|      |      |
 *                                 |      |      |      |       |      |      |      |
 *                                 `--------------------'       `--------------------'
 */
[NUM] = LAYOUT_ergodox(
// left hand
        _______,        _______,    _______,    _______,    _______,  _______,    _______,
        _______,        _______,    _______,      KC_UP,    _______,  _______,    _______,
        _______,        _______,    KC_LEFT,    KC_DOWN,    KC_RIGHT, _______,
        _______,        _______,    _______,    _______,    _______,  _______,    _______,
        _______,        _______,    _______,    _______,    _______,

        DF(BASE),   _______,
        _______,
        _______,        _______,    _______,

// right hand
        _______,        LSFT(KC_8), LSFT(KC_9), KC_PEQL,    KC_PSLS,    KC_PAST,    _______,
        _______,        _______,    KC_P7,      KC_P8,      KC_P9,      KC_PMNS,    _______,
                        _______,    KC_P4,      KC_P5,      KC_P6,      KC_PPLS,    _______,
        _______,        _______,    KC_P1,      KC_P2,      KC_P3,      KC_PENT,    _______,
                                    KC_P0,      KC_P0,      KC_PDOT,    KC_PENT,    KC_DOT,

        _______,        _______,
        _______,
        _______,        _______,    _______
),
/* IDEA
 *
 * ,--------------------------------------------------.           ,--------------------------------------------------.
 * |        |      |      |      |      |      | Renm |           | Usag |      | LnCm | BkCm |      | Term |        |
 * |--------+------+------+------+------+-------------|           |------+------+------+------+------+------+--------|
 * |        |      |      |Search|      |      |      |           |      |      | Refm |      |      |      |        |
 * |--------+------+------+------+------+------|      |           | Col  |------+------+------+------+------+--------|
 * |        |      |      |      |      |      |------|           |------|      |      |      |      |      |        |
 * |--------+------+------+------+------+------|      |           |      |------+------+------+------+------+--------|
 * |        |      | Code |      |      |      |      |           |      |      |      |      |      |      |        |
 * `--------+------+------+------+------+-------------'           `-------------+------+------+------+------+--------'
 *   |      |      |      |      |      |                                       |      |      |      |      |      |
 *   `----------------------------------'                                       `----------------------------------'
 *                                        ,-------------.       ,-------------.
 *                                        |      |      |       |      |      |
 *                                 ,------|------|------|       |------+------+------.
 *                                 |      |      |      |       |      |      |      |
 *                                 |      |      |------        |------|      |      |
 *                                 |      |      |      |       |      |      |      |
 *                                 `--------------------'       `--------------------'
 */
[IDEA] = LAYOUT_ergodox(

//Left hand
        _______,        _______,    _______,    _______,    _______,    _______,    I_RENAME,
        _______,        _______,    _______,    I_SEARCH,   _______,    _______,    _______,
        _______,        _______,    _______,    _______,    _______,    _______,
        _______,        _______,    P_CODE,     _______,    _______,    _______,    _______,
        _______,        _______,    _______,    _______,    _______,

                                                                        _______,    DF(BASE),
                                                                                    _______,
                                                        _______,        _______,    _______,

// right hand
        I_FUSAGE,       _______,    I_LN_COM,   I_BK_COM,   _______,    I_TERM,    _______,
        I_COLUMN,       _______,    I_REFORM,   _______,    _______,    _______,    _______,
                        _______,    _______,    _______,    _______,    _______,    _______,
        _______,        _______,    _______,    _______,    _______,    _______,    _______,
                                _______,        _______,    _______,    _______,    _______,

        _______,        _______,
        _______,
        _______,        _______,    _______
)
};


void led_1_off(void) {
    ergodox_right_led_1_off();
}

void led_2_off(void) {
    ergodox_right_led_2_off();
}

void led_3_off(void) {
    ergodox_right_led_3_off();
}

//Runs just one time when the keyboard initializes
void matrix_init_use(void) {
    led_1_off();
    led_2_off();
    led_3_off();
}

// Value to use to switch LEDs on. The default value of 255 is far too bright.
static const uint8_t max_led_value = 20;


void led_1_on(void) {
    ergodox_right_led_1_on();
    ergodox_right_led_1_set(max_led_value);
}

void led_2_on(void) {
    ergodox_right_led_2_on();
    ergodox_right_led_2_set(max_led_value);
}

void led_3_on(void) {
    ergodox_right_led_3_on();
    ergodox_right_led_3_set(max_led_value);
}

uint32_t layer_state_set_user(uint32_t state) {

    if(layer_state_cmp(state ,IDEA)) {
        led_1_on();
        led_3_on();
    } else {
        led_1_off();
        led_3_off();
    }

  return state;
};

void matrix_scan_user(void) {

    ergodox_board_led_off();
    led_1_off();
    led_2_off();
    led_3_off();

    if(layer_state_cmp(default_layer_state, QWERTY)) {
        led_3_on();
    }

    if(layer_state_cmp(default_layer_state, FN)) {
        led_2_on();
    }

    if(layer_state_cmp(default_layer_state, NUM)) {
        led_2_on();
        led_3_on();
    }

    if(layer_state_cmp(default_layer_state, MOUSE)) {
        led_1_on();
    }
};