Julien-Bernard

2ip SOCD with reac

Jan 28th, 2022 (edited)
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. bool right_isTheMostRecentPressed = false;
  2. bool up_isTheMostRecentPressed = false;
  3.  
  4. GCReport getGCReport(GpioToButtonSets::F1::ButtonSet buttonSet) {
  5.    
  6.     GpioToButtonSets::F1::ButtonSet bs = buttonSet; // Alterable copy
  7.  
  8.     GCReport gcReport = defaultGcReport;
  9.  
  10.     /* 2IP No reactivation */
  11.    
  12.     if (bs.right && !right_wasPressed) right_isTheMostRecentPressed=true;
  13.     if (bs.left && !left_wasPressed) right_isTheMostRecentPressed=false;
  14.     if (bs.up && !up_wasPressed) up_outlawUntilRelease=true;
  15.     if (bs.down && !down_wasPressed) up_isTheMostRecentPressed=false;
  16.  
  17.     left_wasPressed = bs.left;
  18.     right_wasPressed = bs.right;
  19.     up_wasPressed = bs.up;
  20.     down_wasPressed = bs.down;
  21.  
  22.     if (bs.left && bs.right) {
  23.         if (right_isTheMostRecentPressed) bs.left = false;
  24.         else bs.right = false;
  25.     }
  26.     if (bs.down && bs.up) {
  27.         if (up_isTheMostRecentPressed) bs.down = false;
  28.         else bs.up = false;
  29.     }
Add Comment
Please, Sign In to add comment