~ruther/qmk_firmware

ref: 7a411014c94fe1b6e90f4981b1690341ed59aba5 qmk_firmware/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c -rw-r--r-- 13.6 KiB
7a411014 — Rutherther feat: few updates 6 months 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
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
#include QMK_KEYBOARD_H
#include "features/layer_lock.h"
#include "features/cz_accent.h"
#include "features/achordion.h"

bool process_caps_word_off(uint16_t keycode, keyrecord_t* record);

enum layers {
  _QWERTY = 0,
  _QWERTY_NOHOMEMODS,
  _PLAIN,
  _GAMES,
  _SYM,
  _NAV,
  _FUNCTION,
  _NUM,
  _WM,
  _CTRL,
  _TTY,
};

enum custom_keycodes {
  QK_LLCK = SAFE_RANGE,
  CZ_CARETED, // on hold send cz caret prepended to each symbol
  CZ_ACUTED, // on hold send cz acute prepended to each symbol
  ACHORDION_OFF,
  ACHORDION_ON,
};

#define SYM      MO(_SYM)
#define NUM      MO(_NUM)
#define NAV      MO(_NAV)
#define FKEYS    MO(_FUNCTION)
#define CTRL     MO(_CTRL)
#define WM       MO(_WM)
#define TTY      MO(_TTY)

#define GAMES    TO(_GAMES)
#define QWERTY   TO(_QWERTY)
#define NOHOMODS   TO(_QWERTY_NOHOMEMODS)

#define CTL_ESC  MT(MOD_LCTL, KC_ESC)
#define CTL_QUOT MT(MOD_LCTL, KC_QUOTE)
#define SUP_BSLS MT(MOD_LGUI, KC_BSLS)
#define SUP_TAB  MT(MOD_LGUI, KC_TAB)
#define ALT_ENT  MT(MOD_LALT, KC_ENT)
#define ALT_SPC  MT(MOD_LALT, KC_SPC)

#define OSM_LSFT OSM(MOD_LSFT)
#define OSM_RSFT OSM(MOD_RSFT)

#define NAV_V LT(_NAV, KC_V)
#define NUM_G LT(_NUM, KC_G)
#define NUM_SPC LT(_NUM, KC_SPC)
#define WM_M LT(_WM, KC_M)

#define GUI_Q MT(MOD_LGUI, KC_Q)
#define SYM_A LT(_SYM, KC_A)
#define LALT_S MT(MOD_LALT, KC_S)
#define LSFT_D MT(MOD_LSFT, KC_D)
#define LCTL_F MT(MOD_LCTL, KC_F)

#define GUI_P MT(MOD_RGUI, KC_P)
#define SYM_SCLN LT(_SYM, KC_SCLN)
#define LALT_L MT(MOD_LALT, KC_L)
#define RSFT_K MT(MOD_RSFT, KC_K)
#define LCTL_J MT(MOD_LCTL, KC_J)

#define WM_MON1 G(KC_W)
#define WM_MON2 G(KC_E)
#define WM_MON3 G(KC_R)
#define WM_WS(i) G(KC_##i)
#define WM_RUN G(KC_SCLN)
#define WM_RUN2 G(S(KC_SCLN))
#define WM_TERM G(S(KC_ENT))
#define WM_KILL G(S(KC_C))

// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  [_QWERTY] = LAYOUT(
    KC_TAB,  GUI_Q,    KC_W,     KC_E,     KC_R,      KC_T,                                                        KC_Y,     KC_U,     KC_I,     KC_O,     GUI_P,    KC_BSLS,
    KC_ESC,  SYM_A,    LALT_S,   LSFT_D,   LCTL_F,    KC_G,                                                        KC_H,     LCTL_J,   RSFT_K,   LALT_L,   SYM_SCLN, KC_QUOT,
    QK_LOCK, KC_Z,     KC_X,     KC_C,     NAV_V,     KC_B,      _______, CTRL,                FKEYS,     TTY,     KC_N,     WM_M,     KC_COMM,  KC_DOT,   KC_SLSH,  KC_APP,
                                 _______,  _______,   QK_REP,    NUM_SPC,  CZ_ACUTED,          CZ_CARETED,KC_ENT,  KC_BSPC,  _______,  _______
  ),

  [_QWERTY_NOHOMEMODS] = LAYOUT(
    SUP_TAB,  KC_Q,     KC_W,     KC_E,     KC_R,      KC_T,                                                        KC_Y,     KC_U,    KC_I,     KC_O,     KC_P,     SUP_BSLS,
    CTL_ESC,  SYM_A,    KC_S,     KC_D,     KC_F,      NUM_G,                                                       KC_H,     KC_J,    KC_K,     KC_L,     SYM_SCLN, CTL_QUOT,
    OSM_LSFT, KC_Z,     KC_X,     KC_C,     KC_V,      KC_B,     _______,    CTRL,               FKEYS,     TTY,      KC_N,     KC_M,    KC_COMM,  KC_DOT,   KC_SLSH,  OSM_RSFT,
                                  QK_LOCK,  _______,   QK_REP,   ALT_SPC,  CZ_ACUTED,          CZ_CARETED,ALT_ENT,  KC_BSPC,  KC_DEL,  KC_APP
  ),

  [_PLAIN] = LAYOUT(
    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_LCTL,  KC_A,     KC_S,     LSFT_D,   KC_F,      KC_G,                                                       KC_H,     KC_J,     RSFT_K,   KC_L,     KC_SCLN,  KC_QUOT,
    KC_LSFT,  KC_Z,     KC_X,     KC_C,     KC_V,      KC_B,    _______,    CTRL,              FKEYS,    _______,  KC_N,     KC_M,     KC_COMM,  KC_DOT,   KC_SLSH,  KC_RSFT,
                                  _______,  _______,  _______,  _______,  _______,             _______,  _______,  _______,  _______,  _______
  ),

  [_GAMES] = LAYOUT(
    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_LCTL,  KC_A,     KC_S,     KC_D,     KC_F,      KC_G,                                                       KC_H,     KC_J,     KC_K,     KC_L,     KC_SCLN,  KC_QUOT,
    KC_LSFT,  KC_Z,     KC_X,     KC_C,     KC_V,      KC_B,    KC_LALT,    CTRL,               FKEYS,    _______, KC_N,     KC_M,     KC_COMM,  KC_DOT,   KC_SLSH,  KC_RSFT,
                                  _______,  _______,   NAV,     KC_SPC,     NUM,                SYM,      KC_ENT,  _______,  _______,  KC_ESC
  ),

  [_SYM] = LAYOUT(
    _______,  _______,  KC_LABK,  KC_RABK,  KC_BSLS,  KC_GRAVE,                                                   KC_AMPR,  KC_UNDS,  KC_LBRC,  KC_RBRC,  KC_PERC,  _______,
    _______,  KC_EXLM,  KC_MINUS, KC_PLUS,  KC_EQUAL, KC_HASH,                                                    KC_PIPE,  KC_TILD,  KC_LPRN,  KC_RPRN,  KC_COLON, KC_DQUO,
    _______,  KC_COLN,  KC_SLASH, KC_ASTR,  KC_CIRC,  _______,  _______,  _______,            _______,  _______,  _______,  KC_DLR,   KC_LCBR,  KC_RCBR,  KC_AT,    _______,
                                  _______,  _______,  _______,  _______,  _______,            QK_LLCK,  _______,  KC_DEL,   _______,  _______
  ),

  [_NAV] = LAYOUT(
    _______,  KC_LGUI,  _______,  _______,  _______,  _______,                                                    KC_HOME,  KC_PGDN,  KC_PGUP,  KC_END,   KC_INS,   KC_DEL,
    _______,  KC_LCTL,  KC_LALT,  OSM_LSFT, KC_LCTL,  _______,                                                    KC_LEFT,  KC_DOWN,  KC_UP,    KC_RGHT,  _______,  _______,
    _______,  _______,  _______,  _______,  _______,  _______,  _______,  KC_SCRL,            _______,  _______,  KC_PAUSE, KC_MPRV,  KC_MPLY,  KC_MNXT,  KC_MUTE,  KC_PSCR,
                                  _______,  _______,  _______,  _______,  _______,            QK_LLCK,  _______,  _______,  _______,  _______
  ),

  [_FUNCTION] = LAYOUT(
    _______,  _______,  KC_F4,    KC_F9,    KC_F8,    KC_F10,                                                     _______,  _______,  _______,  _______,  KC_RGUI,  _______,
    _______,  _______,  KC_F3,    KC_F2,    KC_F1,    KC_F11,                                                     _______,  KC_LCTL,  OSM_RSFT, KC_LALT,  KC_RGUI,  _______,
    _______,  _______,  KC_F5,    KC_F6,    KC_F7,    KC_F12,   _______,  _______,            _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,
                                  _______,  _______,  _______,  _______,  _______,            QK_LLCK,  _______,  _______,  _______,  _______
  ),

  [_NUM] = LAYOUT(
    _______,  _______,  _______,  _______,  _______,  _______,                                                    KC_PLUS,  KC_8,     KC_9,     KC_4,     _______,  _______,
    _______,  KC_LGUI,  KC_LALT,  KC_LCTL,  OSM_LSFT, _______,                                                    KC_EQUAL, KC_1,     KC_2,     KC_3,     KC_SLASH, _______,
    _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,            _______,  _______,  KC_MINUS, KC_7,     KC_6,     KC_5,     KC_DOT,   _______,
                                  _______,  _______,  _______,  _______,  _______,            QK_LLCK,  KC_0,     _______,  _______,  _______
  ),

  /* [_NUML] = LAYOUT( */
  /*   _______, _______,   KC_4,     KC_9,     KC_8,  KC_PLUS,                                                       _______,  _______,  _______,  _______,  KC_RGUI,  _______, */
  /*   _______, KC_SLASH,  KC_3,     KC_2,     KC_1,  KC_EQUAL,                                                      _______,  KC_LCTL,  KC_RSFT,  KC_LALT,  KC_RGUI,  _______, */
  /*   _______, KC_DOT,    KC_5,     KC_6,     KC_7,  KC_MINUS,    _______,  _______,            _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______, */
  /*                                 _______,  _______,  _______,  KC_0,     QK_LLCK,            _______,  _______,  _______,  _______,  _______ */
  /* ), */

  [_WM] = LAYOUT(
    _______,  WM_MON2,  WM_WS(4), WM_WS(9), WM_WS(8), _______,                                                    _______,  _______,  WM_RUN,   WM_TERM,  _______,  _______,
    _______,  WM_MON1,  WM_WS(3), WM_WS(2), WM_WS(1), _______,                                                    _______,  KC_RCTL,  KC_RSFT,  KC_LALT,  KC_RGUI,  WM_KILL,
    _______,  WM_MON3,  WM_WS(5), WM_WS(6), WM_WS(7), _______,  _______,  _______,            _______,  _______,  _______,  _______,  _______,  _______,  _______,  WM_RUN2,
                                  _______,  _______,  _______,  _______,  QK_LLCK,            _______,  _______,  _______,  _______,  _______
  ),

  [_CTRL] = LAYOUT(
    _______,  _______,  _______,  _______,  _______,  _______,                                                    DT_UP,    _______,  _______,  _______,  _______,  ACHORDION_ON,
    _______,  _______,  _______,  _______,  _______,  _______,                                                    DT_DOWN,  _______,  _______,  _______,  _______,  ACHORDION_OFF,
    _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,            _______,  _______,  DT_PRNT,  _______,  _______,  _______,  _______,  _______,
                                  _______,  _______,  _______,  _______,  _______,            QWERTY,   NOHOMODS, GAMES,  _______,  _______
  ),

  [_TTY] = LAYOUT(
    _______,  _______,  LCA(KC_F4), LCA(KC_F9), LCA(KC_F8), LCA(KC_F10),                                                     _______,  _______,  _______,  _______,  _______,  _______,
    _______,  _______,  LCA(KC_F3), LCA(KC_F2), LCA(KC_F1), LCA(KC_F11),                                                     _______,  _______,  _______,  _______,  _______,  _______,
    _______,  _______,  LCA(KC_F5), LCA(KC_F6), LCA(KC_F7), LCA(KC_F12), _______,  _______,            _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,
                                    _______,    _______,    _______,     _______,  QK_LLCK,            _______,  _______,  _______,  _______,  _______
  ),

  /* [_TEMPLATE] = LAYOUT( */
  /*   _______,  _______,  _______,  _______,  _______,  _______,                                                    _______,  _______,  _______,  _______,  _______,  _______, */
  /*   _______,  _______,  _______,  _______,  _______,  _______,                                                    _______,  _______,  _______,  _______,  _______,  _______, */
  /*   _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,            _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______, */
  /*                                 _______,  _______,  _______,  _______,  _______,            _______,  _______,  _______,  _______,  _______ */
  /* ), */
};

void keyboard_pre_init_user(void) {
  // Set our LED pin as output
  setPinOutput(24);
  // Turn the LED off
  // (Due to technical reasons, high is off and low is on)
  writePinHigh(24);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  static bool achordion = true;
  if (!process_caps_word_off(keycode, record)) { return false; }
  if (!process_czech_acute(keycode, record, CZ_ACUTED, _PLAIN)) { return false; }
  if (!process_czech_caret(keycode, record, CZ_CARETED, _PLAIN)) { return false; }
  if (!process_layer_lock(keycode, record, QK_LLCK)) { return false; }

  // NOTE: it's important that this is under processing czech accent modes
  if (!is_in_czech_accent_mode() && achordion)
    if (!process_achordion(keycode, record)) { return false; }

  switch (keycode) {
    case ACHORDION_OFF:
      cancel_achordion();
      achordion = false;
      return false;
    case ACHORDION_ON:
      achordion = true;
      return false;
  }

  return true;
}

bool process_caps_word_off(uint16_t keycode, keyrecord_t* record)
{
  if (is_caps_word_on() && keycode == KC_ESC) {
    caps_word_off();
    return false;
  }

  return true;
}

bool achordion_chord(uint16_t tap_hold_keycode,
                      keyrecord_t* tap_hold_record,
                      uint16_t other_keycode,
                      keyrecord_t* other_record) {
  if (other_keycode == CZ_CARETED ||
      other_keycode == CZ_ACUTED ||
      tap_hold_keycode == CZ_ACUTED ||
      tap_hold_keycode == CZ_CARETED) {
    return true;
  }

  return achordion_opposite_hands(tap_hold_record, other_record);
}

void matrix_scan_user(void) {
  achordion_task();
}

bool achordion_eager_mod(uint8_t mod) {
  switch (mod) {
    case MOD_LSFT:
    case MOD_RSFT:
    case MOD_LCTL:
    case MOD_RCTL:
    case MOD_LGUI:
    case MOD_RGUI:
      return true;  // Eagerly apply Shift and Ctrl mods.

    default:
      return false;
  }
}

bool caps_word_press_user(uint16_t keycode) {
    switch (keycode) {
        // Keycodes that continue Caps Word, with shift applied.
        case KC_A ... KC_Z:
            add_weak_mods(MOD_BIT(KC_LSFT));  // Apply shift to next key.
            return true;

        // Keycodes that continue Caps Word, without shifting.
        case KC_1 ... KC_0:
        case KC_BSPC:
        case KC_DEL:
        case KC_UNDS:
        case KC_MINS:
            return true;
        default:
            return false;  // Deactivate Caps Word.
    }
}

/*
qmk-keyboard-format:json:begin
{
    "name": "Kyria",
    "numkeys": 50,
    "rows": [
        [  0,  1,  2,  3,  4,  5, -1, -1, -2, -1, -1,  6,  7,  8,  9, 10, 11 ],
        [ 12, 13, 14, 15, 16, 17, -1, -1, -2, -1, -1, 18, 19, 20, 21, 22, 23 ],
        [ 24, 25, 26, 27, 28, 29, 30, 31, -2, 32, 33, 34, 35, 36, 37, 38, 39 ],
        [ -1, -1, -1, 40, 41, 42, 43, 44, -2, 45, 46, 47, 48, 49, -1, -1, -1 ]
        ]
}
qmk-keyboard-format:json:end
*/
Do not follow this link