button.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2023 Daniele Lacamera <root@danielinux.net>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef BUTTON_H_INCLUDED
  18. #define BUTTON_H_INCLUDED
  19. void input_setup(void);
  20. int input_get_swl(void);
  21. int input_get_swr(void);
  22. #define N_BUTTONS 13
  23. #define BUTTON_DPADL 0
  24. #define BUTTON_DPADU 1
  25. #define BUTTON_DPADR 2
  26. #define BUTTON_DPADD 3
  27. #define BUTTON_OK 4
  28. #define BUTTON_BACK 5
  29. #define BUTTON_REPEAT 6
  30. #define BUTTON_DEL 7
  31. #define BUTTON_TPREV 8
  32. #define BUTTON_TNEXT 9
  33. #define BUTTON_PLUS 10
  34. #define BUTTON_MINUS 11
  35. #define TOUCHSCREEN 12
  36. #define TS_TOUCH_NONE 0
  37. #define TS_TOUCH_DETECTED 1
  38. #define TS_TOUCH_INPUT 2
  39. int input_detect_touch(void);
  40. struct user_button
  41. {
  42. int pressed;
  43. uint32_t transition_start_timestamp;
  44. };
  45. struct input_status
  46. {
  47. /* State switches */
  48. int sw_play, sw_rec;
  49. /* Trimmers */
  50. uint32_t pot_l, pot_r;
  51. /* Buttons */
  52. struct user_button b[N_BUTTONS];
  53. struct ts_touch_info {
  54. uint32_t X,Y;
  55. } ts;
  56. uint32_t start_touch;
  57. int touching;
  58. };
  59. extern struct input_status Input_status;
  60. #endif