qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

cirque_pinnacle_gestures.h (4401B)


      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 
     19 #include "cirque_pinnacle.h"
     20 #include "report.h"
     21 
     22 typedef struct {
     23     bool tap_enable;
     24     bool circular_scroll_enable;
     25 } cirque_pinnacle_features_t;
     26 
     27 #if defined(CIRQUE_PINNACLE_TAP_ENABLE) && CIRQUE_PINNACLE_POSITION_MODE
     28 #    ifndef CIRQUE_PINNACLE_TAPPING_TERM
     29 #        include "action.h"
     30 #        include "action_tapping.h"
     31 #        define CIRQUE_PINNACLE_TAPPING_TERM GET_TAPPING_TERM(QK_MOUSE_BUTTON_1, &(keyrecord_t){})
     32 #    endif
     33 #    ifndef CIRQUE_PINNACLE_TOUCH_DEBOUNCE
     34 #        define CIRQUE_PINNACLE_TOUCH_DEBOUNCE (CIRQUE_PINNACLE_TAPPING_TERM * 8)
     35 #    endif
     36 
     37 typedef struct {
     38     uint16_t timer;
     39     bool     touchDown;
     40 } trackpad_tap_context_t;
     41 
     42 /* Enable/disable tap gesture */
     43 void cirque_pinnacle_enable_tap(bool enable);
     44 #endif
     45 
     46 #ifdef CIRQUE_PINNACLE_CIRCULAR_SCROLL_ENABLE
     47 #    if !CIRQUE_PINNACLE_POSITION_MODE
     48 #        error "Circular scroll is not supported in relative mode"
     49 #    endif
     50 typedef enum {
     51     SCROLL_UNINITIALIZED,
     52     SCROLL_DETECTING,
     53     SCROLL_VALID,
     54     NOT_SCROLL,
     55 } circular_scroll_status_t;
     56 
     57 typedef struct {
     58     int8_t v;
     59     int8_t h;
     60     bool   suppress_touch;
     61 } circular_scroll_t;
     62 
     63 typedef struct {
     64     uint8_t  outer_ring_pct; /* Width of outer ring, given as a percentage of the radius */
     65     uint8_t  trigger_px;     /* Amount of movement before triggering scroll validation, in pixels 0~127 */
     66     uint16_t trigger_ang;    /* Angle required to validate scroll, in radians where pi = 32768 */
     67     uint8_t  wheel_clicks;   /* How many clicks to report in a circle */
     68     bool     left_handed;    /* Whether scrolling should be flipped for left handed use */
     69 } circular_scroll_config_t;
     70 
     71 typedef struct {
     72     circular_scroll_config_t config;
     73     circular_scroll_status_t state;
     74     uint8_t                  mag;
     75     int8_t                   x;
     76     int8_t                   y;
     77     uint16_t                 z;
     78     bool                     axis;
     79 } circular_scroll_context_t;
     80 
     81 /* Enable/disable circular scroll gesture */
     82 void cirque_pinnacle_enable_circular_scroll(bool enable);
     83 
     84 /*
     85  * Configure circular scroll gesture.
     86  * Trackpad can be configured to act exclusively as a scroll wheel with outer_ring_pct = 0, trigger_px = 0, trigger_ang = 0.
     87  * @param outer_ring_pct Width of outer ring from which to begin scroll validation, given as a percentage of the radius.
     88  * @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.
     89  * @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.
     90  * @param wheel_clicks Number of scroll wheel clicks to report in a full rotation.
     91  * @param left_handed Whether scrolling should be flipped for left-handed use.
     92  */
     93 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);
     94 #endif
     95 
     96 #ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
     97 /* Implementation in pointing_device_drivers.c */
     98 
     99 /* Enable/disable inertial cursor */
    100 void cirque_pinnacle_enable_cursor_glide(bool enable);
    101 
    102 /*
    103  * Configure inertial cursor.
    104  * @param trigger_px Movement required to trigger cursor glide, set this to non-zero if you have some amount of hover.
    105  */
    106 void cirque_pinnacle_configure_cursor_glide(float trigger_px);
    107 #endif
    108 
    109 /* Process available gestures */
    110 bool cirque_pinnacle_gestures(report_mouse_t* mouse_report, pinnacle_data_t touchData);