From 9e03e120c3f98664a67f74b8418506b1047b847d Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Sat, 2 Sep 2023 07:48:11 -0400 Subject: [PATCH] switch layers: fix crash Signed-off-by: Maarten van Gompel --- keyboard.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/keyboard.c b/keyboard.c index bba2ca3..5ee5981 100644 --- a/keyboard.c +++ b/keyboard.c @@ -66,20 +66,20 @@ kbd_next_layer(struct kbd *kb, struct key *k, bool invert) { } else { // normal behaviour: switch to the next layout in the layer sequence layer_index++; - size_t layercount = 0; - for (size_t i = 0; layercount == 0; i++) { - if (kb->landscape) { - if (kb->landscape_layers[i] == NumLayouts) layercount = i; - } else { - if (kb->layers[i] == NumLayouts) layercount = i; - } - } - if (layer_index >= layercount) { - if (kb->debug) - fprintf(stderr, "wrapping layer_index back to start\n"); - layer_index = 0; + } + size_t layercount = 0; + for (size_t i = 0; layercount == 0; i++) { + if (kb->landscape) { + if (kb->landscape_layers[i] == NumLayouts) layercount = i; + } else { + if (kb->layers[i] == NumLayouts) layercount = i; } } + if (layer_index >= layercount) { + if (kb->debug) + fprintf(stderr, "wrapping layer_index back to start\n"); + layer_index = 0; + } enum layout_id layer; if (kb->landscape) { layer = kb->landscape_layers[layer_index];