]> git.donarmstrong.com Git - qmk_firmware.git/blob - users/zer09/zer09.c
Remove more commented out MCUs
[qmk_firmware.git] / users / zer09 / zer09.c
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
16 static uint8_t c_lyr = 0; // current layer.
17
18 bool 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
38 void matrix_init_user(void) {
39   eeprom_read_led_dim_lvl();
40
41   matrix_init_keymap();
42 }
43
44 void 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
60 bool 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
72 void 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 }