summaryrefslogtreecommitdiffstats
path: root/keyboards/handwired/obuwunkunubi/spaget/keymaps/default/keymap.c
blob: 482287740f5023f9f642c4635e7d920fcf215344 (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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
/* Copyright 2020 obuwunkunubi
*
* 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

// Defines for shortcut macros
#define KC_CAD LALT(LCTL(KC_DEL)) // CTRL + ALT + DEL
#define KC_CPY LCTL(KC_C) // Copy
#define KC_PST LCTL(KC_V) // Paste
#define KC_AF4 LALT(KC_F4) // ALT + F4

enum custom_keycodes {
  SELWN = SAFE_RANGE,
  SELWP,
  EM1,
  EM2,
  EM3,
  EM4,
  EM5,
  EM6,
  EM7,
  EM8,
  EM9,
  MAKE1,
  MAKE2,
  MAIL1,
  MAIL2,
  OBUWUN,
  DIR
};

enum layer_names {
  BASE,
  ONE,
  TWO
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

  /* Keymap BASE: Base Layer
  *
  *      ,---.       ,---.
  *      |NUM|       |PLY|
  *      `---'       `---'
  *      ,---------------.
  *      |CAL| UP|PRE|NXT|
  *      |---------------|
  *      | = | / | * | - |
  *      |---------------|
  *      | 7 | 8 | 9 |   |
  *      |------------ + |
  *      | 4 | 5 | 6 |   |
  *      |---------------|
  *      | 1 | 2 | 3 |   |
  *      |------------ENT|
  *      |   0   | . |   |
  *      `---------------'
  */
  [BASE] = LAYOUT(                      \
    KC_NLCK,                   KC_MPLY, \
    KC_CALC, TO(ONE), KC_MPRV, KC_MNXT, \
    KC_EQL,  KC_PSLS, KC_PAST, KC_MINS, \
    KC_P7,   KC_P8,   KC_P9,            \
    KC_P4,   KC_P5,   KC_P6,   KC_PPLS, \
    KC_P1,   KC_P2,   KC_P3,            \
             KC_P0,   KC_PDOT, KC_PENT  \
  ),

  /* Keymap ONE: Util Layer
  *
  *      ,---.       ,---.
  *      |RST|       |CAD|
  *      `---'       `---'
  *      ,---------------.
  *      |BAS|TWO|MK1|MK2|
  *      |---------------|
  *      |DIR|@1 |@2 |OBU|
  *      |---------------|
  *      |SWP|AF4|SWN|   |
  *      |------------PSC|
  *      |CPY| U |PST|   |
  *      |---------------|
  *      | L | D | R |   |
  *      |------------ NO|
  *      |  NO   | NO|   |
  *      `---------------'
  */
  [ONE] = LAYOUT(                        \
    RESET,                      KC_CAD,  \
    TO(BASE), TO(TWO), MAKE1,   MAKE2,   \
    DIR,      MAIL1,   MAIL2,   OBUWUN,  \
    SELWP,    KC_AF4,  SELWN,            \
    KC_CPY,   KC_UP,   KC_PST,  KC_PSCR, \
    KC_LEFT,  KC_DOWN, KC_RGHT,          \
              KC_P0,   KC_PDOT, KC_PENT  \
  ),

  /* Keymap TWO: Emoji Layer
  *
  *      ,---.       ,---.
  *      | NO|       | NO|
  *      `---'       `---'
  *      ,---------------.
  *      |ONE|BAS| [ | ] |
  *      |---------------|
  *      |F13|F14|F15|F16|
  *      |---------------|
  *      |EM7|EM8|EM9|   |
  *      |------------ NO|
  *      |EM4|EM5|EM6|   |
  *      |---------------|
  *      |EM1|EM2|EM3|   |
  *      |------------ NO|
  *      |  NO   | NO|   |
  *      `---------------'
  */
  [TWO] = LAYOUT(                        \
    KC_NO,                      KC_NO,   \
    TO(ONE), TO(BASE), KC_LBRC, KC_RBRC, \
    KC_F13,  KC_F14,   KC_F15,  KC_F16,  \
    EM7,     EM8,      EM9,              \
    EM4,     EM5,      EM6,     KC_NO,   \
    EM1,     EM2,      EM3,              \
             KC_NO,    KC_NO,   KC_NO    \
  ),

};


bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {

    case SELWN:  // select and copy next word
    if (record->event.pressed) {
      // when keycode SELWN is pressed

      tap_code16(C(S(KC_RGHT)));
      tap_code16(KC_CPY);
      return false; break;

    } else {
      // when keycode SELWN is released
    }
    break;

    case SELWP:   // select and copy previous word
    if (record->event.pressed) {
      // when keycode SELWP is pressed

      tap_code16(C(S(KC_LEFT)));
      tap_code16(KC_CPY);
      return false; break;

    } else {
      // when keycode SELWP is released
    }
    break;

    case MAKE1:
    if (record->event.pressed) {
      // when keycode MAKE1 is pressed

      send_string("make handwired/obuwunkunubi/spaget:default:avrdude");

    } else {
      // when keycode MAKE1 is released
    }
    break;

    case MAKE2:
    if (record->event.pressed) {
      // when keycode MAKE2 is pressed

      send_string("make preonic/rev3:obuwunkunubi:dfu-util");

    } else {
      // when keycode MAKE2 is released
    }
    break;

    case DIR:
    if (record->event.pressed) {
      // when keycode DIR is pressed

      send_string("cd /d/Keyboards/qmk/qmk_firmware/");

    } else {
      // when keycode DIR is released
    }
    break;

    case OBUWUN:
    if (record->event.pressed) {
      // when keycode OBUWUN is pressed

      send_string("obuwunkunubi");

    } else {
      // when keycode OBUWUN is released
    }
    break;

    case MAIL1:
    if (record->event.pressed) {
      // when keycode MAIL1 is pressed

      send_string("marko.bakan7");

    } else {
      // when keycode MAIL1 is released
    }
    break;

    case MAIL2:
    if (record->event.pressed) {
      // when keycode MAIL2 is pressed

      send_string("bakan.marko7");

    } else {
      // when keycode MAIL2 is released
    }
    break;

    case EM1:
    if (record->event.pressed) {
      // when keycode EM1 is pressed

      send_unicode_string("ʕ•ᴥ•ʔ");

    } else {
      // when keycode EM1 is released
    }
    break;

    case EM2:
    if (record->event.pressed) {
      // when keycode EM2 is pressed

      send_unicode_string("༼ つ ◕_◕ ༽つ");

    } else {
      // when keycode EM2 is released
    }
    break;

    case EM3:
    if (record->event.pressed) {
      // when keycode EM3 is pressed

      send_unicode_string("( ⌐■_■)");

    } else {
      // when keycode EM3 is released
    }
    break;

    case EM4:
    if (record->event.pressed) {
      // when keycode EM4 is pressed

      send_unicode_string("(╯°□°)╯彡 ┻━┻");

    } else {
      // when keycode EM4 is released
    }
    break;

    case EM5:
    if (record->event.pressed) {
      // when keycode EM5 is pressed

      send_unicode_string("ಠ_ಠ");

    } else {
      // when keycode EM5 is released
    }
    break;

    case EM6:
    if (record->event.pressed) {
      // when keycode EM6 is pressed

      send_unicode_string("( ͡° ͜ʖ ͡°)");

    } else {
      // when keycode EM6 is released
    }
    break;

    case EM7:
    if (record->event.pressed) {
      // when keycode EM7 is pressed

      send_unicode_string("(☞゚ヮ゚)☞");

    } else {
      // when keycode EM7 is released
    }
    break;

    case EM8:
    if (record->event.pressed) {
      // when keycode EM8 is pressed

      send_unicode_string("(^‿^)");

    } else {
      // when keycode EM8 is released
    }
    break;

    case EM9:
    if (record->event.pressed) {
      // when keycode EM9 is pressed

      send_unicode_string("¯\\_(ツ)_/¯");

    } else {
      // when keycode EM9 is released
    }
    break;

  }
  return true;
};

// Unicode input mode set to Windows using WinCompose
void matrix_init_user(void) {
    set_unicode_input_mode(UC_WINC);
};
#ifdef OLED_ENABLE
void oled_task_user(void) {
  oled_write_P(PSTR("       spaget v1\n\n"), false);

  // Host Keyboard Layer Status
  oled_write_P(PSTR("Layer: "), false);

  switch (get_highest_layer(layer_state)) {
    case BASE:
    oled_write_P(PSTR("Base\n"), false);
    break;
    case ONE:
    oled_write_P(PSTR("Util\n"), false);
    break;
    case TWO:
    oled_write_P(PSTR("Emoji\n"), false);
    break;
    default:
    oled_write_ln_P(PSTR("Undefined"), false);
  }

  // Host Keyboard LED Status
  led_t led_state = host_keyboard_led_state();
  oled_write_P(PSTR("Lock: "), false);
  oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR("    "), false);
  oled_write_P(led_state.caps_lock ? PSTR("CAPS ") : PSTR("     "), false);
  oled_write_P(led_state.scroll_lock ? PSTR("SCROLL ") : PSTR("       "), false);
}
#endif

bool encoder_update_user(uint8_t index, bool clockwise) {
  if(IS_LAYER_ON(BASE)) {
    if (index == 0) { /* First encoder */
      if (clockwise) {
        tap_code(KC_PGDN);
      } else {
        tap_code(KC_PGUP);
      }
    } else if (index == 1) { /* Second encoder */
      if (clockwise) {
        tap_code(KC_VOLU);
      } else {
        tap_code(KC_VOLD);
      }
    }
  }
  else if(IS_LAYER_ON(ONE)) {
    if (index == 0) { /* First encoder */
      if (clockwise) {
        tap_code(KC_WH_R);
      } else {
        tap_code(KC_WH_L);
      }
    } else if (index == 1) { /* Second encoder */
      if (clockwise) {
        tap_code(KC_WH_D);
      } else {
        tap_code(KC_WH_U);
      }
    }
  }
  else if(IS_LAYER_ON(TWO)) {
    if (index == 0) { /* First encoder */
      if (clockwise) {
        tap_code(KC_DEL);
      } else {
        tap_code(KC_BSPC);
      }
    } else if (index == 1) { /* Second encoder */
      if (clockwise) {
        tap_code(KC_DOWN);
      } else {
        tap_code(KC_UP);
      }
    }
  }
  else {
    if (index == 0) { /* First encoder */
      if (clockwise) {
        tap_code(KC_PGDN);
      } else {
        tap_code(KC_PGUP);
      }
    } else if (index == 1) { /* Second encoder */
      if (clockwise) {
        tap_code(KC_VOLU);
      } else {
        tap_code(KC_VOLD);
      }
    }
  }
    return true;
}