touchscreen.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2019 Clementine Computing LLC.
  3. *
  4. * This file is part of PopuFare.
  5. *
  6. * PopuFare is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * PopuFare is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #include "touchscreen.h"
  21. static int ts_calib_left = 0x07F;
  22. static int ts_calib_right = 0x3BD;
  23. static int ts_calib_top = 0x040;
  24. static int ts_calib_bottom = 0x3AA;
  25. void begin_touchscreen_calibration(void) {
  26. }
  27. void draw_touchscreen_calibration(void) {
  28. }
  29. int advance_touchscreen_calibration(int raw_x, int raw_y, int down) {
  30. return 0;
  31. }
  32. int translate_ts_x(unsigned rawx)
  33. {
  34. int accum = (rawx - ts_calib_left);
  35. if(accum < 0)
  36. accum = 0;
  37. accum *= (XRES - 1);
  38. accum /= (ts_calib_right - ts_calib_left);
  39. if(accum >= XRES)
  40. {
  41. return XRES - 1;
  42. }
  43. return accum;
  44. }
  45. int translate_ts_y(unsigned rawy)
  46. {
  47. int accum = (rawy - ts_calib_top);
  48. if(accum < 0)
  49. accum = 0;
  50. accum *= (YRES - 1);
  51. accum /= (ts_calib_bottom - ts_calib_top);
  52. if(accum >= YRES)
  53. {
  54. return YRES - 1;
  55. }
  56. return accum;
  57. }