cirque_pinnacle_gestures.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #if defined(CIRQUE_PINNACLE_TAP_ENABLE) && CIRQUE_PINNACLE_POSITION_MODE
  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. # if !CIRQUE_PINNACLE_POSITION_MODE
  42. # error "Circular scroll is not supported in relative mode"
  43. # endif
  44. typedef enum {
  45. SCROLL_UNINITIALIZED,
  46. SCROLL_DETECTING,
  47. SCROLL_VALID,
  48. NOT_SCROLL,
  49. } circular_scroll_status_t;
  50. typedef struct {
  51. int8_t v;
  52. int8_t h;
  53. bool suppress_touch;
  54. } circular_scroll_t;
  55. typedef struct {
  56. uint8_t outer_ring_pct; /* Width of outer ring, given as a percentage of the radius */
  57. uint8_t trigger_px; /* Amount of movement before triggering scroll validation, in pixels 0~127 */
  58. uint16_t trigger_ang; /* Angle required to validate scroll, in radians where pi = 32768 */
  59. uint8_t wheel_clicks; /* How many clicks to report in a circle */
  60. bool left_handed; /* Whether scrolling should be flipped for left handed use */
  61. } circular_scroll_config_t;
  62. typedef struct {
  63. circular_scroll_config_t config;
  64. circular_scroll_status_t state;
  65. uint8_t mag;
  66. int8_t x;
  67. int8_t y;
  68. uint16_t z;
  69. bool axis;
  70. } circular_scroll_context_t;
  71. /* Enable/disable circular scroll gesture */
  72. void cirque_pinnacle_enable_circular_scroll(bool enable);
  73. /*
  74. * Configure circular scroll gesture.
  75. * Trackpad can be configured to act exclusively as a scroll wheel with outer_ring_pct = 0, trigger_px = 0, trigger_ang = 0.
  76. * @param outer_ring_pct Width of outer ring from which to begin scroll validation, given as a percentage of the radius.
  77. * @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.
  78. * @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.
  79. * @param wheel_clicks Number of scroll wheel clicks to report in a full rotation.
  80. * @param left_handed Whether scrolling should be flipped for left-handed use.
  81. */
  82. 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);
  83. #endif
  84. #ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
  85. /* Implementation in pointing_device_drivers.c */
  86. /* Enable/disable inertial cursor */
  87. void cirque_pinnacle_enable_cursor_glide(bool enable);
  88. /*
  89. * Configure inertial cursor.
  90. * @param trigger_px Movement required to trigger cursor glide, set this to non-zero if you have some amount of hover.
  91. */
  92. void cirque_pinnacle_configure_cursor_glide(float trigger_px);
  93. #endif
  94. /* Process available gestures */
  95. bool cirque_pinnacle_gestures(report_mouse_t* mouse_report, pinnacle_data_t touchData);