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.

66 lines
2.0 KiB

  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  2. * Copyright 2020 Ploopy Corporation
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <stdbool.h>
  19. #ifndef SCROLLER_AR_SIZE
  20. # define SCROLLER_AR_SIZE 31
  21. #endif
  22. #ifndef SCROLL_THRESH_RANGE_LIM
  23. # define SCROLL_THRESH_RANGE_LIM 10
  24. #endif
  25. enum State { HIHI, HILO, LOLO, LOHI };
  26. extern enum State state;
  27. /* Variables used for scroll wheel functionality. */
  28. extern bool lohif;
  29. extern bool hilof;
  30. extern int lowA;
  31. extern int highA;
  32. extern bool cLowA;
  33. extern bool cHighA;
  34. extern int lowIndexA;
  35. extern int highIndexA;
  36. extern bool lowOverflowA;
  37. extern bool highOverflowA;
  38. extern int lowB;
  39. extern int highB;
  40. extern bool cLowB;
  41. extern bool cHighB;
  42. extern int lowIndexB;
  43. extern int highIndexB;
  44. extern bool lowOverflowB;
  45. extern bool highOverflowB;
  46. extern int scrollThresholdA;
  47. extern int scrollThresholdB;
  48. extern int arLowA[SCROLLER_AR_SIZE];
  49. extern int arHighA[SCROLLER_AR_SIZE];
  50. extern int arLowB[SCROLLER_AR_SIZE];
  51. extern int arHighB[SCROLLER_AR_SIZE];
  52. void calculateThresholdA(int curA);
  53. void calculateThresholdB(int curB);
  54. int calculateThreshold(int cur, int* low, int* high, bool* cLow, bool* cHigh, int arLow[], int arHigh[], int* lowIndex, int* highIndex, bool* lowOverflow, bool* highOverflow);
  55. int thresholdEquation(int lo, int hi);
  56. void incrementIndex(int* index, bool* ovflw);
  57. void opt_encoder_init(void);
  58. int opt_encoder_handler(int curA, int curB);