synapticsstr.h revision 302b15bd
1/* 2 * Permission to use, copy, modify, distribute, and sell this software 3 * and its documentation for any purpose is hereby granted without 4 * fee, provided that the above copyright notice appear in all copies 5 * and that both that copyright notice and this permission notice 6 * appear in supporting documentation, and that the name of Red Hat 7 * not be used in advertising or publicity pertaining to distribution 8 * of the software without specific, written prior permission. Red 9 * Hat makes no representations about the suitability of this software 10 * for any purpose. It is provided "as is" without express or implied 11 * warranty. 12 * 13 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 14 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 15 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 16 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 17 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 18 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 19 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22#ifndef _SYNAPTICSSTR_H_ 23#define _SYNAPTICSSTR_H_ 24 25#include "synproto.h" 26 27#ifdef DBG 28# undef DBG 29#endif 30 31#ifdef DEBUG 32#define DBG(verb, ...) \ 33 xf86MsgVerb(X_INFO, verb, __VA_ARGS__) 34#else 35#define DBG(verb, msg, ...) /* */ 36#endif 37 38/****************************************************************************** 39 * Definitions 40 * structs, typedefs, #defines, enums 41 *****************************************************************************/ 42#define SYNAPTICS_MOVE_HISTORY 5 43 44typedef struct _SynapticsMoveHist 45{ 46 int x, y; 47 int millis; 48} SynapticsMoveHistRec; 49 50enum FingerState { /* Note! The order matters. Compared with < operator. */ 51 FS_UNTOUCHED, 52 FS_TOUCHED, 53 FS_PRESSED 54}; 55 56enum MovingState { 57 MS_FALSE, 58 MS_TOUCHPAD_RELATIVE, 59 MS_TRACKSTICK /* trackstick is always relative */ 60}; 61 62enum MidButtonEmulation { 63 MBE_OFF, /* No button pressed */ 64 MBE_LEFT, /* Left button pressed, waiting for right button or timeout */ 65 MBE_RIGHT, /* Right button pressed, waiting for left button or timeout */ 66 MBE_MID, /* Left and right buttons pressed, waiting for both buttons 67 to be released */ 68 MBE_TIMEOUT, /* Waiting for both buttons to be released. */ 69 MBE_LEFT_CLICK, /* Emulate left button click. */ 70 MBE_RIGHT_CLICK, /* Emulate right button click. */ 71}; 72 73/* See docs/tapndrag.dia for a state machine diagram */ 74enum TapState { 75 TS_START, /* No tap/drag in progress */ 76 TS_1, /* After first touch */ 77 TS_MOVE, /* Pointer movement enabled */ 78 TS_2A, /* After first release */ 79 TS_2B, /* After second/third/... release */ 80 TS_SINGLETAP, /* After timeout after first release */ 81 TS_3, /* After second touch */ 82 TS_DRAG, /* Pointer drag enabled */ 83 TS_4, /* After release when "locked drags" enabled */ 84 TS_5 /* After touch when "locked drags" enabled */ 85}; 86 87enum TapButtonState { 88 TBS_BUTTON_UP, /* "Virtual tap button" is up */ 89 TBS_BUTTON_DOWN, /* "Virtual tap button" is down */ 90 TBS_BUTTON_DOWN_UP /* Send button down event + set up state */ 91}; 92 93enum TouchpadModel { 94 MODEL_UNKNOWN = 0, 95 MODEL_SYNAPTICS, 96 MODEL_ALPS, 97 MODEL_APPLETOUCH 98}; 99 100typedef struct _SynapticsParameters 101{ 102 /* Parameter data */ 103 int left_edge, right_edge, top_edge, bottom_edge; /* edge coordinates absolute */ 104 int finger_low, finger_high, finger_press; /* finger detection values in Z-values */ 105 int tap_time; 106 int tap_move; /* max. tapping time and movement in packets and coord. */ 107 int single_tap_timeout; /* timeout to recognize a single tap */ 108 int tap_time_2; /* max. tapping time for double taps */ 109 int click_time; /* The duration of a single click */ 110 Bool fast_taps; /* Faster reaction to single taps */ 111 int emulate_mid_button_time; /* Max time between left and right button presses to 112 emulate a middle button press. */ 113 int emulate_twofinger_z; /* pressure threshold to emulate two finger touch (for Alps) */ 114 int emulate_twofinger_w; /* Finger width threshold to emulate two finger touch */ 115 int scroll_dist_vert; /* Scrolling distance in absolute coordinates */ 116 int scroll_dist_horiz; /* Scrolling distance in absolute coordinates */ 117 Bool scroll_edge_vert; /* Enable/disable vertical scrolling on right edge */ 118 Bool scroll_edge_horiz; /* Enable/disable horizontal scrolling on left edge */ 119 Bool scroll_edge_corner; /* Enable/disable continuous edge scrolling when in the corner */ 120 Bool scroll_twofinger_vert; /* Enable/disable vertical two-finger scrolling */ 121 Bool scroll_twofinger_horiz; /* Enable/disable horizontal two-finger scrolling */ 122 double min_speed, max_speed, accl; /* movement parameters */ 123 double trackstick_speed; /* trackstick mode speed */ 124 int edge_motion_min_z; /* finger pressure at which minimum edge motion speed is set */ 125 int edge_motion_max_z; /* finger pressure at which maximum edge motion speed is set */ 126 int edge_motion_min_speed; /* slowest setting for edge motion speed */ 127 int edge_motion_max_speed; /* fastest setting for edge motion speed */ 128 Bool edge_motion_use_always; /* If false, edge motion is used only when dragging */ 129 130 Bool updown_button_scrolling; /* Up/Down-Button scrolling or middle/double-click */ 131 Bool leftright_button_scrolling; /* Left/right-button scrolling, or two lots of middle button */ 132 Bool updown_button_repeat; /* If up/down button being used to scroll, auto-repeat?*/ 133 Bool leftright_button_repeat; /* If left/right button being used to scroll, auto-repeat? */ 134 int scroll_button_repeat; /* time, in milliseconds, between scroll events being 135 * sent when holding down scroll buttons */ 136 int touchpad_off; /* Switches the touchpad off 137 * 0 : Not off 138 * 1 : Off 139 * 2 : Only tapping and scrolling off 140 */ 141 Bool locked_drags; /* Enable locked drags */ 142 int locked_drag_time; /* timeout for locked drags */ 143 int tap_action[MAX_TAP]; /* Button to report on tap events */ 144 int click_action[MAX_CLICK]; /* Button to report on click with fingers */ 145 Bool circular_scrolling; /* Enable circular scrolling */ 146 double scroll_dist_circ; /* Scrolling angle radians */ 147 int circular_trigger; /* Trigger area for circular scrolling */ 148 Bool circular_pad; /* Edge has an oval or circular shape */ 149 Bool palm_detect; /* Enable Palm Detection */ 150 int palm_min_width; /* Palm detection width */ 151 int palm_min_z; /* Palm detection depth */ 152 double coasting_speed; /* Coasting threshold scrolling speed */ 153 double coasting_friction; /* Number of scrolls per second per second to change coasting speed */ 154 int press_motion_min_z; /* finger pressure at which minimum pressure motion factor is applied */ 155 int press_motion_max_z; /* finger pressure at which maximum pressure motion factor is applied */ 156 double press_motion_min_factor; /* factor applied on speed when finger pressure is at minimum */ 157 double press_motion_max_factor; /* factor applied on speed when finger pressure is at minimum */ 158 Bool grab_event_device; /* grab event device for exclusive use? */ 159 Bool tap_and_drag_gesture; /* Switches the tap-and-drag gesture on/off */ 160 unsigned int resolution_horiz; /* horizontal resolution of touchpad in units/mm */ 161 unsigned int resolution_vert; /* vertical resolution of touchpad in units/mm */ 162 int area_left_edge, area_right_edge, area_top_edge, area_bottom_edge; /* area coordinates absolute */ 163 int hyst_x, hyst_y; /* x and y width of hysteresis box */ 164} SynapticsParameters; 165 166 167typedef struct _SynapticsPrivateRec 168{ 169 SynapticsParameters synpara; /* Default parameter settings, read from 170 the X config file */ 171 SynapticsSHM *synshm; /* Current parameter settings. Will point to 172 shared memory if shm_config is true */ 173 struct SynapticsProtocolOperations* proto_ops; 174 void *proto_data; /* protocol-specific data */ 175 176 struct SynapticsHwState hwState; 177 178 Bool shm_config; /* True when shared memory area allocated */ 179 180 OsTimerPtr timer; /* for up/down-button repeat, tap processing, etc */ 181 182 struct CommData comm; 183 184 Bool absolute_events; /* post absolute motion events instead of relative */ 185 SynapticsMoveHistRec move_hist[SYNAPTICS_MOVE_HISTORY]; /* movement history */ 186 int hist_index; /* Last added entry in move_hist[] */ 187 int hyst_center_x; /* center x of hysteresis*/ 188 int hyst_center_y; /* center y of hysteresis*/ 189 int scroll_y; /* last y-scroll position */ 190 int scroll_x; /* last x-scroll position */ 191 double scroll_a; /* last angle-scroll position */ 192 int count_packet_finger; /* packet counter with finger on the touchpad */ 193 int button_delay_millis; /* button delay for 3rd button emulation */ 194 Bool prev_up; /* Previous up button value, for double click emulation */ 195 enum FingerState finger_state; /* previous finger state */ 196 197 enum TapState tap_state; /* State of tap processing */ 198 int tap_max_fingers; /* Max number of fingers seen since entering start state */ 199 int tap_button; /* Which button started the tap processing */ 200 enum TapButtonState tap_button_state; /* Current tap action */ 201 SynapticsMoveHistRec touch_on; /* data when the touchpad is touched/released */ 202 203 enum MovingState moving_state; /* previous moving state */ 204 Bool vert_scroll_edge_on; /* Keeps track of currently active scroll modes */ 205 Bool horiz_scroll_edge_on; /* Keeps track of currently active scroll modes */ 206 Bool vert_scroll_twofinger_on; /* Keeps track of currently active scroll modes */ 207 Bool horiz_scroll_twofinger_on; /* Keeps track of currently active scroll modes */ 208 Bool circ_scroll_on; /* Keeps track of currently active scroll modes */ 209 Bool circ_scroll_vert; /* True: Generate vertical scroll events 210 False: Generate horizontal events */ 211 int trackstick_neutral_x; /* neutral x position for trackstick mode */ 212 int trackstick_neutral_y; /* neutral y position for trackstick mode */ 213 double autoscroll_xspd; /* Horizontal coasting speed */ 214 double autoscroll_yspd; /* Vertical coasting speed */ 215 double autoscroll_x; /* Accumulated horizontal coasting scroll */ 216 double autoscroll_y; /* Accumulated vertical coasting scroll */ 217 int scroll_packet_count; /* Scroll duration */ 218 double frac_x, frac_y; /* absolute -> relative fraction */ 219 enum MidButtonEmulation mid_emu_state; /* emulated 3rd button */ 220 int repeatButtons; /* buttons for repeat */ 221 int nextRepeat; /* Time when to trigger next auto repeat event */ 222 int lastButtons; /* last state of the buttons */ 223 int palm; /* Set to true when palm detected, reset to false when 224 palm/finger contact disappears */ 225 int prev_z; /* previous z value, for palm detection */ 226 int prevFingers; /* previous numFingers, for transition detection */ 227 int avg_width; /* weighted average of previous fingerWidth values */ 228 double horiz_coeff; /* normalization factor for x coordintes */ 229 double vert_coeff; /* normalization factor for y coordintes */ 230 231 int minx, maxx, miny, maxy; /* min/max dimensions as detected */ 232 int minp, maxp, minw, maxw; /* min/max pressure and finger width as detected */ 233 int resx, resy; /* resolution of coordinates as detected in units/mm */ 234 Bool has_left; /* left button detected for this device */ 235 Bool has_right; /* right button detected for this device */ 236 Bool has_middle; /* middle button detected for this device */ 237 Bool has_double; /* double click detected for this device */ 238 Bool has_triple; /* triple click detected for this device */ 239 Bool has_pressure; /* device reports pressure */ 240 Bool has_width; /* device reports finger width */ 241 Bool has_scrollbuttons; /* device has physical scrollbuttons */ 242 243 enum TouchpadModel model; /* The detected model */ 244} SynapticsPrivate; 245 246 247extern void SynapticsDefaultDimensions(InputInfoPtr pInfo); 248 249#endif /* _SYNAPTICSSTR_H_ */ 250