Skip to content

Commit 1012b45

Browse files
puppable0w0mewo
authored andcommitted
countdown timer: make digit selection wrap when pressing right
When pressing right, adds the modulo number to the `selection` variable before subtracting and modulo'ing it. This prevents it from being assigned a negative value (which cannot be relied upon for an enum), as well as making the variable properly wrap around below "zero". While not strictly necessary, the code for handling left button presses is also changed for consistency.
1 parent fce19e3 commit 1012b45

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

views/countdown_view.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,11 @@ static void handle_time_setting_select(InputKey key, CountDownTimView* cdv) {
304304
break;
305305

306306
case InputKeyRight:
307-
selection--;
308-
selection = selection % 3;
307+
selection = (3 + selection - 1) % 3;
309308
break;
310309

311310
case InputKeyLeft:
312-
selection++;
313-
selection = selection % 3;
311+
selection = (3 + selection + 1) % 3;
314312
break;
315313

316314
default:

0 commit comments

Comments
 (0)