~ruther/qmk_firmware

ref: c80fa1c6f92fcb697aae25fd2713fec19e2e13ad qmk_firmware/keyboards/zsa/moonlander/keymaps/rutherther/features/cz_accent.c -rw-r--r-- 2.0 KiB
c80fa1c6 — Rutherther feat: split cz accented feature 9 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
#include "cz_accent.h"
#include "keymap_czech.h"

bool process_czech_acute(uint16_t keycode, keyrecord_t* record,
                         uint16_t acute_keycode, int8_t plain_layer) {
  static bool cz_send_acuted = false;

  if (keycode == acute_keycode) {
    cz_send_acuted = record->event.pressed;

    if (record->event.pressed) {
      layer_move(plain_layer);
    } else {
      layer_move(0);
    }

    return false;
  }

  // TODO: Ignore everything else except for A - Z (or even just the letters that are actually used with acute in czech)
  // 1. release shift if held, save if held to shift_held
  // 2. send acute accent char with ralt
  // 3. if shift_held, hold shift
  // 4. process original
  if (cz_send_acuted &&
      keycode != acute_keycode &&
      keycode != KC_LEFT_SHIFT &&
      keycode != KC_RIGHT_SHIFT &&
      record->event.pressed) {
    const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();

    clear_mods();
    clear_weak_mods();
    clear_oneshot_mods();

    tap_code16(RALT(CZ_ACUT));

    set_mods(mods);
  }

  return true;
}

bool process_czech_caret(uint16_t keycode, keyrecord_t* record,
                         uint16_t caret_keycode, int8_t plain_layer) {
  static bool cz_send_careted = false;

  if (keycode == caret_keycode) {
    cz_send_careted = record->event.pressed;

    if (record->event.pressed) {
      layer_move(plain_layer);
    } else {
      layer_move(0);
    }
    return false;
  }

  // TODO: Ignore everything else except for A - Z (or even just the letters that are actually used with acute in czech)
  if (cz_send_careted && keycode != caret_keycode &&
      keycode != KC_LEFT_SHIFT &&
      keycode != KC_RIGHT_SHIFT &&
      record->event.pressed) {

    const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();

    clear_mods();
    clear_weak_mods();
    clear_oneshot_mods();

    if (QK_MODS_GET_BASIC_KEYCODE(keycode) == KC_U) {
      tap_code16(LSFT(RALT(CZ_SCLN)));
    } else {
      tap_code16(LSFT(RALT(CZ_ACUT)));
    }

    set_mods(mods);
  }

  return true;
}
Do not follow this link