You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

40 lines
1.4 KiB

  1. diff --git a/lisgd.c b/lisgd.c
  2. index 9d3442b..78f6a3c 100644
  3. --- a/lisgd.c
  4. +++ b/lisgd.c
  5. @@ -109,19 +109,21 @@ touchup(struct libinput_event *e)
  6. );
  7. }
  8. - if (xend[slot] > xstart[slot] && fabs(xend[slot] - xstart[slot]) > threshold) {
  9. - start = Left;
  10. - end = Right;
  11. - } else if (xend[slot] < xstart[slot] && fabs(xend[slot] - xstart[slot]) > threshold) {
  12. - start = Right;
  13. - end = Left;
  14. - } else if (yend[slot] > ystart[slot] && fabs(yend[slot] - ystart[slot]) > threshold) {
  15. - start = Up;
  16. - end = Down;
  17. - } else if (yend[slot] < ystart[slot] && fabs(yend[slot] - ystart[slot]) > threshold) {
  18. - start = Down;
  19. - end = Up;
  20. - } else {
  21. + int move_x = fabs(xend[slot] - xstart[slot]) > threshold
  22. + ? (xend[slot] > xstart[slot] ? 1 : -1) : 0;
  23. + int move_y = fabs(yend[slot] - ystart[slot]) > threshold
  24. + ? (yend[slot] > ystart[slot] ? 1 : -1) : 0;
  25. + switch (move_x * 100 + move_y) {
  26. + case -100 -1: start = Right; end = Up; break;
  27. + case -100 +0: start = Right; end = Left; break;
  28. + case -100 +1: start = Right; end = Down; break;
  29. + case +0 -1: start = Down; end = Up; break;
  30. + case +0 +1: start = Up; end = Down; break;
  31. + case +100 -1: start = Left; end = Up; break;
  32. + case +100 +0: start = Left; end = Right; break;
  33. + case +100 +1: start = Left; end = Down; break;
  34. + case +0 +0:
  35. + default:
  36. if (verbose) {
  37. fprintf(stderr, "Input didn't match a known gesture\n");
  38. }