summaryrefslogtreecommitdiff
path: root/keyboards/handwired/dactyl_manuform/5x6_5/keymaps/333fred/keymap.c
blob: 1e164081f26d9888d7df0207c93c0b9da5290d6d (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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/*
  Copyright (c) 2020 Fred Silberberg

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/

#include QMK_KEYBOARD_H
#include "333fred.h"

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

  [BASE] = LAYOUT_5x6_5(
     KC_GRV,        KC_1,        KC_2,  KC_3,  KC_4,    KC_5,                                                           KC_6,   KC_7,     KC_8,         KC_9,   KC_0,           KC_MINS,
     KC_TAB,        KC_Q,        KC_W,  KC_E,  KC_R,    KC_T,                                                           KC_Y,   KC_U,     KC_I,         KC_O,   KC_P,           KC_BSLS,
     KC_ESC,        KC_A,        KC_S,  KC_D,  KC_F,    KC_G,                                                           KC_H,   KC_J,     KC_K,         KC_L,   KC_SCLN,        KC_QUOT,
     OSM(MOD_LSFT), CTL_T(KC_Z), KC_X,  KC_C,  KC_V,    KC_B,                                                           KC_N,   KC_M,     KC_COMM,      KC_DOT, CTL_T(KC_SLSH), OSM(MOD_RSFT),
                                 KC_F4,        KC_LALT, KC_BSPC, TD(TD_SYM_VIM), KC_DEL,               KC_UP,   KC_ENT, KC_SPC, OSL(VIM),               KC_EQL,
                                                                 KC_LGUI,        TD(TD_COPY_PASTE),    KC_DOWN, OSM(MOD_RCTL)
  ),

  [SYMB] = LAYOUT_5x6_5(
     _______, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,                                          KC_F6,   KC_F7,   KC_F8,    KC_F9,  KC_F10,  KC_F11,
     _______, KC_EXLM, KC_AT,   KC_LPRN, KC_RPRN, KC_PIPE,                                        _______, KC_7,    KC_8,     KC_9,   _______, KC_F12,
     _______, KC_HASH, KC_DLR,  KC_LCBR, KC_RCBR, KC_GRV,                                         _______, KC_4,    KC_5,     KC_6,   _______, _______,
     _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD,                                        _______, KC_1,    KC_2,     KC_3,   _______, _______,
                       KC_F7,            _______, _______, _______, _______,    KC_VOLU, KC_MPRV, KC_MPLY, KC_MNXT,  KC_ENT,
                                                           _______, _______,    KC_VOLD, _______
  ),

  [VIM] = LAYOUT_5x6_5(
     _______, RESET,   _______, _______, _______, _______,                                         _______, _______, _______, _______, RESET,   _______,
     _______, _______, _______, _______, KC_LSFT, _______,                                         _______, _______, _______, _______, _______, _______,
     _______, DLEFT,   DRIGHT,  KC_LCTL, KC_LGUI, _______,                                         KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT, _______, _______,
     _______, _______, _______, _______, _______, _______,                                         _______, _______, _______, _______, _______, _______,
                       _______,          _______, _______,_______, _______,     TG(GAME), _______, _______, _______,          _______,
                                                          _______, _______,     _______,  _______
  ),

  [GAME] = LAYOUT_5x6_5(
     KC_ESC, KC_1,    KC_2,    KC_3,  KC_4,    KC_5,                                          KC_6,    KC_7,     KC_8,         KC_9,   KC_0,    KC_MINS,
     KC_T,   KC_TAB,  KC_Q,    KC_W,  KC_E,    KC_R,                                          KC_Y,    KC_U,     KC_I,         KC_O,   KC_P,    KC_BSLS,
     KC_G,   KC_LCTL, KC_A,    KC_S,  KC_D,    KC_F,                                          KC_H,    KC_J,     KC_K,         KC_L,   KC_SCLN, KC_QUOT,
     KC_B,   KC_LSFT, KC_Z,    KC_X,  KC_C,    KC_V,                                          KC_N,    KC_M,     KC_COMM,      KC_DOT, KC_SLSH, KC_RSFT,
                      KC_LOCK,        KC_LALT, KC_SPC, KC_ENT,  KC_GRV,    TG(GAME), _______, _______, _______,                KC_EQL,
                                                       KC_BSPC, KC_F5,     KC_F6,    _______
  ),
};

uint32_t quote_timer;

void keyboard_post_init_user(void) { quote_timer = 0; }

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    tap_dance_process_keycode(keycode);
    return !try_handle_macro(keycode, record);
}

static void render_logo(void) {
    static const char PROGMEM qmk_logo[] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00};

    oled_write_P(qmk_logo, false);
}

void render_led_status(void) {
    led_t led_state = host_keyboard_led_state();
    if (led_state.num_lock || led_state.caps_lock || led_state.scroll_lock) {
        oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR("    "), false);
        oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR("    "), false);
        oled_write_ln_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR("    "), false);
    }
}

void render_mods_status(void) {
    uint8_t mods = get_mods() | get_oneshot_mods();
    bool    ctrl = mods & MOD_MASK_CTRL;
    bool    shft = mods & MOD_MASK_SHIFT;
    bool    alt  = mods & MOD_MASK_ALT;
    bool    gui  = mods & MOD_MASK_GUI;

    oled_write_P(ctrl ? PSTR("CTRL ") : PSTR("     "), false);
    oled_write_P(shft ? PSTR("SHIFT ") : PSTR("      "), false);
    oled_write_P(alt ? PSTR("ALT ") : PSTR("    "), false);
    oled_write_ln_P(gui ? PSTR("GUI ") : PSTR("    "), false);
}

#define MAX_LINES 8

void write_quote(const char* data, const uint8_t num_lines) {
    uint8_t current_line = 0;
    for (; current_line < (MAX_LINES - num_lines) / 2; current_line++) {
        oled_advance_page(true);
    }

    oled_write_ln_P(data, false);

    for (current_line += num_lines; current_line < MAX_LINES; current_line++)
    {
        oled_advance_page(true);
    }
}

bool oled_task_user(void) {
    if (is_keyboard_master()) {
        render_logo();
        oled_advance_page(/* clearPageRemainder */ true);
        oled_write_P(PSTR("Layer: "), false);
        switch (get_highest_layer(layer_state)) {
            case BASE:
                oled_write_ln_P(PSTR("Base"), false);
                break;
            case SYMB:
                oled_write_ln_P(PSTR("Symbols"), false);
                break;
            case VIM:
                oled_write_ln_P(PSTR("Vim"), false);
                break;
            case GAME:
                oled_write_ln_P(PSTR("Gaming"), false);
                break;
        }

        render_mods_status();
        render_led_status();
    } else {
        if ((quote_timer != 0 && timer_elapsed32(quote_timer) < 300000 /* 5 minutes */) || !is_oled_on()) {
            return;
        }

        srand(timer_read32());
        int currentQuote = rand() % 63;
        quote_timer  = timer_read32();

        // Max character count on my screen is 20 characters per line.
        // Quotes are from various fantasy books, mostly either from
        // The Stormlight Archive or from The Wheel of Time.
        switch (currentQuote) {
            case 0:
                write_quote(PSTR("  Life before Death \n"
                                 "  Strength before   \n"
                                 "      Weakness      \n"
                                 "   Journey before   \n"
                                 "    Destination"),
                            5);
                break;
            case 1:
                write_quote(PSTR(" Honor is dead, but \n"
                                 "I'll see what I can \n"
                                 "        do."),
                            3);
                break;
            case 2:
                write_quote(PSTR(" You cannot have my \n"
                                 "       pain!"),
                            2);
                break;
            case 3:
                write_quote(PSTR(" Pride doesn't win  \n"
                                 "     battles"),
                            2);
                break;
            case 4:
                write_quote(PSTR("  I have practice   \n"
                                 " following fools in \n"
                                 "   their reckless   \n"
                                 "      pursuits."),
                            4);
                break;
            case 5:
                write_quote(PSTR("  What is the most  \n"
                                 "  important step a  \n"
                                 "    man can take?"),
                            3);
                break;
            case 6:
                write_quote(PSTR(" It's the next one. \n"
                                 "  Always the next   \n"
                                 "   step, Dalinar."),
                            3);
                break;
            case 7:
                write_quote(PSTR("    NO MATING."), 1);
                break;
            case 8:
                write_quote(PSTR("   Inappropriate?   \n"
                                 "Such as... dividing \n"
                                 "     by zero?"),
                            3);
                break;
            case 9:
                write_quote(PSTR("   I am a stick!"), 1);
                break;
            case 10:
                write_quote(PSTR("  But you could be  \n"
                                 "       fire!"),
                            1);
                break;
            case 11:
                write_quote(PSTR("    Sometimes a     \n"
                                 "   hyprocrite is    \n"
                                 " nothing more than  \n"
                                 " than a man in the  \n"
                                 "process of changing"),
                            5);
                break;
            case 12:
                write_quote(PSTR(" You surrender when \n"
                                 " you are dead. Many \n"
                                 "a man has been given\n"
                                 "       less."),
                            4);
                break;
            case 13:
                write_quote(PSTR(" Kneel and swear to \n"
                                 " the Lord Dragon,...\n"
                                 "   or you will be   \n"
                                 "      knelt."),
                            4);
                break;
            case 14:
                write_quote(PSTR("I'm right, anyway. I\n"
                                 "wish I wasn't, but I\n"
                                 "  am. I bloody am."),
                            3);
                break;
            case 15:
                write_quote(PSTR(" Death rides on my  \n"
                                 "  shoulder,. Death  \n"
                                 "    walks in my     \n"
                                 "  footsteps. I am   \n"
                                 "       death."),
                            5);
                break;
            case 16:
                write_quote(PSTR("  The Golden Crane  \n"
                                 "  flies for Tarmon  \n"
                                 "      Gai'don"),
                            3);
                break;
            case 17:
                write_quote(PSTR("You humans are very \n"
                                 "     excitable"),
                            2);
                break;
            case 18:
                write_quote(PSTR("       Phaw!"), 1);
                break;
            case 19:
                write_quote(PSTR("I may be a fool, but\n"
                                 "  I intend to be a  \n"
                                 "     live fool."),
                            3);
                break;
            case 20:
                write_quote(PSTR(" Anyone who claimed \n"
                                 "  that old age had  \n"
                                 "    brought them    \n"
                                 "patience was either \n"
                                 "  lying or senile."),
                            5);
                break;
            case 21:
                write_quote(PSTR("Death is light as a \n"
                                 "feather; duty, heavy\n"
                                 "   as a mountain"),
                            3);
                break;
            case 22:
                write_quote(PSTR("Dovie'andi se tovya \n"
                                 "      sagain."),
                            2);
                break;
            case 23:
                write_quote(PSTR(" Carai an Caldazar! \n"
                                 "Carai an Ellisande! \n"
                                 "   Al Ellisande!"),
                            3);
                break;
            case 24:
                write_quote(PSTR("    Mia dovienya    \n"
                                 "  nesodhin soende."),
                            2);
                break;
            case 25:
                write_quote(PSTR(" The Wheel of Time  \n"
                                 "turns, and Ages come\n"
                                 " and pass, leaving  \n"
                                 "memories that become\n"
                                 "      legend."),
                            5);
                break;
            case 26:
                write_quote(PSTR("  Legend fades to   \n"
                                 "myth, and even myth \n"
                                 " is long forgotten  \n"
                                 " when the Age that  \n"
                                 "gave it birth comes \n"
                                 "       again."),
                            6);
                break;
            case 27:
                write_quote(PSTR(" What is too absurd \n"
                                 "   to believe is    \n"
                                 "believed because it \n"
                                 "is too absurd to be \n"
                                 "       a lie."),
                            5);
                break;
            case 28:
                write_quote(PSTR("And you gave me the \n"
                                 "  way out! Chew on  \n"
                                 "that bitterness for \n"
                                 "lunch, you flaming, \n"
                                 "burning, misbegotten\n"
                                 "       liars!"),
                            6);
                break;
            case 29:
                write_quote(PSTR("  He was going to   \n"
                                 "start having, 'I am \n"
                                 "not a bloody Lord', \n"
                                 " embroidered on his \n"
                                 "       coats."),
                            5);
                break;
            case 30:
                write_quote(PSTR("All was not lost, of\n"
                                 "  course. All was   \n"
                                 " never lost as long \n"
                                 " as you were alive."),
                            4);
                break;
            case 31:
                write_quote(PSTR(" Everything is just \n"
                                 "    bloody fine!"),
                            2);
                break;
            case 32:
                write_quote(PSTR("The wheel weaves as \n"
                                 "  the wheel wills"),
                            2);
                break;
            case 33:
                write_quote(PSTR("  Time to toss the  \n"
                                 "        dice"),
                            2);
                break;
            case 34:
                write_quote(PSTR("Always plan for the \n"
                                 " worst, child, that \n"
                                 "    way all your    \n"
                                 "   surprises are    \n"
                                 "   pleasant ones."),
                            5);
                break;
            case 35:
                write_quote(PSTR("'Pessimism, she is a\n"
                                 "   fond friend of   \n"
                                 "yours, yes?' 'That's\n"
                                 "  uncalled for. I   \n"
                                 "  barely know her.  \n"
                                 "Mere acquaintances, \n"
                                 "     at best.'"),
                            7);
                break;
            case 36:
                write_quote(PSTR("   Do not trouble   \n"
                                 "trouble till trouble\n"
                                 "   troubles you."),
                            3);
                break;
            case 37:
                write_quote(PSTR("If your enemy offers\n"
                                 "  you two targets,  \n"
                                 " strike at a third."),
                            3);
                break;
            case 38:
                write_quote(PSTR("The wind was not the\n"
                                 "beginning. There are\n"
                                 " neither beginnings \n"
                                 " nor endings to the \n"
                                 "   turning of the   \n"
                                 " Wheel of Time. But \n"
                                 "     it was _a_     \n"
                                 "     beginning."),
                            8);
                break;
            case 39:
                write_quote(PSTR("Bloody flaming ashes"), 1);
                break;
            case 40:
                write_quote(PSTR("Then follow Lord Mat\n"
                                 " whenever he calls  \n"
                                 "To dance with Jak O'\n"
                                 "    the Shadows."),
                            4);
                break;
            case 41:
                write_quote(PSTR("    There are no    \n"
                                 " endings, and never \n"
                                 "will be endings, to \n"
                                 " the turning of the \n"
                                 " Wheel of Time. But \n"
                                 " it was an ending."),
                            6);
                break;
            case 42:
                write_quote(PSTR(" TAI'SHAR MALKIER!"), 1);
                break;
            case 43:
                write_quote(PSTR("I would not mind you\n"
                                 " in my head, if you \n"
                                 "were not so clearly \n"
                                 "        mad."),
                            4);
                break;
            case 44:
                write_quote(PSTR("  ILYENA, MY LOVE,  \n"
                                 "    FORGIVE ME!"),
                            2);
                break;
            case 45:
                write_quote(PSTR(" Oh, Light. That's  \n"
                                 "impossible! We can't\n"
                                 "  use it! Cast it   \n"
                                 "away! That is death \n"
                                 " we hold, death and \n"
                                 "betrayal. It is HIM."),
                            6);
                break;
            case 46:
                write_quote(PSTR("Nothing ever goes as\n"
                                 " you expect. Expect \n"
                                 "  nothing, and you  \n"
                                 "    will not be     \n"
                                 " surprised. Expect  \n"
                                 " nothing. Hope for  \n"
                                 " nothing. Nothing."),
                            7);
                break;
            case 47:
                write_quote(PSTR("  Distant Weeping"), 1);
                break;
            case 48:
                write_quote(PSTR("Are you real? Am I?"), 1);
                break;
            case 49:
                write_quote(PSTR("  I'm just an old   \n"
                                 "gleeman, who could I\n"
                                 "    possibly be     \n"
                                 "   dangerous to?"),
                            4);
                break;
            case 50:
                write_quote(PSTR(" Mat bloody Cauthon \n"
                                 " is no bloody hero!"),
                            2);
                break;
            case 51:
                write_quote(PSTR("You are a coward and\n"
                                 " a tyrant. I'd name \n"
                                 " you Darkfriend as  \n"
                                 "well, but I suspect \n"
                                 " that the Dark One  \n"
                                 "  would perhaps be  \n"
                                 "   embarrassed to   \n"
                                 "associate with you."),
                            8);
                break;
            case 52:
                write_quote(PSTR(" I win again, Lews  \n"
                                 "      Therin."),
                            2);
                break;
            case 53:
                write_quote(PSTR("May you always find \n"
                                 "  water and shade."),
                            2);
                break;
            case 54:
                write_quote(PSTR(" I will never serve \n"
                                 "you, Father of Lies.\n"
                                 "In a thousand lives,\n"
                                 "I never have. I know\n"
                                 " that. I'm sure of  \n"
                                 "it. Come. It is time\n"
                                 "      to die."),
                            7);
                break;
            case 55:
                write_quote(PSTR(" There may be more  \n"
                                 "than one way to skin\n"
                                 " a cat, but the cat \n"
                                 "isn't going to like \n"
                                 "    any of them."),
                            5);
                break;
            case 56:
                write_quote(PSTR("Please see that they\n"
                                 " know, although the \n"
                                 "word Black may brand\n"
                                 "my name forever, my \n"
                                 "soul is Brown. Tell \n"
                                 "      them..."),
                            6);
                break;
            case 57:
                write_quote(PSTR(" 'Your soul is of a \n"
                                 "pure white, Verin,' \n"
                                 "Egwene said softly. \n"
                                 "  'Like the Light   \n"
                                 "      itself.'"),
                            5);
                break;
            case 58:
                write_quote(PSTR("  Asha'man, Kill!"), 1);
                break;
            case 59:
                write_quote(PSTR("  Let the lord of   \n"
                                 "    chaos rule."),
                            2);
                break;
            case 60:
                write_quote(PSTR("   There's always   \n"
                                 "  another secret."),
                            2);
                break;
            case 61:
                write_quote(PSTR(" You see the great  \n"
                                 "thing about madness \n"
                                 "is that it's all in \n"
                                 "     your head."),
                            4);
                break;
            case 62:
                write_quote(PSTR(" In one Age, called \n"
                                 "  the Third Age by  \n"
                                 "some, an Age yet to \n"
                                 " come, an Age long  \n"
                                 " past, a wind rose  \n"
                                 "      above..."),
                            6);
                break;
        }
    }
    return false;
}

bool encoder_update_user(uint8_t index, bool clockwise) {
    // On the left, control the volume. On the right, scroll the page
    if (index == 0) {
        if (clockwise) {
            tap_code(KC_WH_U);
        } else {
            tap_code(KC_WH_D);
        }
    } else {
        if (clockwise) {
            tap_code(KC_VOLU);
        } else {
            tap_code(KC_VOLD);
        }
    }
    return true;
}