Quellcode durchsuchen

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.
woob vor 1 Jahr
Ursprung
Commit
1012b45ba4
1 geänderte Dateien mit 2 neuen und 4 gelöschten Zeilen
  1. 2 4
      views/countdown_view.c

+ 2 - 4
views/countdown_view.c

@@ -304,13 +304,11 @@ static void handle_time_setting_select(InputKey key, CountDownTimView* cdv) {
         break;
         break;
 
 
     case InputKeyRight:
     case InputKeyRight:
-        selection--;
-        selection = selection % 3;
+        selection = (3 + selection - 1) % 3;
         break;
         break;
 
 
     case InputKeyLeft:
     case InputKeyLeft:
-        selection++;
-        selection = selection % 3;
+        selection = (3 + selection + 1) % 3;
         break;
         break;
 
 
     default:
     default: