diff options
| author | Ryan <fauxpark@gmail.com> | 2023-07-03 04:35:41 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-02 19:35:41 +0100 |
| commit | 9ab16e62f75dc6228549ec0aba00ec0704bbc779 (patch) | |
| tree | 1a9d2e4ea291b6d8e25bd13f6b68c5c30a709f06 | |
| parent | 7ff80a57cbe57e888646c3b90e2f4f9dea977156 (diff) | |
Get rid of `USB_LED_NUM_LOCK` (#21424)
25 files changed, 92 insertions, 134 deletions
diff --git a/keyboards/40percentclub/gherkin/keymaps/default/keymap.c b/keyboards/40percentclub/gherkin/keymaps/default/keymap.c index ab2a1fa1c1..f4d3032857 100644 --- a/keyboards/40percentclub/gherkin/keymaps/default/keymap.c +++ b/keyboards/40percentclub/gherkin/keymaps/default/keymap.c | |||
| @@ -59,16 +59,17 @@ void keyboard_pre_init_user(void) { | |||
| 59 | setPinOutput(B0); | 59 | setPinOutput(B0); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | void led_set_user(uint8_t usb_led) { | 62 | bool led_update_user(led_t led_state) { |
| 63 | if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { | 63 | if (led_state.num_lock) { |
| 64 | writePinLow(D5); | 64 | writePinLow(D5); |
| 65 | } else { | 65 | } else { |
| 66 | writePinHigh(D5); | 66 | writePinHigh(D5); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { | 69 | if (led_state.caps_lock) { |
| 70 | writePinLow(B0); | 70 | writePinLow(B0); |
| 71 | } else { | 71 | } else { |
| 72 | writePinHigh(B0); | 72 | writePinHigh(B0); |
| 73 | } | 73 | } |
| 74 | return false; | ||
| 74 | } | 75 | } |
diff --git a/keyboards/contra/keymaps/maxr1998/keymap.c b/keyboards/contra/keymaps/maxr1998/keymap.c index 8a56c60746..0802a211f0 100644 --- a/keyboards/contra/keymaps/maxr1998/keymap.c +++ b/keyboards/contra/keymaps/maxr1998/keymap.c | |||
| @@ -176,10 +176,11 @@ void update_tri_layer_user(void) { | |||
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | void led_set_user(uint8_t usb_led) { | 179 | bool led_update_user(led_t led_state) { |
| 180 | // Force-enable Numlock | 180 | // Force-enable Numlock |
| 181 | if (!(usb_led & (1<<USB_LED_NUM_LOCK))) { | 181 | if (!led_state.num_lock) { |
| 182 | register_code(KC_NUM_LOCK); | 182 | register_code(KC_NUM_LOCK); |
| 183 | unregister_code(KC_NUM_LOCK); | 183 | unregister_code(KC_NUM_LOCK); |
| 184 | } | 184 | } |
| 185 | return false; | ||
| 185 | } | 186 | } |
diff --git a/keyboards/crkbd/keymaps/rpbaptist/keymap.c b/keyboards/crkbd/keymaps/rpbaptist/keymap.c index aeeae2cbd8..0fc110b12e 100644 --- a/keyboards/crkbd/keymaps/rpbaptist/keymap.c +++ b/keyboards/crkbd/keymaps/rpbaptist/keymap.c | |||
| @@ -266,10 +266,10 @@ void render_status(void) { | |||
| 266 | 266 | ||
| 267 | oled_write_P(PSTR("\n"), false); | 267 | oled_write_P(PSTR("\n"), false); |
| 268 | 268 | ||
| 269 | uint8_t led_usb_state = host_keyboard_leds(); | 269 | led_t led_state = host_keyboard_led_state(); |
| 270 | oled_write_P(PSTR("Mode:"), false); | 270 | oled_write_P(PSTR("Mode:"), false); |
| 271 | oled_write_P(IS_LED_ON(led_usb_state, USB_LED_NUM_LOCK) ? PSTR(" NUM ") : PSTR("\n"), false); | 271 | oled_write_P(led_state.num_lock ? PSTR(" NUM ") : PSTR("\n"), false); |
| 272 | oled_write_P(IS_LED_ON(led_usb_state, USB_LED_CAPS_LOCK) ? PSTR(" CAPS") : PSTR("\n"), false); | 272 | oled_write_P(led_state.caps_lock ? PSTR(" CAPS") : PSTR("\n"), false); |
| 273 | 273 | ||
| 274 | # ifdef RGB_MATRIX_ENABLE | 274 | # ifdef RGB_MATRIX_ENABLE |
| 275 | oled_write_P(PSTR("\n"), false); | 275 | oled_write_P(PSTR("\n"), false); |
diff --git a/keyboards/dztech/dz60rgb/keymaps/matthewrobo/keymap.c b/keyboards/dztech/dz60rgb/keymaps/matthewrobo/keymap.c index 8d58eed10e..e446178b62 100644 --- a/keyboards/dztech/dz60rgb/keymaps/matthewrobo/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/matthewrobo/keymap.c | |||
| @@ -25,7 +25,6 @@ enum dz60rgb_keycodes { | |||
| 25 | #define _V_V_V_ KC_TRNS | 25 | #define _V_V_V_ KC_TRNS |
| 26 | #define LT_CAPS LT(_NAV, KC_CAPS) | 26 | #define LT_CAPS LT(_NAV, KC_CAPS) |
| 27 | #define LT_DEL LT(_RGB, KC_DEL) | 27 | #define LT_DEL LT(_RGB, KC_DEL) |
| 28 | extern bool autoshift_enabled; | ||
| 29 | #define MT_SLSH RSFT_T(KC_SLSH) | 28 | #define MT_SLSH RSFT_T(KC_SLSH) |
| 30 | #define MT_APP RALT_T(KC_APP) | 29 | #define MT_APP RALT_T(KC_APP) |
| 31 | #define LM_LALT LM(_FNM, MOD_LALT) | 30 | #define LM_LALT LM(_FNM, MOD_LALT) |
| @@ -92,12 +91,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 92 | }; | 91 | }; |
| 93 | 92 | ||
| 94 | bool rgb_matrix_indicators_user(void) { | 93 | bool rgb_matrix_indicators_user(void) { |
| 95 | uint8_t this_led = host_keyboard_leds(); | 94 | led_t led_state = host_keyboard_led_state(); |
| 96 | 95 | ||
| 97 | if (!g_suspend_state && rgb_matrix_config.enable) { | 96 | if (!g_suspend_state && rgb_matrix_config.enable) { |
| 98 | switch (get_highest_layer(layer_state)) { | 97 | switch (get_highest_layer(layer_state)) { |
| 99 | case _NAV: | 98 | case _NAV: |
| 100 | if (this_led & (1 << USB_LED_NUM_LOCK)) { | 99 | if (led_state.num_lock) { |
| 101 | rgb_matrix_set_color(13, 0xFF, 0x00, 0x00); | 100 | rgb_matrix_set_color(13, 0xFF, 0x00, 0x00); |
| 102 | rgb_matrix_set_color(19, 0xFF, 0xFF, 0x00); | 101 | rgb_matrix_set_color(19, 0xFF, 0xFF, 0x00); |
| 103 | } else { | 102 | } else { |
| @@ -204,17 +203,11 @@ bool rgb_matrix_indicators_user(void) { | |||
| 204 | rgb_matrix_set_color(41, 0xFF, 0x00, 0x40); // ctrl+delete | 203 | rgb_matrix_set_color(41, 0xFF, 0x00, 0x40); // ctrl+delete |
| 205 | rgb_matrix_set_color(43, 0xFF, 0x00, 0x40); // ctrl+slash | 204 | rgb_matrix_set_color(43, 0xFF, 0x00, 0x40); // ctrl+slash |
| 206 | 205 | ||
| 207 | if (this_led & (1 << !autoshift_enabled)) { | ||
| 208 | rgb_matrix_set_color(0, 0xFF, 0x00, 0x00); // AS_TOGG | ||
| 209 | } else { | ||
| 210 | rgb_matrix_set_color(0, 0xFF, 0xFF, 0x00); | ||
| 211 | } | ||
| 212 | |||
| 213 | break; | 206 | break; |
| 214 | } | 207 | } |
| 215 | } | 208 | } |
| 216 | 209 | ||
| 217 | if (this_led & (1 << USB_LED_CAPS_LOCK)) { | 210 | if (led_state.caps_lock) { |
| 218 | rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF); | 211 | rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF); |
| 219 | } | 212 | } |
| 220 | return false; | 213 | return false; |
diff --git a/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c b/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c index 4dca4d2396..52b7643850 100644 --- a/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c +++ b/keyboards/dztech/dz60rgb/keymaps/mekanist/keymap.c | |||
| @@ -58,7 +58,7 @@ void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue) { | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | bool rgb_matrix_indicators_user(void) { | 60 | bool rgb_matrix_indicators_user(void) { |
| 61 | uint8_t this_led = host_keyboard_leds(); | 61 | led_t led_state = host_keyboard_led_state(); |
| 62 | 62 | ||
| 63 | if (!g_suspend_state && rgb_matrix_config.enable) { | 63 | if (!g_suspend_state && rgb_matrix_config.enable) { |
| 64 | switch (get_highest_layer(layer_state)) { | 64 | switch (get_highest_layer(layer_state)) { |
| @@ -73,13 +73,13 @@ bool rgb_matrix_indicators_user(void) { | |||
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | if (this_led & (1 << USB_LED_CAPS_LOCK)) { | 76 | if (led_state.caps_lock) { |
| 77 | rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF); | 77 | rgb_matrix_set_color(40, 0xFF, 0xFF, 0xFF); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | switch (get_highest_layer(layer_state)) { | 80 | switch (get_highest_layer(layer_state)) { |
| 81 | case _LAYER3: | 81 | case _LAYER3: |
| 82 | if (this_led & (1 << USB_LED_NUM_LOCK)) { | 82 | if (led_state.num_lock) { |
| 83 | rgb_matrix_set_color(13, 0xFF, 0x00, 0x00); | 83 | rgb_matrix_set_color(13, 0xFF, 0x00, 0x00); |
| 84 | } else { | 84 | } else { |
| 85 | rgb_matrix_set_color(13, 0x00, 0x00, 0x00); | 85 | rgb_matrix_set_color(13, 0x00, 0x00, 0x00); |
| @@ -152,22 +152,3 @@ bool rgb_matrix_indicators_user(void) { | |||
| 152 | } | 152 | } |
| 153 | return false; | 153 | return false; |
| 154 | } | 154 | } |
| 155 | |||
| 156 | |||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | void matrix_init_user(void) | ||
| 161 | { | ||
| 162 | //user initialization | ||
| 163 | } | ||
| 164 | |||
| 165 | void matrix_scan_user(void) | ||
| 166 | { | ||
| 167 | //user matrix | ||
| 168 | } | ||
| 169 | |||
| 170 | bool process_record_user(uint16_t keycode, keyrecord_t* record) | ||
| 171 | { | ||
| 172 | return true; | ||
| 173 | } | ||
diff --git a/keyboards/dztech/dz65rgb/keymaps/matthewrobo/keymap.c b/keyboards/dztech/dz65rgb/keymaps/matthewrobo/keymap.c index d283d0ba1e..7936aaff75 100644 --- a/keyboards/dztech/dz65rgb/keymaps/matthewrobo/keymap.c +++ b/keyboards/dztech/dz65rgb/keymaps/matthewrobo/keymap.c | |||
| @@ -25,7 +25,6 @@ enum dz65rgb_keycodes { | |||
| 25 | #define TG_NKRO MAGIC_TOGGLE_NKRO | 25 | #define TG_NKRO MAGIC_TOGGLE_NKRO |
| 26 | #define _V_V_V_ KC_TRNS | 26 | #define _V_V_V_ KC_TRNS |
| 27 | #define LT_CAPS LT(_NAV, KC_CAPS) | 27 | #define LT_CAPS LT(_NAV, KC_CAPS) |
| 28 | extern bool autoshift_enabled; | ||
| 29 | #define MT_APP RALT_T(KC_APP) | 28 | #define MT_APP RALT_T(KC_APP) |
| 30 | #define LM_LALT LM(_FNM, MOD_LALT) | 29 | #define LM_LALT LM(_FNM, MOD_LALT) |
| 31 | 30 | ||
| @@ -87,12 +86,12 @@ bool rgb_matrix_indicators_user(void) { | |||
| 87 | rgb_matrix_set_color(8, 0xFF, 0xFF, 0xFF); | 86 | rgb_matrix_set_color(8, 0xFF, 0xFF, 0xFF); |
| 88 | } | 87 | } |
| 89 | 88 | ||
| 90 | uint8_t this_led = host_keyboard_leds(); | 89 | led_t led_state = host_keyboard_led_state(); |
| 91 | 90 | ||
| 92 | if (!g_suspend_state && rgb_matrix_config.enable) { | 91 | if (!g_suspend_state && rgb_matrix_config.enable) { |
| 93 | switch (get_highest_layer(layer_state)) { | 92 | switch (get_highest_layer(layer_state)) { |
| 94 | case _NAV: | 93 | case _NAV: |
| 95 | if (IS_LED_ON(this_led, USB_LED_NUM_LOCK)) { | 94 | if (led_state.num_lock) { |
| 96 | rgb_matrix_set_color(17, 0xFF, 0x00, 0x00); | 95 | rgb_matrix_set_color(17, 0xFF, 0x00, 0x00); |
| 97 | rgb_matrix_set_color(26, 0xFF, 0xFF, 0x00); | 96 | rgb_matrix_set_color(26, 0xFF, 0xFF, 0x00); |
| 98 | } else { | 97 | } else { |
| @@ -171,12 +170,6 @@ bool rgb_matrix_indicators_user(void) { | |||
| 171 | rgb_matrix_set_color(24, 0xFF, 0x40, 0x00); // KC_MPRV | 170 | rgb_matrix_set_color(24, 0xFF, 0x40, 0x00); // KC_MPRV |
| 172 | rgb_matrix_set_color(25, 0xFF, 0x40, 0x00); | 171 | rgb_matrix_set_color(25, 0xFF, 0x40, 0x00); |
| 173 | 172 | ||
| 174 | if (this_led & (1 << !autoshift_enabled)) { | ||
| 175 | rgb_matrix_set_color(15, 0xFF, 0x00, 0x00); // AS_TOGG | ||
| 176 | } else { | ||
| 177 | rgb_matrix_set_color(15, 0xFF, 0xFF, 0x00); | ||
| 178 | } | ||
| 179 | |||
| 180 | rgb_matrix_set_color(6, 0xFF, 0x80, 0x00); //RGB_MOD | 173 | rgb_matrix_set_color(6, 0xFF, 0x80, 0x00); //RGB_MOD |
| 181 | rgb_matrix_set_color(48, 0xFF, 0x80, 0x00); | 174 | rgb_matrix_set_color(48, 0xFF, 0x80, 0x00); |
| 182 | rgb_matrix_set_color(29, 0xFF, 0x80, 0x00); //RGB_MOD | 175 | rgb_matrix_set_color(29, 0xFF, 0x80, 0x00); //RGB_MOD |
diff --git a/keyboards/handwired/arrow_pad/keymaps/default/keymap.c b/keyboards/handwired/arrow_pad/keymaps/default/keymap.c index cecaefe80d..820851f803 100644 --- a/keyboards/handwired/arrow_pad/keymaps/default/keymap.c +++ b/keyboards/handwired/arrow_pad/keymaps/default/keymap.c | |||
| @@ -96,9 +96,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) { | |||
| 96 | return true; | 96 | return true; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | void led_set_user(uint8_t usb_led) | 99 | bool led_update_user(led_t led_state) |
| 100 | { | 100 | { |
| 101 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | 101 | if (led_state.caps_lock) { |
| 102 | // output high | 102 | // output high |
| 103 | DDRD |= (1<<6); | 103 | DDRD |= (1<<6); |
| 104 | PORTD |= (1<<6); | 104 | PORTD |= (1<<6); |
| @@ -107,7 +107,7 @@ void led_set_user(uint8_t usb_led) | |||
| 107 | DDRD &= ~(1<<6); | 107 | DDRD &= ~(1<<6); |
| 108 | PORTD &= ~(1<<6); | 108 | PORTD &= ~(1<<6); |
| 109 | } | 109 | } |
| 110 | if (usb_led & (1<<USB_LED_NUM_LOCK)) { | 110 | if (led_state.num_lock) { |
| 111 | // output low | 111 | // output low |
| 112 | DDRC |= (1<<7); | 112 | DDRC |= (1<<7); |
| 113 | PORTC |= ~(1<<7); | 113 | PORTC |= ~(1<<7); |
| @@ -116,4 +116,5 @@ void led_set_user(uint8_t usb_led) | |||
| 116 | DDRC &= ~(1<<7); | 116 | DDRC &= ~(1<<7); |
| 117 | PORTC &= ~(1<<7); | 117 | PORTC &= ~(1<<7); |
| 118 | } | 118 | } |
| 119 | return false; | ||
| 119 | } | 120 | } |
diff --git a/keyboards/handwired/arrow_pad/keymaps/pad_21/keymap.c b/keyboards/handwired/arrow_pad/keymaps/pad_21/keymap.c index cf291c00cf..c3ab462ce3 100644 --- a/keyboards/handwired/arrow_pad/keymaps/pad_21/keymap.c +++ b/keyboards/handwired/arrow_pad/keymaps/pad_21/keymap.c | |||
| @@ -109,9 +109,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) { | |||
| 109 | return true; | 109 | return true; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | void led_set_user(uint8_t usb_led) | 112 | bool led_update_user(led_t led_state) |
| 113 | { | 113 | { |
| 114 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | 114 | if (led_state.caps_lock) { |
| 115 | // output high | 115 | // output high |
| 116 | DDRD |= (1<<6); | 116 | DDRD |= (1<<6); |
| 117 | PORTD |= (1<<6); | 117 | PORTD |= (1<<6); |
| @@ -120,7 +120,7 @@ void led_set_user(uint8_t usb_led) | |||
| 120 | DDRD &= ~(1<<6); | 120 | DDRD &= ~(1<<6); |
| 121 | PORTD &= ~(1<<6); | 121 | PORTD &= ~(1<<6); |
| 122 | } | 122 | } |
| 123 | if (usb_led & (1<<USB_LED_NUM_LOCK)) { | 123 | if (led_state.num_lock) { |
| 124 | // output low | 124 | // output low |
| 125 | DDRC |= (1<<7); | 125 | DDRC |= (1<<7); |
| 126 | PORTC |= ~(1<<7); | 126 | PORTC |= ~(1<<7); |
| @@ -129,4 +129,5 @@ void led_set_user(uint8_t usb_led) | |||
| 129 | DDRC &= ~(1<<7); | 129 | DDRC &= ~(1<<7); |
| 130 | PORTC &= ~(1<<7); | 130 | PORTC &= ~(1<<7); |
| 131 | } | 131 | } |
| 132 | return false; | ||
| 132 | } | 133 | } |
diff --git a/keyboards/handwired/arrow_pad/keymaps/pad_24/keymap.c b/keyboards/handwired/arrow_pad/keymaps/pad_24/keymap.c index b69d49b7e5..fc044a0e1a 100644 --- a/keyboards/handwired/arrow_pad/keymaps/pad_24/keymap.c +++ b/keyboards/handwired/arrow_pad/keymaps/pad_24/keymap.c | |||
| @@ -96,9 +96,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t * record) { | |||
| 96 | return true; | 96 | return true; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | void led_set_user(uint8_t usb_led) | 99 | bool led_update_user(led_t led_state) |
| 100 | { | 100 | { |
| 101 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | 101 | if (led_state.caps_lock) { |
| 102 | // output high | 102 | // output high |
| 103 | DDRD |= (1<<6); | 103 | DDRD |= (1<<6); |
| 104 | PORTD |= (1<<6); | 104 | PORTD |= (1<<6); |
| @@ -107,7 +107,7 @@ void led_set_user(uint8_t usb_led) | |||
| 107 | DDRD &= ~(1<<6); | 107 | DDRD &= ~(1<<6); |
| 108 | PORTD &= ~(1<<6); | 108 | PORTD &= ~(1<<6); |
| 109 | } | 109 | } |
| 110 | if (usb_led & (1<<USB_LED_NUM_LOCK)) { | 110 | if (led_state.num_lock) { |
| 111 | // output low | 111 | // output low |
| 112 | DDRC |= (1<<7); | 112 | DDRC |= (1<<7); |
| 113 | PORTC |= ~(1<<7); | 113 | PORTC |= ~(1<<7); |
| @@ -116,4 +116,5 @@ void led_set_user(uint8_t usb_led) | |||
| 116 | DDRC &= ~(1<<7); | 116 | DDRC &= ~(1<<7); |
| 117 | PORTC &= ~(1<<7); | 117 | PORTC &= ~(1<<7); |
| 118 | } | 118 | } |
| 119 | return false; | ||
| 119 | } | 120 | } |
diff --git a/keyboards/input_club/infinity60/led.c b/keyboards/input_club/infinity60/led.c index 8effcea81a..33871bcc49 100644 --- a/keyboards/input_club/infinity60/led.c +++ b/keyboards/input_club/infinity60/led.c | |||
| @@ -26,29 +26,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | * both regular threads and ISRs, unlocked (during resume-from-sleep). | 26 | * both regular threads and ISRs, unlocked (during resume-from-sleep). |
| 27 | * In particular, I2C functions (interrupt-driven) should NOT be called from here. | 27 | * In particular, I2C functions (interrupt-driven) should NOT be called from here. |
| 28 | */ | 28 | */ |
| 29 | void led_set(uint8_t usb_led) { | 29 | bool led_update_kb(led_t led_state) { |
| 30 | msg_t msg; | 30 | bool res = led_update_user(led_state); |
| 31 | 31 | if (res) { | |
| 32 | if (usb_led & (1<<USB_LED_NUM_LOCK)) { | 32 | msg_t msg; |
| 33 | chSysUnconditionalLock(); | 33 | |
| 34 | msg=(1 << 8) | TOGGLE_NUM_LOCK; | 34 | if (led_state.num_lock) { |
| 35 | chMBPostI(&led_mailbox, msg); | 35 | chSysUnconditionalLock(); |
| 36 | chSysUnconditionalUnlock(); | 36 | msg=(1 << 8) | TOGGLE_NUM_LOCK; |
| 37 | } else { | 37 | chMBPostI(&led_mailbox, msg); |
| 38 | chSysUnconditionalLock(); | 38 | chSysUnconditionalUnlock(); |
| 39 | msg=(0 << 8) | TOGGLE_NUM_LOCK; | 39 | } else { |
| 40 | chMBPostI(&led_mailbox, msg); | 40 | chSysUnconditionalLock(); |
| 41 | chSysUnconditionalUnlock(); | 41 | msg=(0 << 8) | TOGGLE_NUM_LOCK; |
| 42 | } | 42 | chMBPostI(&led_mailbox, msg); |
| 43 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | 43 | chSysUnconditionalUnlock(); |
| 44 | chSysUnconditionalLock(); | 44 | } |
| 45 | msg=(1 << 8) | TOGGLE_CAPS_LOCK; | 45 | if (led_state.caps_lock) { |
| 46 | chMBPostI(&led_mailbox, msg); | 46 | chSysUnconditionalLock(); |
| 47 | chSysUnconditionalUnlock(); | 47 | msg=(1 << 8) | TOGGLE_CAPS_LOCK; |
| 48 | } else { | 48 | chMBPostI(&led_mailbox, msg); |
| 49 | chSysUnconditionalLock(); | 49 | chSysUnconditionalUnlock(); |
| 50 | msg=(0 << 8) | TOGGLE_CAPS_LOCK; | 50 | } else { |
| 51 | chMBPostI(&led_mailbox, msg); | 51 | chSysUnconditionalLock(); |
| 52 | chSysUnconditionalUnlock(); | 52 | msg=(0 << 8) | TOGGLE_CAPS_LOCK; |
| 53 | chMBPostI(&led_mailbox, msg); | ||
| 54 | chSysUnconditionalUnlock(); | ||
| 55 | } | ||
| 53 | } | 56 | } |
| 57 | return false; | ||
| 54 | } | 58 | } |
diff --git a/keyboards/input_club/infinity60/led_controller.c b/keyboards/input_club/infinity60/led_controller.c index cf3edf20dd..5ea0ae804c 100644 --- a/keyboards/input_club/infinity60/led_controller.c +++ b/keyboards/input_club/infinity60/led_controller.c | |||
| @@ -187,8 +187,9 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 187 | // initialize persistent variables | 187 | // initialize persistent variables |
| 188 | pwm_step_status = 4; //full brightness | 188 | pwm_step_status = 4; //full brightness |
| 189 | page_status = 0; //start frame 0 (all off/on) | 189 | page_status = 0; //start frame 0 (all off/on) |
| 190 | numlock_status = (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? 1 : 0; | 190 | led_t led_state = host_keyboard_led_state(); |
| 191 | capslock_status = (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? 1 : 0; | 191 | numlock_status = led_state.num_lock ? 1 : 0; |
| 192 | capslock_status = led_state.caps_lock ? 1 : 0; | ||
| 192 | 193 | ||
| 193 | while(true) { | 194 | while(true) { |
| 194 | // wait for a message (asynchronous) | 195 | // wait for a message (asynchronous) |
diff --git a/keyboards/kbdfans/niu_mini/keymaps/tobias/keymap.c b/keyboards/kbdfans/niu_mini/keymaps/tobias/keymap.c index 4224672152..8c7d3b8e0e 100644 --- a/keyboards/kbdfans/niu_mini/keymaps/tobias/keymap.c +++ b/keyboards/kbdfans/niu_mini/keymaps/tobias/keymap.c | |||
| @@ -377,13 +377,7 @@ layer_state_t layer_state_set_user(layer_state_t state) { | |||
| 377 | */ | 377 | */ |
| 378 | 378 | ||
| 379 | 379 | ||
| 380 | void led_set_user(uint8_t usb_led) { | 380 | bool led_update_user(led_t led_state) { |
| 381 | 381 | bnumlock = led_state.num_lock; | |
| 382 | if (usb_led & (1 << USB_LED_NUM_LOCK)) { | 382 | return false; |
| 383 | bnumlock = true; | ||
| 384 | |||
| 385 | } else { | ||
| 386 | bnumlock = false; | ||
| 387 | } | ||
| 388 | |||
| 389 | } | 383 | } |
diff --git a/keyboards/kprepublic/jj40/keymaps/stevexyz/keymap.c b/keyboards/kprepublic/jj40/keymaps/stevexyz/keymap.c index 51691e8f1f..6c8220a702 100644 --- a/keyboards/kprepublic/jj40/keymaps/stevexyz/keymap.c +++ b/keyboards/kprepublic/jj40/keymaps/stevexyz/keymap.c | |||
| @@ -262,14 +262,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 262 | void matrix_init_user(void) { | 262 | void matrix_init_user(void) { |
| 263 | // eeconfig_init(); // reset keyboard to a standard default state; useful when new releases messup with eeprom values | 263 | // eeconfig_init(); // reset keyboard to a standard default state; useful when new releases messup with eeprom values |
| 264 | // set num lock on at start (for numonly layer to work) | 264 | // set num lock on at start (for numonly layer to work) |
| 265 | if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) { | 265 | if (!host_keyboard_led_state().num_lock) { |
| 266 | SEND_STRING(SS_TAP(X_NUM_LOCK)); //register_code(KC_NUM_LOCK); unregister_code(KC_NUM_LOCK); | 266 | SEND_STRING(SS_TAP(X_NUM_LOCK)); //register_code(KC_NUM_LOCK); unregister_code(KC_NUM_LOCK); |
| 267 | } | 267 | } |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | void matrix_scan_user(void) { | ||
| 271 | } | ||
| 272 | |||
| 273 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 270 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 274 | switch (keycode) { | 271 | switch (keycode) { |
| 275 | case CK_TRIPLEZERO: | 272 | case CK_TRIPLEZERO: |
diff --git a/keyboards/massdrop/alt/keymaps/jdelkins_ss/keymap.c b/keyboards/massdrop/alt/keymaps/jdelkins_ss/keymap.c index 51772f1fa3..c974fb9e2b 100644 --- a/keyboards/massdrop/alt/keymaps/jdelkins_ss/keymap.c +++ b/keyboards/massdrop/alt/keymaps/jdelkins_ss/keymap.c | |||
| @@ -26,7 +26,6 @@ uint16_t rgb_idle_seconds = 0; | |||
| 26 | uint16_t rgb_timer; | 26 | uint16_t rgb_timer; |
| 27 | uint8_t save_layer; | 27 | uint8_t save_layer; |
| 28 | 28 | ||
| 29 | #define NUMLOCK_ON (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) | ||
| 30 | #define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT) | 29 | #define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT) |
| 31 | #define MODS_CTRL (get_mods() & MOD_MASK_CTRL) | 30 | #define MODS_CTRL (get_mods() & MOD_MASK_CTRL) |
| 32 | 31 | ||
| @@ -143,7 +142,7 @@ static void set_rgb_layer(int layer) { | |||
| 143 | void matrix_init_keymap(void) { | 142 | void matrix_init_keymap(void) { |
| 144 | set_rgb_layer(_QWERTY); | 143 | set_rgb_layer(_QWERTY); |
| 145 | // force numlock on upon startup | 144 | // force numlock on upon startup |
| 146 | if (!NUMLOCK_ON) { | 145 | if (!host_keyboard_led_state().num_lock) { |
| 147 | tap_code(KC_NUM_LOCK); | 146 | tap_code(KC_NUM_LOCK); |
| 148 | } | 147 | } |
| 149 | }; | 148 | }; |
diff --git a/keyboards/mt/mt980/keymaps/walker/keymap.c b/keyboards/mt/mt980/keymaps/walker/keymap.c index e98a1d71de..f0817dd33d 100644 --- a/keyboards/mt/mt980/keymaps/walker/keymap.c +++ b/keyboards/mt/mt980/keymaps/walker/keymap.c | |||
| @@ -89,8 +89,8 @@ tap_dance_action_t tap_dance_actions[] = { | |||
| 89 | [ALT_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,alt_finished, alt_reset) | 89 | [ALT_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,alt_finished, alt_reset) |
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| 92 | void led_set_keymap(uint8_t usb_led) { | 92 | bool led_update_keymap(led_t led_state) { |
| 93 | if (usb_led & (1<<USB_LED_NUM_LOCK)) { | 93 | if (led_state.num_lock) { |
| 94 | numlock_on = true; | 94 | numlock_on = true; |
| 95 | } | 95 | } |
| 96 | else { | 96 | else { |
diff --git a/keyboards/novelkeys/novelpad/keymaps/0xdec/keymap.c b/keyboards/novelkeys/novelpad/keymaps/0xdec/keymap.c index 5380de9648..79a3e2fdbf 100755 --- a/keyboards/novelkeys/novelpad/keymaps/0xdec/keymap.c +++ b/keyboards/novelkeys/novelpad/keymaps/0xdec/keymap.c | |||
| @@ -36,11 +36,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 36 | 36 | ||
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | void led_set_user(uint8_t usb_led) { | 39 | bool led_update_user(led_t led_state) { |
| 40 | if (usb_led & (1 << USB_LED_NUM_LOCK)) { | 40 | if (led_state.num_lock) { |
| 41 | // Illuminate the LED under the Num Lock key | 41 | // Illuminate the LED under the Num Lock key |
| 42 | rgblight_sethsv_at(0, 0, 127, 1); | 42 | rgblight_sethsv_at(0, 0, 127, 1); |
| 43 | } else { | 43 | } else { |
| 44 | rgblight_sethsv_at(0, 0, 0, 1); | 44 | rgblight_sethsv_at(0, 0, 0, 1); |
| 45 | } | 45 | } |
| 46 | return false; | ||
| 46 | } | 47 | } |
diff --git a/keyboards/salicylic_acid3/setta21/keymaps/salicylic/keymap.c b/keyboards/salicylic_acid3/setta21/keymaps/salicylic/keymap.c index e117d26eee..b7cde4d4e0 100644 --- a/keyboards/salicylic_acid3/setta21/keymaps/salicylic/keymap.c +++ b/keyboards/salicylic_acid3/setta21/keymaps/salicylic/keymap.c | |||
| @@ -173,8 +173,8 @@ void render_layer_state(void) { | |||
| 173 | oled_write_P(PSTR(" Macro "), layer_state_is(_MACRO)); | 173 | oled_write_P(PSTR(" Macro "), layer_state_is(_MACRO)); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | void render_keylock_status(uint8_t led_usb_state) { | 176 | void render_keylock_status(led_t led_state) { |
| 177 | oled_write_P(PSTR("NumLock"), led_usb_state & (1 << USB_LED_NUM_LOCK)); | 177 | oled_write_P(PSTR("NumLock"), led_state.num_lock); |
| 178 | oled_write_P(PSTR(" "), false); | 178 | oled_write_P(PSTR(" "), false); |
| 179 | } | 179 | } |
| 180 | 180 | ||
| @@ -186,7 +186,7 @@ void render_layer_messages(void) { | |||
| 186 | void render_status(void) { | 186 | void render_status(void) { |
| 187 | /* Show Keyboard Layout */ | 187 | /* Show Keyboard Layout */ |
| 188 | render_layer_messages(); | 188 | render_layer_messages(); |
| 189 | render_keylock_status(host_keyboard_leds()); | 189 | render_keylock_status(host_keyboard_led_state()); |
| 190 | render_layer_state(); | 190 | render_layer_state(); |
| 191 | } | 191 | } |
| 192 | 192 | ||
diff --git a/keyboards/westfoxtrot/cypher/rev1/keymaps/kwer/keymap.c b/keyboards/westfoxtrot/cypher/rev1/keymaps/kwer/keymap.c index eed5e664a8..9763abe369 100644 --- a/keyboards/westfoxtrot/cypher/rev1/keymaps/kwer/keymap.c +++ b/keyboards/westfoxtrot/cypher/rev1/keymaps/kwer/keymap.c | |||
| @@ -51,23 +51,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 51 | ), | 51 | ), |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | 54 | bool led_update_user(led_t led_state) { | |
| 55 | |||
| 56 | void matrix_init_user(void) { | ||
| 57 | //user initialization | ||
| 58 | } | ||
| 59 | |||
| 60 | void matrix_scan_user(void) { | ||
| 61 | //user matrix | ||
| 62 | } | ||
| 63 | |||
| 64 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 65 | return true; | ||
| 66 | } | ||
| 67 | |||
| 68 | void led_set_user(uint8_t usb_led) { | ||
| 69 | // Insert custom handling for CAPS_LOCK, NUM_LOCK, SCROLL_LOCK here | 55 | // Insert custom handling for CAPS_LOCK, NUM_LOCK, SCROLL_LOCK here |
| 70 | if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { | 56 | if (led_state.num_lock) { |
| 71 | writePinHigh(F4); | 57 | writePinHigh(F4); |
| 72 | writePinHigh(F1); | 58 | writePinHigh(F1); |
| 73 | writePinHigh(F5); | 59 | writePinHigh(F5); |
| @@ -76,4 +62,5 @@ void led_set_user(uint8_t usb_led) { | |||
| 76 | writePinLow(F1); | 62 | writePinLow(F1); |
| 77 | writePinLow(F5); | 63 | writePinLow(F5); |
| 78 | } | 64 | } |
| 65 | return false; | ||
| 79 | } | 66 | } |
diff --git a/keyboards/xiudi/xd75/keymaps/billypython/keymap.c b/keyboards/xiudi/xd75/keymaps/billypython/keymap.c index 30b9f79606..d8301194f8 100644 --- a/keyboards/xiudi/xd75/keymaps/billypython/keymap.c +++ b/keyboards/xiudi/xd75/keymaps/billypython/keymap.c | |||
| @@ -41,7 +41,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 41 | case NUMPAD: | 41 | case NUMPAD: |
| 42 | if (record->event.pressed) { | 42 | if (record->event.pressed) { |
| 43 | layer_invert(L_NUMPAD); | 43 | layer_invert(L_NUMPAD); |
| 44 | bool num_lock = host_keyboard_leds() & 1<<USB_LED_NUM_LOCK; | 44 | bool num_lock = host_keyboard_led_state().num_lock; |
| 45 | if (num_lock != (bool)IS_LAYER_ON(L_NUMPAD)) { | 45 | if (num_lock != (bool)IS_LAYER_ON(L_NUMPAD)) { |
| 46 | tap_code(KC_NUM_LOCK); // Toggle Num Lock to match layer state. | 46 | tap_code(KC_NUM_LOCK); // Toggle Num Lock to match layer state. |
| 47 | } | 47 | } |
diff --git a/keyboards/xiudi/xd75/keymaps/boy_314/keymap.c b/keyboards/xiudi/xd75/keymaps/boy_314/keymap.c index 1c5aa90627..1f3897f484 100644 --- a/keyboards/xiudi/xd75/keymaps/boy_314/keymap.c +++ b/keyboards/xiudi/xd75/keymaps/boy_314/keymap.c | |||
| @@ -126,16 +126,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 126 | }; | 126 | }; |
| 127 | 127 | ||
| 128 | void matrix_init_user(void) { | 128 | void matrix_init_user(void) { |
| 129 | if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) { | 129 | if (!host_keyboard_led_state().num_lock) { |
| 130 | register_code(KC_NUM_LOCK); | 130 | register_code(KC_NUM_LOCK); |
| 131 | unregister_code(KC_NUM_LOCK); | 131 | unregister_code(KC_NUM_LOCK); |
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | void led_set_user(uint8_t usb_led) { | 135 | bool led_update_user(led_t led_state) { |
| 136 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | 136 | if (led_state.caps_lock) { |
| 137 | rgblight_mode(18); | 137 | rgblight_mode(18); |
| 138 | } else { | 138 | } else { |
| 139 | rgblight_mode(14); | 139 | rgblight_mode(14); |
| 140 | } | 140 | } |
| 141 | return false; | ||
| 141 | } | 142 | } |
diff --git a/keyboards/yosino58/keymaps/default/keymap.c b/keyboards/yosino58/keymaps/default/keymap.c index 45ee46f7ce..512c0ec4b1 100644 --- a/keyboards/yosino58/keymaps/default/keymap.c +++ b/keyboards/yosino58/keymaps/default/keymap.c | |||
| @@ -200,8 +200,9 @@ bool oled_task_user(void) { | |||
| 200 | int rowa = 0; | 200 | int rowa = 0; |
| 201 | 201 | ||
| 202 | //Set Indicator icon | 202 | //Set Indicator icon |
| 203 | if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 1; } else { rown = 0; } | 203 | led_t led_state = host_keyboard_led_state(); |
| 204 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowc = 1; } else { rowc = 0; } | 204 | if (led_state.num_lock) { rown = 1; } else { rown = 0; } |
| 205 | if (led_state.caps_lock) { rowc = 1; } else { rowc = 0; } | ||
| 205 | if (layer_state == L_LOWER) { rowl = 1; } | 206 | if (layer_state == L_LOWER) { rowl = 1; } |
| 206 | if (layer_state == L_RAISE) { rowr = 1; } | 207 | if (layer_state == L_RAISE) { rowr = 1; } |
| 207 | if (layer_state == L_ADJUST) { rowa = 1; } | 208 | if (layer_state == L_ADJUST) { rowa = 1; } |
diff --git a/keyboards/yosino58/keymaps/sakura/keymap.c b/keyboards/yosino58/keymaps/sakura/keymap.c index 53d4f9b077..e3c8c52d7d 100644 --- a/keyboards/yosino58/keymaps/sakura/keymap.c +++ b/keyboards/yosino58/keymaps/sakura/keymap.c | |||
| @@ -200,8 +200,9 @@ bool oled_task_user(void) { | |||
| 200 | int rowa = 0; | 200 | int rowa = 0; |
| 201 | 201 | ||
| 202 | //Set Indicator icon | 202 | //Set Indicator icon |
| 203 | if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 1; } else { rown = 0; } | 203 | led_t led_state = host_keyboard_led_state(); |
| 204 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowc = 1; } else { rowc = 0; } | 204 | if (led_state.num_lock) { rown = 1; } else { rown = 0; } |
| 205 | if (led_state.caps_lock) { rowc = 1; } else { rowc = 0; } | ||
| 205 | if (layer_state == L_LOWER) { rowl = 1; } | 206 | if (layer_state == L_LOWER) { rowl = 1; } |
| 206 | if (layer_state == L_RAISE) { rowr = 1; } | 207 | if (layer_state == L_RAISE) { rowr = 1; } |
| 207 | if (layer_state == L_ADJUST) { rowa = 1; } | 208 | if (layer_state == L_ADJUST) { rowa = 1; } |
diff --git a/layouts/community/numpad_5x6/bjohnson/keymap.c b/layouts/community/numpad_5x6/bjohnson/keymap.c index 71c8829d02..63b358f226 100644 --- a/layouts/community/numpad_5x6/bjohnson/keymap.c +++ b/layouts/community/numpad_5x6/bjohnson/keymap.c | |||
| @@ -35,12 +35,13 @@ void keyboard_post_init_user(void) { | |||
| 35 | #endif | 35 | #endif |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | void led_set_user(uint8_t usb_led) { | 38 | bool led_update_user(led_t led_state) { |
| 39 | if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { | 39 | if (led_state.num_lock) { |
| 40 | rgblight_sethsv_noeeprom(HSV_CYAN); | 40 | rgblight_sethsv_noeeprom(HSV_CYAN); |
| 41 | } else { | 41 | } else { |
| 42 | rgblight_sethsv_noeeprom(HSV_MAGENTA); | 42 | rgblight_sethsv_noeeprom(HSV_MAGENTA); |
| 43 | } | 43 | } |
| 44 | return false; | ||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | void shutdown_user (void) { | 47 | void shutdown_user (void) { |
diff --git a/quantum/led.h b/quantum/led.h index 197f2618be..679e743396 100644 --- a/quantum/led.h +++ b/quantum/led.h | |||
| @@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | /* FIXME: Add doxygen comments here. */ | 23 | /* FIXME: Add doxygen comments here. */ |
| 24 | 24 | ||
| 25 | /* keyboard LEDs */ | 25 | /* keyboard LEDs */ |
| 26 | #define USB_LED_NUM_LOCK 0 | ||
| 27 | #define USB_LED_CAPS_LOCK 1 | 26 | #define USB_LED_CAPS_LOCK 1 |
| 28 | 27 | ||
| 29 | #ifdef __cplusplus | 28 | #ifdef __cplusplus |
diff --git a/users/doogle999/doogle999.c b/users/doogle999/doogle999.c index 5d71599687..a5bd637ece 100644 --- a/users/doogle999/doogle999.c +++ b/users/doogle999/doogle999.c | |||
| @@ -389,7 +389,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) | |||
| 389 | /* KC_KP_1, KC_KP_2, ..., KC_KP_0, KC_KP_DOT */ | 389 | /* KC_KP_1, KC_KP_2, ..., KC_KP_0, KC_KP_DOT */ |
| 390 | (keycode >= KC_KP_1 && keycode <= KC_KP_DOT); | 390 | (keycode >= KC_KP_1 && keycode <= KC_KP_DOT); |
| 391 | 391 | ||
| 392 | if(numpadKeyPressed && !(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) | 392 | if(numpadKeyPressed && !host_keyboard_led_state().num_lock) |
| 393 | { | 393 | { |
| 394 | add_key(KC_NUM_LOCK); | 394 | add_key(KC_NUM_LOCK); |
| 395 | send_keyboard_report(); | 395 | send_keyboard_report(); |
