From fcb451a3edab46b9bc7bb4c3d7b92b71fef5f481 Mon Sep 17 00:00:00 2001 From: Joe Wasson Date: Mon, 31 Aug 2020 22:19:51 -0700 Subject: [PATCH] TMO50: use layer_state_set_kb at keyboard level (#10150) * Change TMO to use layer_state_set_kb as is customary at the keyboard level. This also factors out `process_indicator_led` to a separate method. --- keyboards/tmo50/tmo50.c | 37 +++++++++++++++++++++++++++---------- keyboards/tmo50/tmo50.h | 5 ++++- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/keyboards/tmo50/tmo50.c b/keyboards/tmo50/tmo50.c index 4f6288133da3..bad4319f11e7 100644 --- a/keyboards/tmo50/tmo50.c +++ b/keyboards/tmo50/tmo50.c @@ -51,34 +51,51 @@ void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } -uint32_t layer_state_set_user(uint32_t state) +layer_state_t layer_state_set_kb(layer_state_t state) { - // if on layer 0, turn on B0 LED, otherwise off. - if (biton32(state) == 0) { + state = layer_state_set_user(state); + process_indicator_led_kb(state); + + return state; +} + +__attribute__((weak)) +bool process_indicator_led_user(layer_state_t state){ + return true; +} + +bool process_indicator_led_kb(layer_state_t state) +{ + if(process_indicator_led_user(state)) + { + // if on layer 0, turn on B0 LED, otherwise off. + if (get_highest_layer(state) == 0) { PORTB &= ~(1<