summaryrefslogtreecommitdiff
path: root/keyboards/duck
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-12-09 01:42:22 +0000
committerGitHub <noreply@github.com>2022-12-09 01:42:22 +0000
commit99cd0b13e109bb14f1e5af023c5fcb5e50a78e0a (patch)
treef6b3198bca1321fb9f4b8c0903d87869a8816630 /keyboards/duck
parentba6ee2904066aa64fa83417dc865f24dc76d991b (diff)
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>
Diffstat (limited to 'keyboards/duck')
-rw-r--r--keyboards/duck/eagle_viper/v2/v2.c27
-rw-r--r--keyboards/duck/jetfire/jetfire.c39
-rw-r--r--keyboards/duck/lightsaver/lightsaver.c32
3 files changed, 53 insertions, 45 deletions
diff --git a/keyboards/duck/eagle_viper/v2/v2.c b/keyboards/duck/eagle_viper/v2/v2.c
index d3e1368de9..e7ce5d4749 100644
--- a/keyboards/duck/eagle_viper/v2/v2.c
+++ b/keyboards/duck/eagle_viper/v2/v2.c
@@ -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;
}
diff --git a/keyboards/duck/jetfire/jetfire.c b/keyboards/duck/jetfire/jetfire.c
index d648287156..7bebd7ad21 100644
--- a/keyboards/duck/jetfire/jetfire.c
+++ b/keyboards/duck/jetfire/jetfire.c
@@ -95,22 +95,25 @@ void backlight_update_state()
show();
}
-void led_set_kb(uint8_t usb_led)
-{
- if(usb_led & (1<<USB_LED_CAPS_LOCK)) {
- backlight_state_led |= 1<<STATE_LED_CAPS_LOCK;
- } else {
- backlight_state_led &= ~(1<<STATE_LED_CAPS_LOCK);
- }
- if(usb_led & (1<<USB_LED_SCROLL_LOCK)) {
- backlight_state_led |= 1<<STATE_LED_SCROLL_LOCK;
- } else {
- backlight_state_led &= ~(1<<STATE_LED_SCROLL_LOCK);
- }
- if(usb_led & (1<<USB_LED_NUM_LOCK)) {
- backlight_state_led |= 1<<STATE_LED_NUM_LOCK;
- } else {
- backlight_state_led &= ~(1<<STATE_LED_NUM_LOCK);
- }
- backlight_update_state();
+bool led_update_kb(led_t led_state) {
+ bool res = led_update_user(led_state);
+ if(res) {
+ if(led_state.caps_lock) {
+ backlight_state_led |= 1<<STATE_LED_CAPS_LOCK;
+ } else {
+ backlight_state_led &= ~(1<<STATE_LED_CAPS_LOCK);
+ }
+ if(led_state.scroll_lock) {
+ backlight_state_led |= 1<<STATE_LED_SCROLL_LOCK;
+ } else {
+ backlight_state_led &= ~(1<<STATE_LED_SCROLL_LOCK);
+ }
+ if(led_state.num_lock) {
+ backlight_state_led |= 1<<STATE_LED_NUM_LOCK;
+ } else {
+ backlight_state_led &= ~(1<<STATE_LED_NUM_LOCK);
+ }
+ backlight_update_state();
+ }
+ return res;
}
diff --git a/keyboards/duck/lightsaver/lightsaver.c b/keyboards/duck/lightsaver/lightsaver.c
index e0fe918e7d..eba1ce25c2 100644
--- a/keyboards/duck/lightsaver/lightsaver.c
+++ b/keyboards/duck/lightsaver/lightsaver.c
@@ -39,18 +39,20 @@ void backlight_set(uint8_t level) {
}
}
-void led_set_kb(uint8_t usb_led) {
- bool leds[8] = {
- usb_led & (1<<USB_LED_CAPS_LOCK),
- usb_led & (1<<USB_LED_SCROLL_LOCK),
- usb_led & (1<<USB_LED_NUM_LOCK),
- layer_state & (1<<1),
- layer_state & (1<<2),
- layer_state & (1<<3),
- layer_state & (1<<4),
- layer_state & (1<<5)
- };
- indicator_leds_set(leds);
-
- led_set_user(usb_led);
-}
+bool led_update_kb(led_t led_state) {
+ bool res = led_update_user(led_state);
+ if(res) {
+ bool leds[8] = {
+ led_state.caps_lock,
+ led_state.scroll_lock,
+ led_state.num_lock,
+ layer_state & (1<<1),
+ layer_state & (1<<2),
+ layer_state & (1<<3),
+ layer_state & (1<<4),
+ layer_state & (1<<5)
+ };
+ indicator_leds_set(leds);
+ }
+ return res;
+} \ No newline at end of file