summaryrefslogtreecommitdiffstats
path: root/users/miketronic/process_records.c
blob: 5c60ddf10030e0fe14d7812e03b8e04e108ca7dc (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
// Copyright 2023 @miketronic -- Mike B <mxb540@gmail.com>
// SPDX-License-Identifier: GPL-2.0+

#include "miketronic.h"
#include "process_records.h"

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

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


bool process_record_user(uint16_t keycode, keyrecord_t *record) {

    switch (keycode) {
        case VERSION:
            if (!record->event.pressed) {
                send_string_with_delay_P(PSTR(QMK_KEYBOARD ":" QMK_KEYMAP "\nVersion:" QMK_VERSION ", built: " QMK_BUILDDATE "\n"), MACRO_TIMER);
            }
            break;

        case M01:
            if (record->event.pressed) {
                SEND_STRING("//a11");
            }
            break;

        case M02:
            if (record->event.pressed) {
                SEND_STRING("//a12");
            }
            break;

        case M03:
            if (record->event.pressed) {
                SEND_STRING("//a08");
            }
            break;

        case M04:
            if (record->event.pressed) {
                SEND_STRING("//a09");
            }
            break;

        case M05:
            if (record->event.pressed) {
                SEND_STRING("//th");
            }
            break;

        case M06:
            if (record->event.pressed) {
                SEND_STRING("//re");
            }
            break;

        case M07:
            if (record->event.pressed) {
                SEND_STRING("//yw");
            }
            break;

        case M08:
            if (record->event.pressed) {
                tap_random_base64();
            }
            break;

        case CCCV: // One key copy/paste
            if (record->event.pressed) {
                copy_paste_timer = timer_read();
            } else {
                if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
                    tap_code16(LCTL(KC_C));
                } else { // Tap, paste
                    tap_code16(LCTL(KC_V));
                }
            }
            break;

        case IENTER: // Tap for letter "i", slight hold for "enter"
            if (record->event.pressed) {
                copy_paste_timer = timer_read();
            } else {
                if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, enter
                    tap_code16(KC_ENT);
                } else { // Tap, "i"
                    tap_code16(KC_I);
                }
            }
            break;

        case PRN:
            if (record->event.pressed) {
                SEND_STRING("()");
                tap_code(KC_LEFT);
            }
            break;

        case BRACES:
            if (record->event.pressed) {
                uint8_t shifted = get_mods() & (MOD_MASK_SHIFT);
                    if (shifted) {
                        unregister_code(KC_LSFT);
                        unregister_code(KC_RSFT);
                        SEND_STRING("<>"SS_TAP(X_LEFT));
                    }
                    else {
                        SEND_STRING("[]"SS_TAP(X_LEFT));
                    }
            }
            break;

#if defined(RGBLIGHT_ENABLE)
        case RGB1:
            if (record->event.pressed) {
                rgblight_sethsv_noeeprom(HSV_BLUE);
            }
            break;

        case RGB2:
            if (record->event.pressed) {
                rgblight_sethsv_noeeprom(HSV_RED);
            }
            break;

        case RGB3:
            if (record->event.pressed) {
                rgblight_sethsv_noeeprom(HSV_ORANGE);
            }
            break;

        case RGB4:
            if (record->event.pressed) {
                rgblight_sethsv_noeeprom(HSV_WHITE);
            }
            break;

        case RGB5:
            if (record->event.pressed) {
                rgblight_sethsv_noeeprom(HSV_GREEN);
            }
            break;
#endif
    }
    return process_record_keymap(keycode, record) && process_record_secrets(keycode, record);
}