summaryrefslogtreecommitdiff
path: root/keyboards/tmo50/tmo50.c
diff options
context:
space:
mode:
authorJoe Wasson <joe@talljoe.com>2020-08-31 22:19:51 -0700
committerGitHub <noreply@github.com>2020-08-31 22:19:51 -0700
commit4a6cfb06c5aafb353ddfa056bfa69ae82b5fc894 (patch)
treebef6cc895bbc6280a400d579eb43cc06f1bbbcba /keyboards/tmo50/tmo50.c
parenta9a2817f3aff389fecf1b4bced52093a175a5a65 (diff)
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.
Diffstat (limited to 'keyboards/tmo50/tmo50.c')
-rw-r--r--keyboards/tmo50/tmo50.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/keyboards/tmo50/tmo50.c b/keyboards/tmo50/tmo50.c
index 4f6288133d..bad4319f11 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<<PB0);
} else {
PORTB |= (1<<PB0);
}
- // if on layer 1, turn on B1 LED, otherwise off.
- if (biton32(state) == 1) {
+ // if on layer 1, turn on B1 LED, otherwise off.
+ if (get_highest_layer(state) == 1) {
PORTB &= ~(1<<PB1);
} else {
PORTB |= (1<<PB1);
}
- // if on layer 2, turn on B2 LED, otherwise off.
- if (biton32(state) == 2) {
+
+ // if on layer 2, turn on B2 LED, otherwise off.
+ if (get_highest_layer(state) == 2) {
PORTB &= ~(1<<PB2);
} else {
PORTB |= (1<<PB2);
}
- // if on layer 3, turn on B3 LED, otherwise off.
- if (biton32(state) == 3) {
+ // if on layer 3, turn on B3 LED, otherwise off.
+ if (get_highest_layer(state) == 3) {
PORTB &= ~(1<<PB3);
} else {
PORTB |= (1<<PB3);
}
+ }
- return state;
+ return true;
}