~ruther/qmk_firmware

ref: faa7c1a1d89f58dc5540df88c2ca231add63e37b qmk_firmware/users/jjerrell/process_records.c -rw-r--r-- 4.7 KiB
faa7c1a1 — James Young 1UpKeyboards Pi60 Layout Additions (#21874) 2 years ago
                                                                                
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
/**
 * Copyright (C) 2021 Jerrell, Jacob <@jjerrell>
 * 
 * This file is part of qmk_firmware.
 * 
 * qmk_firmware 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 3 of the License, or
 * (at your option) any later version.
 * 
 * qmk_firmware 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 qmk_firmware.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "jjerrell.h"

float game_song[][2] = SONG(TO_BOLDLY_GO);
float work_song[][2] = SONG(MARIO_GAMEOVER);
float doom_song[][2] = SONG(E1M1_DOOM);

__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }

static uint16_t key_timer;

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    if (process_record_keymap(keycode, record)) {
        static uint8_t mods = 0;
        // static uint8_t layer = 0;
        mods = get_mods();
        switch (keycode) {
        case KC_QWERTY:
            if (record->event.pressed) {
                set_single_persistent_default_layer(_QWERTY);
            }
            return false;
            break;
        case KC_WORKMAN:
            if (record->event.pressed) {
                set_single_persistent_default_layer(_WORKMAN);
            }
            return false;
            break;
        case KC_CCCV:
            if (record->event.pressed) {
                key_timer = timer_read();
            } else {
                clear_mods();
                if (timer_elapsed(key_timer) > TAPPING_TERM) {  // Hold, copy
                    tap_code16(G(KC_C));
                } else if (mods & MOD_MASK_SHIFT) {  
                    // Tap w/ shift held, open [Paste App](https://pasteapp.io) (no affiliation)
                    // Shift + Command(GUI) + V                
                    tap_code16(S(G(KC_V)));
                } else { // Regular tap, do paste
                    tap_code16(G(KC_V));
                }
                set_mods(mods);
            }
            return false;
            break;
        case KC_ARROW:
            if (record->event.pressed) {
                clear_mods();
                if (mods & MOD_MASK_SHIFT) {
                    SEND_STRING("=>");
                } else {
                    SEND_STRING("->"); 
                }
                set_mods(mods);
            }
            return false;
            break;
        case KC_MAKE:
            if (!record->event.pressed) {
#ifndef MAKE_BOOTLOADER
                uint8_t temp_mod = mod_config(get_mods());
                uint8_t temp_osm = mod_config(get_oneshot_mods());
                clear_mods();
                clear_oneshot_mods();
#endif
                send_string_with_delay_P(PSTR("qmk"), TAP_CODE_DELAY);
#ifndef MAKE_BOOTLOADER
                if ((temp_mod | temp_osm) & MOD_MASK_SHIFT)
#endif
                {
                    send_string_with_delay_P(PSTR(" flash "), TAP_CODE_DELAY);
#ifndef MAKE_BOOTLOADER
                } else {
                    send_string_with_delay_P(PSTR(" compile "), TAP_CODE_DELAY);
#endif
                }
                send_string_with_delay_P(PSTR("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP), TAP_CODE_DELAY);
                send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY);
            }
            return false;
            break;
        case KC_VRSN:
            if (!record->event.pressed) {
                send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE), TAP_CODE_DELAY);
            }
            return false;
            break;
        case KC_GAME:
            if (record->event.pressed) {
                key_timer = timer_read();
            } else {
                if (IS_LAYER_OFF(_GAME)) {
                    if (timer_elapsed(key_timer) > TAPPING_TERM) {
                        layer_move(_GAME);
#ifdef AUDIO_ENABLE
PLAY_SONG(game_song);
#endif
                    }
                    break;
                    // todo: cycle game layers
                // } else if (mods & MOD_MASK_SHIFT) {
// #ifdef AUDIO_ENABLE
// PLAY_SONG(doom_song);
// #endif
//                     break;
                } else {
                    layer_move(_WORKMAN);
#ifdef AUDIO_ENABLE
PLAY_SONG(work_song);
#endif
                    break;
                }
            }
            return false;
            break;
        }
    }
    return true;
}