Refactor some led_set_kb instances (#19179)

* Refactor some led_set_kb instances

* Apply suggestions from code review

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
Joel Challis
2022-12-09 01:42:22 +00:00
committed by GitHub
parent ba6ee29040
commit 99cd0b13e1
18 changed files with 165 additions and 202 deletions

View File

@@ -42,20 +42,23 @@ void backlight_set(uint8_t level) {
}
}
// Port from backlight_update_state
void led_set_kb(uint8_t usb_led) {
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
bool status[8] = {
host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK), /* LED 3 */
host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK), /* LED 2 */
host_keyboard_leds() & (1<<USB_LED_NUM_LOCK), /* LED 1 */
led_state.scroll_lock, /* LED 3 */
led_state.caps_lock, /* LED 2 */
led_state.num_lock, /* LED 1 */
layer_state & (1<<2), /* LED 6 */
layer_state & (1<<1), /* LED 5 */
layer_state & (1<<0) ? 0: 1, /* LED 4 */
layer_state & (1<<2), /* LED 6 */
layer_state & (1<<1), /* LED 5 */
layer_state & (1<<0) ? 0: 1, /* LED 4 */
layer_state & (1<<5), /* LED 8 */
layer_state & (1<<4) /* LED 7 */
};
layer_state & (1<<5), /* LED 8 */
layer_state & (1<<4) /* LED 7 */
};
indicator_leds_set(status);
indicator_leds_set(status);
}
return res;
}