From 2e6c787eea869674afc2fa0f23cb73711725ca2d Mon Sep 17 00:00:00 2001 From: fauxpark Date: Sun, 2 Jul 2023 10:36:31 +1000 Subject: [PATCH 1/2] Get rid of `USB_LED_NUM_LOCK` --- .../gherkin/keymaps/default/keymap.c | 7 +++--- keyboards/contra/keymaps/maxr1998/keymap.c | 5 ++-- keyboards/crkbd/keymaps/rpbaptist/keymap.c | 6 ++--- .../dz60rgb/keymaps/matthewrobo/keymap.c | 13 +++------- .../dztech/dz60rgb/keymaps/mekanist/keymap.c | 25 +++---------------- .../dz65rgb/keymaps/matthewrobo/keymap.c | 11 ++------ .../arrow_pad/keymaps/default/keymap.c | 7 +++--- .../arrow_pad/keymaps/pad_21/keymap.c | 7 +++--- .../arrow_pad/keymaps/pad_24/keymap.c | 7 +++--- keyboards/input_club/infinity60/led.c | 7 +++--- .../input_club/infinity60/led_controller.c | 5 ++-- .../kbdfans/niu_mini/keymaps/tobias/keymap.c | 12 +++------ .../kprepublic/jj40/keymaps/stevexyz/keymap.c | 5 +--- .../massdrop/alt/keymaps/jdelkins_ss/keymap.c | 3 +-- keyboards/mt/mt980/keymaps/walker/keymap.c | 4 +-- .../novelkeys/novelpad/keymaps/0xdec/keymap.c | 5 ++-- .../setta21/keymaps/salicylic/keymap.c | 6 ++--- .../cypher/rev1/keymaps/kwer/keymap.c | 19 +++----------- .../xiudi/xd75/keymaps/billypython/keymap.c | 2 +- keyboards/xiudi/xd75/keymaps/boy_314/keymap.c | 7 +++--- keyboards/yosino58/keymaps/default/keymap.c | 5 ++-- keyboards/yosino58/keymaps/sakura/keymap.c | 5 ++-- .../community/numpad_5x6/bjohnson/keymap.c | 5 ++-- quantum/led.h | 1 - users/doogle999/doogle999.c | 2 +- 25 files changed, 68 insertions(+), 113 deletions(-) diff --git a/keyboards/40percentclub/gherkin/keymaps/default/keymap.c b/keyboards/40percentclub/gherkin/keymaps/default/keymap.c index ab2a1fa1c141..f4d3032857ce 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) { setPinOutput(B0); } -void led_set_user(uint8_t usb_led) { - if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) { +bool led_update_user(led_t led_state) { + if (led_state.num_lock) { writePinLow(D5); } else { writePinHigh(D5); } - if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { + if (led_state.caps_lock) { writePinLow(B0); } else { writePinHigh(B0); } + return false; } diff --git a/keyboards/contra/keymaps/maxr1998/keymap.c b/keyboards/contra/keymaps/maxr1998/keymap.c index 8a56c6074610..0802a211f062 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) { } } -void led_set_user(uint8_t usb_led) { +bool led_update_user(led_t led_state) { // Force-enable Numlock - if (!(usb_led & (1<. * both regular threads and ISRs, unlocked (during resume-from-sleep). * In particular, I2C functions (interrupt-driven) should NOT be called from here. */ -void led_set(uint8_t usb_led) { +void led_update_user(led_t led_state) { msg_t msg; - if (usb_led & (1<event.pressed) { layer_invert(L_NUMPAD); - bool num_lock = host_keyboard_leds() & 1<. /* FIXME: Add doxygen comments here. */ /* keyboard LEDs */ -#define USB_LED_NUM_LOCK 0 #define USB_LED_CAPS_LOCK 1 #define USB_LED_SCROLL_LOCK 2 diff --git a/users/doogle999/doogle999.c b/users/doogle999/doogle999.c index 5d71599687a0..a5bd637ecea7 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) /* KC_KP_1, KC_KP_2, ..., KC_KP_0, KC_KP_DOT */ (keycode >= KC_KP_1 && keycode <= KC_KP_DOT); - if(numpadKeyPressed && !(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) + if(numpadKeyPressed && !host_keyboard_led_state().num_lock) { add_key(KC_NUM_LOCK); send_keyboard_report(); From 96b7c0a95ecbe39fba5f301e71d495a7c5a7ad65 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Sun, 2 Jul 2023 17:18:34 +1000 Subject: [PATCH 2/2] Fix return type --- keyboards/input_club/infinity60/led.c | 51 ++++++++++++++------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/keyboards/input_club/infinity60/led.c b/keyboards/input_club/infinity60/led.c index 7a1d7458ae6f..33871bcc49ca 100644 --- a/keyboards/input_club/infinity60/led.c +++ b/keyboards/input_club/infinity60/led.c @@ -26,30 +26,33 @@ along with this program. If not, see . * both regular threads and ISRs, unlocked (during resume-from-sleep). * In particular, I2C functions (interrupt-driven) should NOT be called from here. */ -void led_update_user(led_t led_state) { - msg_t msg; - - if (led_state.num_lock) { - chSysUnconditionalLock(); - msg=(1 << 8) | TOGGLE_NUM_LOCK; - chMBPostI(&led_mailbox, msg); - chSysUnconditionalUnlock(); - } else { - chSysUnconditionalLock(); - msg=(0 << 8) | TOGGLE_NUM_LOCK; - chMBPostI(&led_mailbox, msg); - chSysUnconditionalUnlock(); - } - if (led_state.caps_lock) { - chSysUnconditionalLock(); - msg=(1 << 8) | TOGGLE_CAPS_LOCK; - chMBPostI(&led_mailbox, msg); - chSysUnconditionalUnlock(); - } else { - chSysUnconditionalLock(); - msg=(0 << 8) | TOGGLE_CAPS_LOCK; - chMBPostI(&led_mailbox, msg); - chSysUnconditionalUnlock(); +bool led_update_kb(led_t led_state) { + bool res = led_update_user(led_state); + if (res) { + msg_t msg; + + if (led_state.num_lock) { + chSysUnconditionalLock(); + msg=(1 << 8) | TOGGLE_NUM_LOCK; + chMBPostI(&led_mailbox, msg); + chSysUnconditionalUnlock(); + } else { + chSysUnconditionalLock(); + msg=(0 << 8) | TOGGLE_NUM_LOCK; + chMBPostI(&led_mailbox, msg); + chSysUnconditionalUnlock(); + } + if (led_state.caps_lock) { + chSysUnconditionalLock(); + msg=(1 << 8) | TOGGLE_CAPS_LOCK; + chMBPostI(&led_mailbox, msg); + chSysUnconditionalUnlock(); + } else { + chSysUnconditionalLock(); + msg=(0 << 8) | TOGGLE_CAPS_LOCK; + chMBPostI(&led_mailbox, msg); + chSysUnconditionalUnlock(); + } } return false; }