tizen 2.3 release
[adaptation/xorg/driver/xserver-xorg-input-gesture.git] / mobile / src / gesture.h
1 /**************************************************************************
2
3 xserver-xorg-input-gesture
4
5 Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
6
7 Contact: Sung-Jin Park <sj76.park@samsung.com>
8          Sangjin LEE <lsj119@samsung.com>
9
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
20 of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 **************************************************************************/
31
32 #ifndef _GESTURE_H_
33 #define _GESTURE_H_
34
35 #include <xorg/events.h>
36 #include <xorg/gestureext.h>
37 #include <X11/extensions/gestureconst.h>
38 #include <pixman.h>
39
40 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
41 #define HAVE_PROPERTIES 1
42 #endif
43
44 #ifndef ABS_CNT
45 #define ABS_CNT (ABS_MAX+1)
46 #endif
47
48 /**
49  * If there's touch event in pointed window and there's no reponse, we just assume that client looks like deadlock.
50  * In this case, we will make a popup window and terminate application.
51  * To support this feature, we use SUPPORT_ANR_WITH_INPUT_EVENT flag.
52  */
53 #define SUPPORT_ANR_WITH_INPUT_EVENT
54
55 #define NUM_PASSKEYS    20
56
57 #define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
58 #define RootWindow(dev) dev->spriteInfo->sprite->spriteTrace[0]
59 #define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
60 #define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
61
62 #define MAX_MT_DEVICES          10
63 #define GESTURE_EQ_SIZE 256
64
65 #define GESTURE_RECOGNIZER_ONOFF        "GESTURE_RECOGNIZER_ONOFF"
66 #define GESTURE_PALM_REJECTION_MODE     "GESTURE_PALM_REJECTION_MODE"
67 #define CHECK_APPLICATION_NOT_RESPONSE_IN_INPUT_EVENT "_CHECK_APPLICATION_NOT_RESPONSE_IN_INPUT_EVENT_"
68 #define ANR_EVENT_WINDOW "_ANR_EVENT_WINDOW_"
69
70 #define FINGER_WIDTH            10
71 #define FINGER_HEIGHT           10
72 #define FINGER_WIDTH_2T 20
73 #define FINGER_HEIGHT_2T        20
74 #define AREA_CENTER_X(extents)  ((extents)->x1 + (((extents)->x2-(extents)->x1)/2))
75 #define AREA_CENTER_Y(extents)  ((extents)->y1 + (((extents)->y2-(extents)->y1)/2))
76 #define AREA_SIZE(extents)              (ABS((extents)->x2-(extents)->x1)*ABS((extents)->y2-(extents)->y1))
77 #define INBOX(r,x,y)                            ( ((r)->x2 >  x) && ((r)->x1 <= x) && ((r)->y2 >  y) && ((r)->y1 <= y) )
78 #define AREA_HEIGHT(extents)    (((extents)->y2)-((extents)->y1))
79 #define AREA_WIDTH(extents)     (((extents)->x2)-((extents)->x1))
80 #define AREA_DIAG_LEN(extents)  sqrt((AREA_WIDTH(extents)*AREA_WIDTH(extents))+(AREA_HEIGHT(extents)*AREA_HEIGHT(extents)))
81
82 //tap
83 #define TAP_THRESHOLD                   100//in pixel
84 #define SINGLE_TAP_TIMEOUT              100//in msec
85 #define DOUBLE_TAP_TIMEOUT      250//in msec
86
87 //pinch rotation
88 #define ZOOM_THRESHOLD                  0.05f
89 #define ANGLE_THRESHOLD         0.1f
90
91 typedef int XFixed;
92 typedef double XDouble;
93 #define XDoubleToFixed(f)    ((XFixed) ((f) * 65536))
94 #define XFixedToDouble(f)    (((XDouble) (f)) / 65536)
95
96 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
97 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
98 #define ABS(x) (((x) < 0) ? -(x) : (x))
99
100 enum
101 {
102         FLICK_NORTHWARD = 0,
103         FLICK_NORTHEASTWARD,
104         FLICK_EASTWARD,
105         FLICK_SOUTHEASTWARD,
106         FLICK_SOUTHWARD,
107         FLICK_SOUTHWESTWARD,
108         FLICK_WESTWARD,
109         FLICK_NORTHWESTWARD
110 };
111
112 /* Gesture query devices infomation and register handlers
113   * if a device_control function is called using DEVICE_READY */
114 #define DEVICE_READY 11
115
116 #define SCREEN_WIDTH                            720
117 #define SCREEN_HEIGHT                           1280
118
119 #define PAN_AREA_THRESHOLD                      10000//=100pixel * 100pixel
120 #define PAN_MOVE_THRESHOLD                      5//pixel
121 #define PAN_UPDATE_MOVE_THRESHOLD       3//pixel
122 #define PAN_TIME_THRESHOLD                      300//ms
123
124 #define PINCHROTATION_TIME_THRESHOLD            500//ms
125 #define PINCHROTATION_INIT_DIST_THRESHOLD       25.0f
126 #define PINCHROTATION_INIT_ANGLE_THRESHOLD      0.2f
127 #define PINCHROTATION_DIST_THRESHOLD            25.0f
128 #define PINCHROTATION_ANGLE_THRESHOLD           0.2f
129
130 #define HOLD_AREA_THRESHOLD                     2500//=50pixel * 50pixel
131 #define HOLD_MOVE_THRESHOLD                     10//pixel
132 #define HOLD_TIME_THRESHOLD                     500//ms
133
134 #define TAP_AREA_THRESHOLD                      30000//= 300pixel * 100pixel
135 #define TAP_MOVE_THRESHOLD                      300//pixel
136 #define SGL_FINGER_TIME_THRESHOLD       50//ms
137 #define SGL_TAP_TIME_THRESHOLD          200//ms
138 #define DBL_TAP_TIME_THRESHOLD          400//ms
139 #define MAX_TAP_REPEATS                         2
140
141 #define TAPNHOLD_AREA_THRESHOLD                 4900//= 70pixel * 70pixel
142 #define TAPNHOLD_MOVE_THRESHOLD                 50//pixel
143 #define TAPNHOLD_TAP_TIME_THRESHOLD             200//ms
144 #define TAPNHOLD_INTV_TIME_THRESHOLD            200//ms
145 #define TAPNHOLD_HOLD_TIME_THRESHOLD    500//ms
146
147 #define FLICK_AREA_THRESHOLD                    22500//=150pixel * 150pixel
148 #define FLICK_AREA_TIMEOUT                              700//ms
149 #define FLICK_MOVE_THRESHOLD                    100//pixel
150 #define FLICK_MOVE_TIMEOUT                              1000//ms
151
152 #define RAD_90DEG  M_PI_2
153 #define RAD_180DEG M_PI
154 #define RAD_270DEG (M_PI_2 * 3)
155 #define RAD_360DEG (M_PI * 2)
156 #define MIN_RAD (RAD_90DEG / 4)
157 #define MAX_RAD ((RAD_90DEG / 4) * 3)
158 #define RAD_180DEG_MIN (RAD_90DEG + MIN_RAD)
159 #define RAD_180DEG_MAX (RAD_90DEG + MAX_RAD)
160
161 #define rad2degree(r) ((r) * 180/M_PI)
162
163 #define AXIS_LABEL_PROP_ABS_X           "Abs X"
164 #define AXIS_LABEL_PROP_ABS_Y           "Abs Y"
165 #define AXIS_LABEL_PROP_ABS_Z           "Abs Z"
166 #define AXIS_LABEL_PROP_ABS_RX          "Abs Rotary X"
167 #define AXIS_LABEL_PROP_ABS_RY          "Abs Rotary Y"
168 #define AXIS_LABEL_PROP_ABS_RZ          "Abs Rotary Z"
169 #define AXIS_LABEL_PROP_ABS_THROTTLE    "Abs Throttle"
170 #define AXIS_LABEL_PROP_ABS_RUDDER      "Abs Rudder"
171 #define AXIS_LABEL_PROP_ABS_WHEEL       "Abs Wheel"
172 #define AXIS_LABEL_PROP_ABS_GAS         "Abs Gas"
173 #define AXIS_LABEL_PROP_ABS_BRAKE       "Abs Brake"
174 #define AXIS_LABEL_PROP_ABS_HAT0X       "Abs Hat 0 X"
175 #define AXIS_LABEL_PROP_ABS_HAT0Y       "Abs Hat 0 Y"
176 #define AXIS_LABEL_PROP_ABS_HAT1X       "Abs Hat 1 X"
177 #define AXIS_LABEL_PROP_ABS_HAT1Y       "Abs Hat 1 Y"
178 #define AXIS_LABEL_PROP_ABS_HAT2X       "Abs Hat 2 X"
179 #define AXIS_LABEL_PROP_ABS_HAT2Y       "Abs Hat 2 Y"
180 #define AXIS_LABEL_PROP_ABS_HAT3X       "Abs Hat 3 X"
181 #define AXIS_LABEL_PROP_ABS_HAT3Y       "Abs Hat 3 Y"
182 #define AXIS_LABEL_PROP_ABS_PRESSURE    "Abs Pressure"
183 #define AXIS_LABEL_PROP_ABS_DISTANCE    "Abs Distance"
184 #define AXIS_LABEL_PROP_ABS_TILT_X      "Abs Tilt X"
185 #define AXIS_LABEL_PROP_ABS_TILT_Y      "Abs Tilt Y"
186 #define AXIS_LABEL_PROP_ABS_TOOL_WIDTH  "Abs Tool Width"
187 #define AXIS_LABEL_PROP_ABS_VOLUME      "Abs Volume"
188 #define AXIS_LABEL_PROP_ABS_MT_SLOT     "Abs MT Slot"
189 #define AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR "Abs MT Touch Major"
190 #define AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR "Abs MT Touch Minor"
191 #define AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR "Abs MT Width Major"
192 #define AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR "Abs MT Width Minor"
193 #define AXIS_LABEL_PROP_ABS_MT_ORIENTATION "Abs MT Orientation"
194 #define AXIS_LABEL_PROP_ABS_MT_POSITION_X  "Abs MT Position X"
195 #define AXIS_LABEL_PROP_ABS_MT_POSITION_Y  "Abs MT Position Y"
196 #define AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE   "Abs MT Tool Type"
197 #define AXIS_LABEL_PROP_ABS_MT_BLOB_ID     "Abs MT Blob ID"
198 #define AXIS_LABEL_PROP_ABS_MT_TRACKING_ID "Abs MT Tracking ID"
199 #define AXIS_LABEL_PROP_ABS_MT_PRESSURE    "Abs MT Pressure"
200 #define AXIS_LABEL_PROP_ABS_MT_DISTANCE    "Abs MT Distance"
201 #define AXIS_LABEL_PROP_ABS_MT_ANGLE       "Abs MT Angle/MT Component"
202 #define AXIS_LABEL_PROP_ABS_MT_PALM        "Abs MT Palm/MT Sumsize"
203 #define AXIS_LABEL_PROP_ABS_MISC           "Abs Misc"
204
205
206 typedef enum _MTSyncType
207 {
208         MTOUCH_FRAME_SYNC_END,
209         MTOUCH_FRAME_SYNC_BEGIN
210 } MTSyncType;
211
212 typedef enum _EventHandleType
213 {
214         PROPAGATE_EVENTS,
215         KEEP_EVENTS,
216         IGNORE_EVENTS
217 } EventHandleType;
218
219 typedef enum _ErrorStatus
220 {
221         ERROR_NONE,
222         ERROR_ABNORMAL,
223         ERROR_INVALPTR,
224         ERROR_EQFULL,
225         ERROR_ALLOCFAIL
226 } ErrorStatus;
227
228 enum EventType
229 {
230     ET_KeyPress = 2,
231     ET_KeyRelease,
232     ET_ButtonPress,
233     ET_ButtonRelease,
234     ET_Motion,
235     /*
236     ...
237     */
238     ET_MTSync = 0x7E,
239     ET_Internal = 0xFF /* First byte */
240 };
241
242 struct _DeviceEvent {
243     unsigned char header; /**< Always ET_Internal */
244     enum EventType type;  /**< One of EventType */
245     int length;           /**< Length in bytes */
246     Time time;            /**< Time in ms */
247     int deviceid;         /**< Device to post this event for */
248     int sourceid;         /**< The physical source device */
249     union {
250         uint32_t button;  /**< Button number (also used in pointer emulating
251                                touch events) */
252         uint32_t key;     /**< Key code */
253     } detail;
254     uint32_t touchid;     /**< Touch ID (client_id) */
255     int16_t root_x;       /**< Pos relative to root window in integral data */
256     float root_x_frac;    /**< Pos relative to root window in frac part */
257     int16_t root_y;       /**< Pos relative to root window in integral part */
258     float root_y_frac;    /**< Pos relative to root window in frac part */
259     uint8_t buttons[(MAX_BUTTONS + 7) / 8];  /**< Button mask */
260     struct {
261         uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
262         uint8_t mode[(MAX_VALUATORS + 7) / 8];/**< Valuator mode (Abs or Rel)*/
263         double data[MAX_VALUATORS];           /**< Valuator data */
264     } valuators;
265     struct {
266         uint32_t base;    /**< XKB base modifiers */
267         uint32_t latched; /**< XKB latched modifiers */
268         uint32_t locked;  /**< XKB locked modifiers */
269         uint32_t effective;/**< XKB effective modifiers */
270     } mods;
271     struct {
272         uint8_t base;    /**< XKB base group */
273         uint8_t latched; /**< XKB latched group */
274         uint8_t locked;  /**< XKB locked group */
275         uint8_t effective;/**< XKB effective group */
276     } group;
277     Window root;      /**< Root window of the event */
278     int corestate;    /**< Core key/button state BEFORE the event */
279     int key_repeat;   /**< Internally-generated key repeat event */
280     uint32_t flags;   /**< Flags to be copied into the generated event */
281 };
282
283 typedef struct _AnyEvent AnyEvent;
284 struct _AnyEvent
285 {
286     unsigned char header; /**< Always ET_Internal */
287     enum EventType type;  /**< One of EventType */
288     int length;           /**< Length in bytes */
289     Time time;            /**< Time in ms */
290     int deviceid;
291     MTSyncType sync;
292     int x;
293     int y;
294 };
295
296 union _InternalEvent {
297         struct {
298             unsigned char header; /**< Always ET_Internal */
299             enum EventType type;  /**< One of ET_* */
300             int length;           /**< Length in bytes */
301             Time time;            /**< Time in ms. */
302         } any;
303         AnyEvent any_event;
304         DeviceEvent device_event;
305 };
306
307 #define wUseDefault(w,field,def)        ((w)->optional ? (w)->optional->field : def)
308 #define wBoundingShape(w)       wUseDefault(w, boundingShape, NULL)
309 #define wInputShape(w)          wUseDefault(w, inputShape, NULL)
310 #define wBorderWidth(w)         ((int) (w)->borderWidth)
311
312 /* used as NULL-terminated list */
313 typedef struct _DevCursorNode {
314     CursorPtr                   cursor;
315     DeviceIntPtr                dev;
316     struct _DevCursorNode*      next;
317 } DevCursNodeRec, *DevCursNodePtr, *DevCursorList;
318
319 typedef struct _WindowOpt {
320     VisualID            visual;            /* default: same as parent */
321     CursorPtr           cursor;            /* default: window.cursorNone */
322     Colormap            colormap;          /* default: same as parent */
323     Mask                dontPropagateMask; /* default: window.dontPropagate */
324     Mask                otherEventMasks;   /* default: 0 */
325     struct _OtherClients *otherClients;    /* default: NULL */
326     struct _GrabRec     *passiveGrabs;     /* default: NULL */
327     PropertyPtr         userProps;         /* default: NULL */
328     unsigned long       backingBitPlanes;  /* default: ~0L */
329     unsigned long       backingPixel;      /* default: 0 */
330     RegionPtr           boundingShape;     /* default: NULL */
331     RegionPtr           clipShape;         /* default: NULL */
332     RegionPtr           inputShape;        /* default: NULL */
333     struct _OtherInputMasks *inputMasks;   /* default: NULL */
334     DevCursorList       deviceCursors;     /* default: NULL */
335 } WindowOptRec, *WindowOptPtr;
336
337 typedef struct _Window {
338     DrawableRec         drawable;
339     PrivateRec          *devPrivates;
340     WindowPtr           parent;         /* ancestor chain */
341     WindowPtr           nextSib;        /* next lower sibling */
342     WindowPtr           prevSib;        /* next higher sibling */
343     WindowPtr           firstChild;     /* top-most child */
344     WindowPtr           lastChild;      /* bottom-most child */
345     RegionRec           clipList;       /* clipping rectangle for output */
346     RegionRec           borderClip;     /* NotClippedByChildren + border */
347     union _Validate     *valdata;
348     RegionRec           winSize;
349     RegionRec           borderSize;
350     DDXPointRec         origin;         /* position relative to parent */
351     unsigned short      borderWidth;
352     unsigned short      deliverableEvents; /* all masks from all clients */
353     Mask                eventMask;      /* mask from the creating client */
354     PixUnion            background;
355     PixUnion            border;
356     pointer             backStorage;    /* null when BS disabled */
357     WindowOptPtr        optional;
358     unsigned            backgroundState:2; /* None, Relative, Pixel, Pixmap */
359     unsigned            borderIsPixel:1;
360     unsigned            cursorIsNone:1; /* else real cursor (might inherit) */
361     unsigned            backingStore:2;
362     unsigned            saveUnder:1;
363     unsigned            DIXsaveUnder:1;
364     unsigned            bitGravity:4;
365     unsigned            winGravity:4;
366     unsigned            overrideRedirect:1;
367     unsigned            visibility:2;
368     unsigned            mapped:1;
369     unsigned            realized:1;     /* ancestors are all mapped */
370     unsigned            viewable:1;     /* realized && InputOutput */
371     unsigned            dontPropagate:3;/* index into DontPropagateMasks */
372     unsigned            forcedBS:1;     /* system-supplied backingStore */
373     unsigned            redirectDraw:2; /* COMPOSITE rendering redirect */
374     unsigned            forcedBG:1;     /* must have an opaque background */
375 #ifdef ROOTLESS
376     unsigned            rootlessUnhittable:1;   /* doesn't hit-test */
377 #endif
378 } WindowRec;
379
380 typedef struct _IEvent {
381         InternalEvent *event;
382         int screen_num;
383         DeviceIntPtr device;
384 } IEventRec, *IEventPtr;
385
386 enum
387 {
388         BTN_RELEASED,
389         BTN_PRESSED,
390         BTN_MOVING
391 };
392
393 #ifdef _F_SUPPORT_BEZEL_FLICK_
394 enum
395 {
396         BEZEL_NONE,
397         BEZEL_ON,
398         BEZEL_START,
399         BEZEL_DONE,
400         BEZEL_END
401 };
402
403 enum
404 {
405         NO_BEZEL,
406         BEZEL_TOP_LEFT,
407         BEZEL_TOP_RIGHT,
408         BEZEL_BOTTOM_LEFT,
409         BEZEL_BOTTOM_RIGHT
410 };
411 #endif
412
413 #define PressFlagFlick                  0x01//(1 << 0)
414 #define PressFlagPan                            0x02//(1 << 1)
415 #define PressFlagPinchRotation  0x04//(1 << 2)
416 #define PressFlagTap                            0x08//(1 << 3)
417 #define PressFlagTapNHold               0x10//(1 << 4)
418 #define PressFlagHold                   0x20//(1 << 5)
419
420 #define FlickFilterMask                 0x01//(1 << 0)
421 #define PanFilterMask                   0x02//(1 << 1)
422 #define PinchRotationFilterMask 0x04//(1 << 2)
423 #define TapFilterMask                   0x08//(1 << 3)
424 #define TapNHoldFilterMask              0x10//(1 << 4)
425 #define HoldFilterMask                  0x20//(1 << 5)
426
427 #define GESTURE_FILTER_MASK_ALL 0x3f//(FlickFilterMask | PanFilterMask | PinchRotationFilterMask | TapFilterMask |TapNHoldFilterMask | HoldFilterMask)
428
429 #define PalmFlickHorizFilterMask                0x01//(1 << 0)
430 #define PalmFlickVertiFilterMask                0x02//(1 << 1)
431
432 #define GESTURE_PALM_FILTER_MASK_ALL    0x03//(PalmFlickHorizFilterMask | PalmFlickVertiFilterMask)
433
434 #ifdef _F_SUPPORT_BEZEL_FLICK_
435 #define BezelFlickFilterMask            0x01//(1 << 0)
436 #endif
437
438 typedef struct _tagTouchStatus
439 {
440         int status;//One of BTN_RELEASED, BTN_PRESSED and BTN_MOVING
441         uint32_t flags;
442
443         int px;         //press x
444         int py;         //press y
445         int mx;         //motion x
446         int my;         //motion y
447         int rx;         //release x
448         int ry;         //release y
449         Time ptime;     //press time
450         Time mtime;     //motion time
451         Time rtime;     //current/previous release time
452 } TouchStatus;
453
454 typedef struct _tagCurrentTouchStatus
455 {
456         int status;//One of BTN_RELEASED, BTN_PRESSED and BTN_MOVING
457
458         int cx;         //current x
459         int cy;         //current y
460 } CurTouchStatus;
461
462 //palm global
463 #define PALM_MIN_TOUCH_MAJOR                            30
464 #define PALM_MIN_WIDTH_MAJOR                            40
465 #define PALM_MIN_TOUCH_MAJOR_BEZEL                      16
466 #define PALM_MIN_WIDTH_MAJOR_BEZEL                      24
467 #define PALM_BEZEL                                                      33
468
469 //palm flick
470 #define PALM_FLICK_INITIAL_TIMEOUT                      300//ms
471 #define PALM_FLICK_FALSE_TIMEOUT                        900//ms
472 #define PALM_FLICK_DETECT_TIMEOUT                       2000//ms
473 #define PALM_HORIZ_ARRAY_COUNT                          4
474 #define PALM_VERTI_ARRAY_COUNT                          7
475 #define PALM_FLICK_MIN_PALM                                     1
476 #define PALM_FLICK_MIN_BASE_WIDTH                       30
477 #define PALM_FLICK_HORIZ_MAX_BASE_WIDTH         400
478 #define PALM_FLICK_VERTI_MAX_BASE_WIDTH         300
479 #define PALM_FALSE_FLICK_BASE_WIDTH                     8
480 #define PALM_FLICK_TOUCH_MAJOR                          80
481 #define PALM_FLICK_FINGER_MIN_TOUCH_MAJOR       15
482 #define PALM_FLICK_HORIZ_MAX_MOVE_Y                     400
483 #define PALM_FLICK_VERTI_MAX_MOVE_X                     300
484
485 //palm tap
486 #define PALM_MIN_MAJOR                                  200
487 #define PALM_SGL_TAP_TIMEOUT                    200//ms
488 #define PALM_DBL_TAP_TIMEOUT                    300//ms
489 #define PALM_TAP_MIN_DEVIATION                  100
490 #define PALM_TAP_FALSE_DEVIATION                20
491 #define PALM_TAP_FALSE_SIZE                             3
492
493 //palm hold
494 #define PALM_HOLD_TIME_THRESHOLD                        150
495
496 typedef struct _tagPalmTouchInfo
497 {
498         int touch_status;//One of BTN_RELEASED, BTN_PRESSED and BTN_MOVING
499
500         int x;
501         int y;
502         double wmajor;//Value of valuator ABS_MT_WIDTH_MAJOR
503         double tmajor;//Value of valuator ABS_MT_TOUCH_MAJOR
504         double tminor;//Value of valuator ABS_MT_TOUCH_MINOR
505         double tangle;//Value of valuator ABS_MT_ANGLE
506         double tpalm;//Value of valuator ABS_MT_PALM
507 } PalmTouchInfo, *PalmTouchInfoPtr;
508
509 typedef struct _tagQueuedTouchInfo
510 {
511         int devid;
512         int pressed;
513 }QueuedTouchInfo;
514
515 typedef struct _tagPalmStatus
516 {
517         int palmflag;
518         double sum_size;
519         double max_eccen;
520         double max_angle;
521         double max_wmajor;
522         double max_tmajor;
523         double max_tminor;
524         double biggest_tmajor;
525         double biggest_wmajor;
526         double bigger_wmajor;
527         int max_size_idx;
528         int max_touched;
529         int cur_touched;
530         double dispersionX;
531         double deviationX;
532         double dispersionY;
533         double deviationY;
534         int cx;
535         int cy;
536         int max_palm;
537         int single_timer_expired;
538
539         OsTimerPtr palm_single_finger_timer;
540         PalmTouchInfo pti[MAX_MT_DEVICES];
541         QueuedTouchInfo qti[MAX_MT_DEVICES+1];
542         pixman_region16_t area;
543         pixman_region16_t finger_rects[MAX_MT_DEVICES];
544 } PalmStatus, *PalmStatusPtr;
545
546 typedef struct _tagPalmDrvStatus
547 {
548         int enabled;
549         int scrn_width;
550         int scrn_height;
551         unsigned int half_scrn_area_size;
552         int horiz_coord[PALM_HORIZ_ARRAY_COUNT];
553         int verti_coord[PALM_VERTI_ARRAY_COUNT];
554 } PalmMiscInfo, *PalmMiscInfoPtr;
555
556 typedef struct _tagStylusStatus
557 {
558         CurTouchStatus t_status[MAX_MT_DEVICES];
559         int stylus_id;
560         Bool pen_detected;
561         Bool fake_events;
562 } StylusInfo, *StylusInfoPtr;
563
564 #ifdef _F_SUPPORT_BEZEL_FLICK_
565 typedef struct _tagBezelStatus
566 {
567         int width;
568         int height;
569 }BezelStatus, *BezelStatusPtr;
570 typedef struct _tagBezelFlickStatus
571 {
572         int is_active;
573         BezelStatus top_left;
574         BezelStatus top_right;
575         BezelStatus bottom_left;
576         BezelStatus bottom_right;
577         int flick_distance;
578         int bezel_angle_ratio;
579         double min_rad;
580         double max_rad;
581         double min_180_rad;
582         double max_180_rad;
583         int bezel_angle_moving_check;
584         int bezelStatus;
585 }BezelFlickStatus, *BezelFlickStatusPtr;
586 #endif
587
588 typedef struct _GestureDeviceRec
589 {
590         char *device;
591         int version;        /* Driver version */
592         OsTimerPtr device_setting_timer;
593
594         int is_active;
595
596         int screen_width;
597         int screen_height;
598
599         int pinchrotation_time_threshold;
600         double pinchrotation_dist_threshold;
601         double pinchrotation_angle_threshold;
602
603         int singlefinger_threshold;
604         int singletap_threshold;
605         int doubletap_threshold;
606
607         int palm_min_touch_major;
608         int palm_min_width_major;
609         int palm_min_touch_major_bezel;
610         int palm_min_width_major_bezel;
611         int palm_bezel;
612
613         int touchkey_id;
614         MTSyncType mtsync_status;
615         StylusInfo stylusInfo;
616         int palm_rejection_mode;
617         Bool palm_detected;
618         Bool no_palm_events;
619
620         int pass_keycodes[NUM_PASSKEYS];
621
622         WindowPtr pRootWin;
623         Window gestureWin;
624         int num_mt_devices;
625
626         Mask grabMask;
627         Mask eventMask;
628         GestureGrabEventPtr GrabEvents;
629         Mask lastSelectedMask;
630         Window lastSelectedWin;
631
632         EventHandleType ehtype;
633         IEventPtr       EQ;
634         int headEQ;
635         int tailEQ;
636
637         int hold_detector_activate;
638         int has_hold_grabmask;
639         pixman_region16_t chold_area;
640         CurTouchStatus cts[MAX_MT_DEVICES];
641         Bool hold_detected;
642
643         PalmStatus palm;
644         PalmMiscInfo palm_misc;
645         int wmajor_idx;
646         int tmajor_idx;
647         int tminor_idx;
648         int tangle_idx;
649         int tpalm_idx;
650         int mt_px_idx;
651         int mt_py_idx;
652         int mt_tool_idx;
653
654         pixman_region16_t area;
655         pixman_region16_t finger_rects[MAX_MT_DEVICES];
656
657         WindowPtr pTempWin;
658         WindowPtr pTempPalmWin;
659         int inc_num_pressed;
660
661         int first_fingerid;
662         int num_pressed;
663         int zoom_enabled;
664         int enqueue_fulled;
665         int tap_repeated;
666         TouchStatus fingers[MAX_MT_DEVICES];
667
668         int event_sum[MAX_MT_DEVICES];
669         uint32_t recognized_gesture;
670         uint32_t filter_mask;
671         uint32_t palm_filter_mask;
672         uint32_t recognized_palm;
673 #ifdef _F_SUPPORT_BEZEL_FLICK_
674         uint32_t bezel_filter_mask;
675         uint32_t bezel_recognized_mask;
676 #endif
677
678         DeviceIntPtr this_device;
679         DeviceIntPtr mt_devices[MAX_MT_DEVICES];
680         DeviceIntPtr master_pointer;
681         DeviceIntPtr xtest_pointer;
682 #ifdef _F_SUPPORT_BEZEL_FLICK_
683         BezelFlickStatus bezel;
684 #endif
685     WindowPtr anr_window;
686
687     int stylus_able;
688     int support_palm;
689 } GestureDeviceRec, *GestureDevicePtr ;
690
691 #endif//_GESTURE_H_