cirque_pinnacle_gestures.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  2. * Copyright 2022 Daniel Kao <daniel.m.kao@gmail.com>
  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 "cirque_pinnacle.h"
  19. #include "report.h"
  20. typedef struct {
  21. bool tap_enable;
  22. bool circular_scroll_enable;
  23. } cirque_pinnacle_features_t;
  24. #ifdef CIRQUE_PINNACLE_TAP_ENABLE
  25. # ifndef CIRQUE_PINNACLE_TAPPING_TERM
  26. # include "action.h"
  27. # include "action_tapping.h"
  28. # define CIRQUE_PINNACLE_TAPPING_TERM GET_TAPPING_TERM(KC_BTN1, &(keyrecord_t){})
  29. # endif
  30. # ifndef CIRQUE_PINNACLE_TOUCH_DEBOUNCE
  31. # define CIRQUE_PINNACLE_TOUCH_DEBOUNCE (CIRQUE_PINNACLE_TAPPING_TERM * 8)
  32. # endif
  33. typedef struct {
  34. uint16_t timer;
  35. bool touchDown;
  36. } trackpad_tap_context_t;
  37. /* Enable/disable tap gesture */
  38. void cirque_pinnacle_enable_tap(bool enable);
  39. #endif
  40. #ifdef CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE
  41. typedef enum {
  42. SCROLL_UNINITIALIZED,
  43. SCROLL_DETECTING,
  44. SCROLL_VALID,
  45. NOT_SCROLL,
  46. } circular_scroll_status_t;
  47. typedef struct {
  48. int8_t v;
  49. int8_t h;
  50. bool suppress_touch;
  51. } circular_scroll_t;
  52. typedef struct {
  53. uint8_t outer_ring_pct; /* Width of outer ring, given as a percentage of the radius */
  54. uint8_t trigger_px; /* Amount of movement before triggering scroll validation, in pixels 0~127 */
  55. uint16_t trigger_ang; /* Angle required to validate scroll, in radians where pi = 32768 */
  56. uint8_t wheel_clicks; /* How many clicks to report in a circle */
  57. bool left_handed; /* Whether scrolling should be flipped for left handed use */
  58. } circular_scroll_config_t;
  59. typedef struct {
  60. circular_scroll_config_t config;
  61. circular_scroll_status_t state;
  62. uint8_t mag;
  63. int8_t x;
  64. int8_t y;
  65. uint16_t z;
  66. bool axis;
  67. } circular_scroll_context_t;
  68. /* Enable/disable circular scroll gesture */
  69. void cirque_pinnacle_enable_circular_scroll(bool enable);
  70. /*
  71. * Configure circular scroll gesture.
  72. * Trackpad can be configured to act exclusively as a scroll wheel with outer_ring_pct = 0, trigger_px = 0, trigger_ang = 0.
  73. * @param outer_ring_pct Width of outer ring from which to begin scroll validation, given as a percentage of the radius.
  74. * @param trigger_px Amount of movement before triggering scroll validation. Expressed in pixels, trackpad coordinates are scaled to radius of 128 pixels for circular scroll.
  75. * @param triger_ang Angle required to validate scroll, angle smaller than this will invalidate scroll. In radians where pi = 32768, 0 means movement towards center of trackpad, 16384 means movement perpendicular to center.
  76. * @param wheel_clicks Number of scroll wheel clicks to report in a full rotation.
  77. * @param left_handed Whether scrolling should be flipped for left-handed use.
  78. */
  79. void cirque_pinnacle_configure_circular_scroll(uint8_t outer_ring_pct, uint8_t trigger_px, uint16_t trigger_ang, uint8_t wheel_clicks, bool left_handed);
  80. #endif
  81. #ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
  82. /* Implementation in pointing_device_drivers.c */
  83. /* Enable/disable inertial cursor */
  84. void cirque_pinnacle_enable_cursor_glide(bool enable);
  85. /*
  86. * Configure inertial cursor.
  87. * @param trigger_px Movement required to trigger cursor glide, set this to non-zero if you have some amount of hover.
  88. */
  89. void cirque_pinnacle_configure_cursor_glide(float trigger_px);
  90. #endif
  91. /* Process available gestures */
  92. bool cirque_pinnacle_gestures(report_mouse_t* mouse_report, pinnacle_data_t touchData);