-#ifdef _F_SUPPORT_BEZEL_FLICK_
-void
-GestureBezelRecognize(int type, InternalEvent *ev, DeviceIntPtr device)
-{
- static OsTimerPtr bezel_finger_timer = NULL;
-
- BezelFlickStatusPtr pBezel = &g_pGesture->bezel;
- int direction = 0;
- int distance;
- double angle;
- static Time base_time = 0;
- int idx = -1;
- int i;
- static int px=-1, py=-1;
- static int mx=-1, my=-1;
- static int rx=-1, ry=-1;
- static int event_count=0;
-
- if(g_pGesture->enqueue_fulled == 1)
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "EQ Event is full.... palm recognize drop..\n");
-#endif//__BEZEL_DEBUG__
- goto bezel_failed;
- }
-
- if( (PROPAGATE_EVENTS == g_pGesture->ehtype) || (device->id != g_pGesture->first_fingerid) )
- return;
-
- for( i = 0 ; i < g_pGesture->num_mt_devices ; i++ )
- {
- if( device->id == g_pGesture->mt_devices[i]->id )
- {
- idx = i;
- break;
- }
- }
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[type: %d][g_pGesture->num_pressed=%d, x,y(%d, %d) ]\n", type, g_pGesture->num_pressed, ev->device_event.root_x, ev->device_event.root_x);
- XDBG_DEBUG(MGEST, "[filter_mask: 0x%x, bezel_filter_mask: 0x%x, palm_filter_mask: 0x%x\n", g_pGesture->filter_mask, g_pGesture->bezel_filter_mask, g_pGesture->palm_filter_mask);
-#endif//__BEZEL_DEBUG__
-
- if (idx < 0)
- return;
- if(g_pGesture->recognized_gesture || g_pGesture->recognized_palm)
- goto bezel_failed;
- if(g_pGesture->num_pressed > 1)
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "Not single finger g_pGesture->num_pressed: %d\n", g_pGesture->num_pressed);
-#endif//__BEZEL_DEBUG__
- goto bezel_failed;
- }
- if(pBezel->is_active == BEZEL_END)
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "Bezel state is END pBezel->is_active: %d\n", pBezel->is_active);
- XDBG_DEBUG(MGEST, "[filter_mask: 0x%x, bezel_filter_mask: 0x%x, palm_filter_mask: 0x%x\n", g_pGesture->filter_mask, g_pGesture->bezel_filter_mask, g_pGesture->palm_filter_mask);
-#endif//__BEZEL_DEBUG__
- goto bezel_failed;
- }
-
- switch(type)
- {
- case ET_ButtonPress:
- base_time = GetTimeInMillis();
- px = ev->device_event.root_x;
- py = ev->device_event.root_y;
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[P] pBezel->is_active: %d, g_pGesture->num_pressed: %d, idx: %d\n", pBezel->is_active, g_pGesture->num_pressed, idx);
- XDBG_DEBUG(MGEST, "[P] g_pGesture->fingers[%d].p: (%d, %d)\n", idx, px,py);
-#endif//__BEZEL_DEBUG__
- if( (pBezel->is_active == BEZEL_ON) && ((g_pGesture->num_pressed == 1) && (idx == 0)) )
- {
- if( ( px < pBezel->top_left.width) && ( py < pBezel->top_left.height) )
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[P] top_left\n");
-#endif//__BEZEL_DEBUG__
- pBezel->is_active = BEZEL_START;
- pBezel->bezelStatus = BEZEL_TOP_LEFT;
- }
- else if( (px > (720 - pBezel->top_right.width)) && ( py < pBezel->top_right.height) )
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[P] top_right\n");
-#endif//__BEZEL_DEBUG__
- pBezel->is_active = BEZEL_START;
- pBezel->bezelStatus = BEZEL_TOP_RIGHT;
- }
- else if( (px < pBezel->bottom_left.width) && ( py > (1280 - pBezel->bottom_left.height)) )
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[P] bottom_left\n");
-#endif//__BEZEL_DEBUG__
- pBezel->is_active = BEZEL_START;
- pBezel->bezelStatus = BEZEL_BOTTOM_LEFT;
- }
- else if( (px > (720 - pBezel->bottom_right.width)) && ( py > (1280 - pBezel->bottom_right.height)) )
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[P] bottom_right\n");
-#endif//__BEZEL_DEBUG__
- pBezel->is_active = BEZEL_START;
- pBezel->bezelStatus = BEZEL_BOTTOM_RIGHT;
- }
- else
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[P] None\n");
-#endif//__BEZEL_DEBUG__
- pBezel->bezelStatus = NO_BEZEL;
- goto bezel_failed;
- }
- }
- if(pBezel->is_active == BEZEL_START)
- {
- bezel_finger_timer = TimerSet(bezel_finger_timer, 0, 500, GestureBezelSingleFingerTimerHandler, NULL);
- }
- else
- {
- TimerCancel(bezel_finger_timer);
- }
- break;
- case ET_Motion:
- if(px <0 || py < 0)
- return;
- mx = ev->device_event.root_x;
- my = ev->device_event.root_y;
- event_count++;
- if( (g_pGesture->bezel.bezel_angle_moving_check) && (event_count >= 10))
- {
- angle = get_angle(px, py, mx, my);
- event_count = 0;
- if(!GestureBezelAngleRecognize(pBezel->bezelStatus, pBezel->flick_distance, angle))
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[M] moving limit!\n");
-#endif//__BEZEL_DEBUG__
- TimerCancel(bezel_finger_timer);
- goto bezel_failed;
- }
- }
- break;
- case ET_ButtonRelease:
- rx = ev->device_event.root_x;
- ry = ev->device_event.root_y;
- if( (g_pGesture->num_pressed == 0) && (g_pGesture->inc_num_pressed == 1) && (pBezel->is_active == BEZEL_START) )
- {
- angle = get_angle(px, py, rx, ry);
- distance = get_distance(px, py, rx, ry);
- Time duration = GetTimeInMillis() - base_time;
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[R] bezelStatus: %d, distance: %d, angle: %lf\n", pBezel->bezelStatus, distance, angle);
-#endif//__BEZEL_DEBUG__
- int res = GestureBezelAngleRecognize(pBezel->bezelStatus, distance, angle);
- if(res)
- {
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[R] Bezel Success\n");
-#endif//__BEZEL_DEBUG__
- pBezel->is_active = BEZEL_DONE;
- g_pGesture->filter_mask = GESTURE_FILTER_MASK_ALL;
- g_pGesture->palm_filter_mask = GESTURE_PALM_FILTER_MASK_ALL;
- TimerCancel(bezel_finger_timer);
-
- if( (0.0 < angle) && (angle < RAD_90DEG))
- direction = FLICK_NORTHEASTWARD;
- else if(angle < RAD_180DEG)
- direction = FLICK_NORTHWESTWARD;
-
- if( GestureHasFingerEventMask(GestureNotifyFlick, 1) )
- GestureHandleGesture_Flick(1, distance, duration, direction);
- goto bezel_cleanup;
- }
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[R] Bezel failed\n");
-#endif//__BEZEL_DEBUG__
- goto bezel_failed;
- }
- break;
- }
- return;
-bezel_failed:
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[F] Bezel failed\n");
-#endif//__BEZEL_DEBUG__
- pBezel->is_active = BEZEL_END;
- g_pGesture->bezel_filter_mask |= BezelFlickFilterMask;
- goto bezel_cleanup;
- return;
-bezel_cleanup:
-#ifdef __BEZEL_DEBUG__
- XDBG_DEBUG(MGEST, "[F] Bezel cleanup\n");
-#endif//__BEZEL_DEBUG__
- TimerCancel(bezel_finger_timer);
- if( ERROR_INVALPTR == GestureFlushOrDrop() )
- {
- GestureControl(g_pGesture->this_device, DEVICE_OFF);
- }
- bezel_finger_timer = NULL;
- base_time = 0;
- px=py=mx=my=rx=ry=-1;
- event_count = 0;
-}
-#endif
-