aboutsummaryrefslogtreecommitdiff
path: root/users/zer09/zer09.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/zer09/zer09.c')
-rw-r--r--users/zer09/zer09.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/users/zer09/zer09.c b/users/zer09/zer09.c
new file mode 100644
index 000000000..a6768f0a1
--- /dev/null
+++ b/users/zer09/zer09.c
@@ -0,0 +1,88 @@
1#include "zer09.h"
2#include "lights.h"
3#include "tap_dance.h"
4
5__attribute__((weak)) void matrix_init_keymap(void) {}
6
7__attribute__((weak)) void matrix_scan_keymap(void) {}
8
9__attribute__((weak)) bool process_record_keymap(uint16_t keycode,
10 keyrecord_t *record) {
11 return true;
12}
13
14__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}
15
16static uint8_t c_lyr = 0; // current layer.
17
18bool shifted_layer(void) {
19 static bool is_shifted = false;
20
21 if (c_lyr == _VL) {
22 if (!is_shifted) {
23 register_code(KC_LSFT);
24 is_shifted = true;
25 return true;
26 }
27 } else {
28 if (is_shifted) {
29 unregister_code(KC_LSFT);
30 is_shifted = false;
31 return true;
32 }
33 }
34
35 return false;
36}
37
38void matrix_init_user(void) {
39 eeprom_read_led_dim_lvl();
40
41 matrix_init_keymap();
42}
43
44void matrix_scan_user(void) {
45 static uint8_t is_leds_changes = 1;
46 c_lyr = biton32(layer_state);
47
48 is_leds_changes = is_leds_changes << set_layer_led(c_lyr);
49 is_leds_changes = is_leds_changes << shifted_layer();
50 is_leds_changes = is_leds_changes << rainbow_loop(c_lyr);
51
52 if (is_leds_changes > 1) {
53 rgblight_set();
54 is_leds_changes = 1;
55 }
56
57 matrix_scan_keymap();
58}
59
60bool process_record_user(uint16_t keycode, keyrecord_t *record) {
61 set_key_led(record, c_lyr);
62
63 if (led_brightness(keycode, record)) {
64 rgblight_set();
65 return false;
66 }
67
68 rgblight_set();
69 return process_record_keymap(keycode, record);
70}
71
72void led_set_user(uint8_t usb_led) {
73 if (usb_led & (1 << USB_LED_CAPS_LOCK)) {
74 rbw_led_keys[RBW_LCAP].status = ENABLED;
75 rbw_led_keys[RBW_RCAP].status = ENABLED;
76 } else {
77 rbw_led_keys[RBW_LCAP].status = DISABLED;
78 rbw_led_keys[RBW_RCAP].status = DISABLED;
79 }
80
81 if (usb_led & (1 << USB_LED_SCROLL_LOCK)) {
82 rbw_led_keys[RBW_SCRL].status = ENABLED;
83 } else {
84 rbw_led_keys[RBW_SCRL].status = DISABLED;
85 }
86
87 led_set_keymap(usb_led);
88}