pointing_device_gestures.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright 2022 Daniel Kao <daniel.m.kao@gmail.com>
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include <stdint.h>
  18. #include "report.h"
  19. #ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
  20. typedef struct {
  21. mouse_xy_report_t dx;
  22. mouse_xy_report_t dy;
  23. bool valid;
  24. } cursor_glide_t;
  25. typedef struct {
  26. uint16_t trigger_px; /* Pixels of movement needed to trigger cursor glide */
  27. uint16_t coef; /* Coefficient of friction */
  28. uint16_t interval; /* Glide report interval, in milliseconds */
  29. } cursor_glide_config_t;
  30. typedef struct {
  31. int32_t v0;
  32. int32_t x;
  33. int32_t y;
  34. uint16_t z;
  35. uint16_t timer;
  36. uint16_t counter;
  37. mouse_xy_report_t dx0;
  38. mouse_xy_report_t dy0;
  39. } cursor_glide_status_t;
  40. typedef struct {
  41. cursor_glide_config_t config;
  42. cursor_glide_status_t status;
  43. } cursor_glide_context_t;
  44. /* Check glide report conditions, calculates glide coordinates */
  45. cursor_glide_t cursor_glide_check(cursor_glide_context_t* glide);
  46. /* Start glide reporting, gives first set of glide coordinates */
  47. cursor_glide_t cursor_glide_start(cursor_glide_context_t* glide);
  48. /* Update glide engine on the latest cursor movement, cursor glide is based on the final movement */
  49. void cursor_glide_update(cursor_glide_context_t* glide, mouse_xy_report_t dx, mouse_xy_report_t dy, uint16_t z);
  50. #endif