aboutsummaryrefslogtreecommitdiffstats
path: root/users/rs/rs.c
blob: fa634bb92842f55de6343c13b3915bc770aaa55b (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
#include "rs.h"

// process_record_user is like process_record_user for keymaps including this file.
__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  return true;
}

// rgb_mod_changed_keymap is called any time the RGB mod has been changed.
__attribute__ ((weak))
void rgb_mod_changed_keymap(void) {
}

// keylog_set_keymap is called for every key press.
__attribute__ ((weak))
void keylog_set_keymap(uint16_t keycode, keyrecord_t *record) {
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  if (record->event.pressed) {
    keylog_set_keymap(keycode, record);
  }

  switch (keycode) {
  case NEQL: // !=
    if (record->event.pressed) {
      SEND_STRING("!=");
    }
    return false;
  case LPLT: // ( or < with shift
    if (record->event.pressed) {
      if (get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) {
        // <
        tap_code(KC_COMM); // shift is already registered
      } else {
        // (
        register_mods(MOD_BIT(KC_LSFT));
        tap_code(KC_9);
        unregister_mods(MOD_BIT(KC_LSFT));
      }
    }
    return false;
  case RPGT: // ) or > with shift
    if (record->event.pressed) {
      if (get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) {
        // <
        tap_code(KC_DOT); // shift is already registered
      } else {
        // )
        register_mods(MOD_BIT(KC_LSFT));
        tap_code(KC_0);
        unregister_mods(MOD_BIT(KC_LSFT));
      }
    }
    return false;
#ifdef RGBLIGHT_ENABLE
  case RGB_MOD:
      if (record->event.pressed) {
        rgblight_step();
        rgb_mod_changed_keymap();
      }
    return false;
  case RGBRST:
      if (record->event.pressed) {
        eeconfig_update_rgblight_default();
        rgblight_enable();
        rgb_mod_changed_keymap();
      }
    return false;
#endif
  }
  return process_record_keymap(keycode, record);
}