tizen 2.3.1 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_TouchCancel = 31,
239     ET_MTSync = 0x7E,
240     ET_Internal = 0xFF /* First byte */
241 };
242
243 struct _DeviceEvent {
244     unsigned char header; /**< Always ET_Internal */
245     enum EventType type;  /**< One of EventType */
246     int length;           /**< Length in bytes */
247     Time time;            /**< Time in ms */
248     int deviceid;         /**< Device to post this event for */
249     int sourceid;         /**< The physical source device */
250     union {
251         uint32_t button;  /**< Button number (also used in pointer emulating
252                                touch events) */
253         uint32_t key;     /**< Key code */
254     } detail;
255     uint32_t touchid;     /**< Touch ID (client_id) */
256     int16_t root_x;       /**< Pos relative to root window in integral data */
257     float root_x_frac;    /**< Pos relative to root window in frac part */
258     int16_t root_y;       /**< Pos relative to root window in integral part */
259     float root_y_frac;    /**< Pos relative to root window in frac part */
260     uint8_t buttons[(MAX_BUTTONS + 7) / 8];  /**< Button mask */
261     struct {
262         uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
263         uint8_t mode[(MAX_VALUATORS + 7) / 8];/**< Valuator mode (Abs or Rel)*/
264         double data[MAX_VALUATORS];           /**< Valuator data */
265     } valuators;
266     struct {
267         uint32_t base;    /**< XKB base modifiers */
268         uint32_t latched; /**< XKB latched modifiers */
269         uint32_t locked;  /**< XKB locked modifiers */
270         uint32_t effective;/**< XKB effective modifiers */
271     } mods;
272     struct {
273         uint8_t base;    /**< XKB base group */
274         uint8_t latched; /**< XKB latched group */
275         uint8_t locked;  /**< XKB locked group */
276         uint8_t effective;/**< XKB effective group */
277     } group;
278     Window root;      /**< Root window of the event */
279     int corestate;    /**< Core key/button state BEFORE the event */
280     int key_repeat;   /**< Internally-generated key repeat event */
281     uint32_t flags;   /**< Flags to be copied into the generated event */
282 };
283
284 typedef struct _AnyEvent AnyEvent;
285 struct _AnyEvent
286 {
287     unsigned char header; /**< Always ET_Internal */
288     enum EventType type;  /**< One of EventType */
289     int length;           /**< Length in bytes */
290     Time time;            /**< Time in ms */
291     int deviceid;
292     MTSyncType sync;
293     int x;
294     int y;
295 };
296
297 typedef struct _TouchCancelEvent TouchCancelEvent;
298 struct _TouchCancelEvent {
299     unsigned char header; /**< Always ET_Internal */
300     enum EventType type;  /**< ET_TouchOwnership */
301     int length;           /**< Length in bytes */
302     Time time;            /**< Time in ms */
303     int deviceid;         /**< Device to post this event for */
304     int sourceid;         /**< The physical source device */
305     uint32_t resource;    /**< Provoking grab or event selection */
306     uint32_t flags;       /**< Flags to be copied into the generated event */
307 };
308
309
310
311 union _InternalEvent {
312         struct {
313             unsigned char header; /**< Always ET_Internal */
314             enum EventType type;  /**< One of ET_* */
315             int length;           /**< Length in bytes */
316             Time time;            /**< Time in ms. */
317         } any;
318         AnyEvent any_event;
319         DeviceEvent device_event;
320         TouchCancelEvent touch_cancel_event;
321 };
322
323 #define wUseDefault(w,field,def)        ((w)->optional ? (w)->optional->field : def)
324 #define wBoundingShape(w)       wUseDefault(w, boundingShape, NULL)
325 #define wInputShape(w)          wUseDefault(w, inputShape, NULL)
326 #define wBorderWidth(w)         ((int) (w)->borderWidth)
327
328 /* used as NULL-terminated list */
329 typedef struct _DevCursorNode {
330     CursorPtr                   cursor;
331     DeviceIntPtr                dev;
332     struct _DevCursorNode*      next;
333 } DevCursNodeRec, *DevCursNodePtr, *DevCursorList;
334
335 typedef struct _WindowOpt {
336     VisualID            visual;            /* default: same as parent */
337     CursorPtr           cursor;            /* default: window.cursorNone */
338     Colormap            colormap;          /* default: same as parent */
339     Mask                dontPropagateMask; /* default: window.dontPropagate */
340     Mask                otherEventMasks;   /* default: 0 */
341     struct _OtherClients *otherClients;    /* default: NULL */
342     struct _GrabRec     *passiveGrabs;     /* default: NULL */
343     PropertyPtr         userProps;         /* default: NULL */
344     unsigned long       backingBitPlanes;  /* default: ~0L */
345     unsigned long       backingPixel;      /* default: 0 */
346     RegionPtr           boundingShape;     /* default: NULL */
347     RegionPtr           clipShape;         /* default: NULL */
348     RegionPtr           inputShape;        /* default: NULL */
349     struct _OtherInputMasks *inputMasks;   /* default: NULL */
350     DevCursorList       deviceCursors;     /* default: NULL */
351 } WindowOptRec, *WindowOptPtr;
352
353 typedef struct _Window {
354     DrawableRec         drawable;
355     PrivateRec          *devPrivates;
356     WindowPtr           parent;         /* ancestor chain */
357     WindowPtr           nextSib;        /* next lower sibling */
358     WindowPtr           prevSib;        /* next higher sibling */
359     WindowPtr           firstChild;     /* top-most child */
360     WindowPtr           lastChild;      /* bottom-most child */
361     RegionRec           clipList;       /* clipping rectangle for output */
362     RegionRec           borderClip;     /* NotClippedByChildren + border */
363     union _Validate     *valdata;
364     RegionRec           winSize;
365     RegionRec           borderSize;
366     DDXPointRec         origin;         /* position relative to parent */
367     unsigned short      borderWidth;
368     unsigned short      deliverableEvents; /* all masks from all clients */
369     Mask                eventMask;      /* mask from the creating client */
370     PixUnion            background;
371     PixUnion            border;
372     pointer             backStorage;    /* null when BS disabled */
373     WindowOptPtr        optional;
374     unsigned            backgroundState:2; /* None, Relative, Pixel, Pixmap */
375     unsigned            borderIsPixel:1;
376     unsigned            cursorIsNone:1; /* else real cursor (might inherit) */
377     unsigned            backingStore:2;
378     unsigned            saveUnder:1;
379     unsigned            DIXsaveUnder:1;
380     unsigned            bitGravity:4;
381     unsigned            winGravity:4;
382     unsigned            overrideRedirect:1;
383     unsigned            visibility:2;
384     unsigned            mapped:1;
385     unsigned            realized:1;     /* ancestors are all mapped */
386     unsigned            viewable:1;     /* realized && InputOutput */
387     unsigned            dontPropagate:3;/* index into DontPropagateMasks */
388     unsigned            forcedBS:1;     /* system-supplied backingStore */
389     unsigned            redirectDraw:2; /* COMPOSITE rendering redirect */
390     unsigned            forcedBG:1;     /* must have an opaque background */
391 #ifdef ROOTLESS
392     unsigned            rootlessUnhittable:1;   /* doesn't hit-test */
393 #endif
394 } WindowRec;
395
396 typedef struct _IEvent {
397         InternalEvent *event;
398         int screen_num;
399         DeviceIntPtr device;
400 } IEventRec, *IEventPtr;
401
402 enum
403 {
404         BTN_RELEASED,
405         BTN_PRESSED,
406         BTN_MOVING
407 };
408
409 #ifdef _F_SUPPORT_BEZEL_FLICK_
410 enum
411 {
412         BEZEL_NONE,
413         BEZEL_ON,
414         BEZEL_START,
415         BEZEL_DONE,
416         BEZEL_END
417 };
418
419 enum
420 {
421         NO_BEZEL,
422         BEZEL_TOP_LEFT,
423         BEZEL_TOP_RIGHT,
424         BEZEL_BOTTOM_LEFT,
425         BEZEL_BOTTOM_RIGHT
426 };
427 #endif
428
429 #define PressFlagFlick                  0x01//(1 << 0)
430 #define PressFlagPan                            0x02//(1 << 1)
431 #define PressFlagPinchRotation  0x04//(1 << 2)
432 #define PressFlagTap                            0x08//(1 << 3)
433 #define PressFlagTapNHold               0x10//(1 << 4)
434 #define PressFlagHold                   0x20//(1 << 5)
435
436 #define FlickFilterMask                 0x01//(1 << 0)
437 #define PanFilterMask                   0x02//(1 << 1)
438 #define PinchRotationFilterMask 0x04//(1 << 2)
439 #define TapFilterMask                   0x08//(1 << 3)
440 #define TapNHoldFilterMask              0x10//(1 << 4)
441 #define HoldFilterMask                  0x20//(1 << 5)
442
443 #define GESTURE_FILTER_MASK_ALL 0x3f//(FlickFilterMask | PanFilterMask | PinchRotationFilterMask | TapFilterMask |TapNHoldFilterMask | HoldFilterMask)
444
445 #define PalmFlickHorizFilterMask                0x01//(1 << 0)
446 #define PalmFlickVertiFilterMask                0x02//(1 << 1)
447
448 #define GESTURE_PALM_FILTER_MASK_ALL    0x03//(PalmFlickHorizFilterMask | PalmFlickVertiFilterMask)
449
450 #ifdef _F_SUPPORT_BEZEL_FLICK_
451 #define BezelFlickFilterMask            0x01//(1 << 0)
452 #endif
453
454 typedef struct _tagTouchStatus
455 {
456         int status;//One of BTN_RELEASED, BTN_PRESSED and BTN_MOVING
457         uint32_t flags;
458
459         int px;         //press x
460         int py;         //press y
461         int mx;         //motion x
462         int my;         //motion y
463         int rx;         //release x
464         int ry;         //release y
465         Time ptime;     //press time
466         Time mtime;     //motion time
467         Time rtime;     //current/previous release time
468 } TouchStatus;
469
470 typedef struct _tagCurrentTouchStatus
471 {
472         int status;//One of BTN_RELEASED, BTN_PRESSED and BTN_MOVING
473
474         int cx;         //current x
475         int cy;         //current y
476 } CurTouchStatus;
477
478 //palm global
479 #define PALM_MIN_TOUCH_MAJOR                            30
480 #define PALM_MIN_WIDTH_MAJOR                            40
481 #define PALM_MIN_TOUCH_MAJOR_BEZEL                      16
482 #define PALM_MIN_WIDTH_MAJOR_BEZEL                      24
483 #define PALM_BEZEL                                                      33
484
485 //palm flick
486 #define PALM_FLICK_INITIAL_TIMEOUT                      300//ms
487 #define PALM_FLICK_FALSE_TIMEOUT                        900//ms
488 #define PALM_FLICK_DETECT_TIMEOUT                       2000//ms
489 #define PALM_HORIZ_ARRAY_COUNT                          4
490 #define PALM_VERTI_ARRAY_COUNT                          7
491 #define PALM_FLICK_MIN_PALM                                     1
492 #define PALM_FLICK_MIN_BASE_WIDTH                       30
493 #define PALM_FLICK_HORIZ_MAX_BASE_WIDTH         400
494 #define PALM_FLICK_VERTI_MAX_BASE_WIDTH         300
495 #define PALM_FALSE_FLICK_BASE_WIDTH                     8
496 #define PALM_FLICK_TOUCH_MAJOR                          80
497 #define PALM_FLICK_FINGER_MIN_TOUCH_MAJOR       15
498 #define PALM_FLICK_HORIZ_MAX_MOVE_Y                     400
499 #define PALM_FLICK_VERTI_MAX_MOVE_X                     300
500
501 //palm tap
502 #define PALM_MIN_MAJOR                                  200
503 #define PALM_SGL_TAP_TIMEOUT                    200//ms
504 #define PALM_DBL_TAP_TIMEOUT                    300//ms
505 #define PALM_TAP_MIN_DEVIATION                  100
506 #define PALM_TAP_FALSE_DEVIATION                20
507 #define PALM_TAP_FALSE_SIZE                             3
508
509 //palm hold
510 #define PALM_HOLD_TIME_THRESHOLD                        150
511
512 typedef struct _tagPalmTouchInfo
513 {
514         int touch_status;//One of BTN_RELEASED, BTN_PRESSED and BTN_MOVING
515
516         int x;
517         int y;
518         double wmajor;//Value of valuator ABS_MT_WIDTH_MAJOR
519         double tmajor;//Value of valuator ABS_MT_TOUCH_MAJOR
520         double tminor;//Value of valuator ABS_MT_TOUCH_MINOR
521         double tangle;//Value of valuator ABS_MT_ANGLE
522         double tpalm;//Value of valuator ABS_MT_PALM
523 } PalmTouchInfo, *PalmTouchInfoPtr;
524
525 typedef struct _tagQueuedTouchInfo
526 {
527         int devid;
528         int pressed;
529 }QueuedTouchInfo;
530
531 typedef struct _tagPalmStatus
532 {
533         int palmflag;
534         double sum_size;
535         double max_eccen;
536         double max_angle;
537         double max_wmajor;
538         double max_tmajor;
539         double max_tminor;
540         double biggest_tmajor;
541         double biggest_wmajor;
542         double bigger_wmajor;
543         int max_size_idx;
544         int max_touched;
545         int cur_touched;
546         double dispersionX;
547         double deviationX;
548         double dispersionY;
549         double deviationY;
550         int cx;
551         int cy;
552         int max_palm;
553         int single_timer_expired;
554
555         OsTimerPtr palm_single_finger_timer;
556         PalmTouchInfo pti[MAX_MT_DEVICES];
557         QueuedTouchInfo qti[MAX_MT_DEVICES+1];
558         pixman_region16_t area;
559         pixman_region16_t finger_rects[MAX_MT_DEVICES];
560 } PalmStatus, *PalmStatusPtr;
561
562 typedef struct _tagPalmDrvStatus
563 {
564         int enabled;
565         int scrn_width;
566         int scrn_height;
567         unsigned int half_scrn_area_size;
568         int horiz_coord[PALM_HORIZ_ARRAY_COUNT];
569         int verti_coord[PALM_VERTI_ARRAY_COUNT];
570 } PalmMiscInfo, *PalmMiscInfoPtr;
571
572 typedef struct _tagStylusStatus
573 {
574         CurTouchStatus t_status[MAX_MT_DEVICES];
575         int stylus_id;
576         Bool pen_detected;
577         Bool fake_events;
578 } StylusInfo, *StylusInfoPtr;
579
580 #ifdef _F_SUPPORT_BEZEL_FLICK_
581 typedef struct _tagBezelStatus
582 {
583         int width;
584         int height;
585 }BezelStatus, *BezelStatusPtr;
586 typedef struct _tagBezelFlickStatus
587 {
588         int is_active;
589         BezelStatus top_left;
590         BezelStatus top_right;
591         BezelStatus bottom_left;
592         BezelStatus bottom_right;
593         int flick_distance;
594         int bezel_angle_ratio;
595         double min_rad;
596         double max_rad;
597         double min_180_rad;
598         double max_180_rad;
599         int bezel_angle_moving_check;
600         int bezelStatus;
601 }BezelFlickStatus, *BezelFlickStatusPtr;
602 #endif
603
604 typedef struct _GestureDeviceRec
605 {
606         char *device;
607         int version;        /* Driver version */
608         OsTimerPtr device_setting_timer;
609
610         int is_active;
611
612         int screen_width;
613         int screen_height;
614
615         int pinchrotation_time_threshold;
616         double pinchrotation_dist_threshold;
617         double pinchrotation_angle_threshold;
618
619         int singlefinger_threshold;
620         int singletap_threshold;
621         int doubletap_threshold;
622
623         int palm_min_touch_major;
624         int palm_min_width_major;
625         int palm_min_touch_major_bezel;
626         int palm_min_width_major_bezel;
627         int palm_bezel;
628
629         int touchkey_id;
630         MTSyncType mtsync_status;
631         StylusInfo stylusInfo;
632         int palm_rejection_mode;
633         Bool palm_detected;
634         Bool no_palm_events;
635
636         int pass_keycodes[NUM_PASSKEYS];
637
638         WindowPtr pRootWin;
639         Window gestureWin;
640         int num_mt_devices;
641
642         Mask grabMask;
643         Mask eventMask;
644         GestureGrabEventPtr GrabEvents;
645         Mask lastSelectedMask;
646         Window lastSelectedWin;
647
648         EventHandleType ehtype;
649         IEventPtr       EQ;
650         int headEQ;
651         int tailEQ;
652
653         int hold_detector_activate;
654         int has_hold_grabmask;
655         pixman_region16_t chold_area;
656         CurTouchStatus cts[MAX_MT_DEVICES];
657         CurTouchStatus last_touches[MAX_MT_DEVICES];
658         Bool touch_cancel_status;
659         Bool hold_detected;
660
661         PalmStatus palm;
662         PalmMiscInfo palm_misc;
663         int wmajor_idx;
664         int tmajor_idx;
665         int tminor_idx;
666         int tangle_idx;
667         int tpalm_idx;
668         int mt_px_idx;
669         int mt_py_idx;
670         int mt_tool_idx;
671
672         pixman_region16_t area;
673         pixman_region16_t finger_rects[MAX_MT_DEVICES];
674
675         WindowPtr pTempWin;
676         WindowPtr pTempPalmWin;
677         int inc_num_pressed;
678
679         int first_fingerid;
680         int num_pressed;
681         int zoom_enabled;
682         int enqueue_fulled;
683         int tap_repeated;
684         TouchStatus fingers[MAX_MT_DEVICES];
685
686         int event_sum[MAX_MT_DEVICES];
687         uint32_t recognized_gesture;
688         uint32_t filter_mask;
689         uint32_t palm_filter_mask;
690         uint32_t recognized_palm;
691 #ifdef _F_SUPPORT_BEZEL_FLICK_
692         uint32_t bezel_filter_mask;
693         uint32_t bezel_recognized_mask;
694 #endif
695
696         DeviceIntPtr this_device;
697         DeviceIntPtr mt_devices[MAX_MT_DEVICES];
698         DeviceIntPtr master_pointer;
699         DeviceIntPtr xtest_pointer;
700 #ifdef _F_SUPPORT_BEZEL_FLICK_
701         BezelFlickStatus bezel;
702 #endif
703     WindowPtr anr_window;
704
705     int stylus_able;
706     int support_palm;
707 } GestureDeviceRec, *GestureDevicePtr ;
708
709 #endif//_GESTURE_H_