4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
12 * This library is free software; you can redistribute it and/or modify it under
13 * the terms of the GNU Lesser General Public License as published by the
14 * Free Software Foundation; either version 2.1 of the License, or (at your option)
17 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 * License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this library; if not, write to the Free Software Foundation, Inc., 51
24 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "probeinfo.h"
34 #include "osp_probe.h"
35 #include "dacollection.h"
40 #define PACK_GESTURE_EVENT(_GESTURETYPE, _X, _Y, _INFO1, _INFO2, _ARGDETECTOR) \
43 setProbePoint(&probeInfo); \
44 PREPARE_LOCAL_BUF(); \
45 PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT, LC_UIEVENT, "p", _ARGDETECTOR); \
46 PACK_COMMON_END(0, 0, 0); \
47 sprintf(info1_str, "%d", _INFO1); \
48 PACK_UIEVENT(_EVENT_GESTURE, _GESTURETYPE, _X, _Y, info1_str, _INFO2); \
52 GestureEventListener GestureEventListener::rInstance;
54 GestureEventListener::GestureEventListener()
59 GestureEventListener::~GestureEventListener()
64 void GestureEventListener::OnCustomGestureCanceled (TouchGestureDetector &gestureDetector)
66 probeInfo_t probeInfo;
68 if(isOptionEnabled(OPT_EVENT))
71 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
76 void GestureEventListener::OnCustomGestureChanged (TouchGestureDetector &gestureDetector)
78 probeInfo_t probeInfo;
80 if(isOptionEnabled(OPT_EVENT))
83 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
88 void GestureEventListener::OnCustomGestureFinished (TouchGestureDetector &gestureDetector)
90 probeInfo_t probeInfo;
92 if(isOptionEnabled(OPT_EVENT))
95 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
100 void GestureEventListener::OnCustomGestureStarted (TouchGestureDetector &gestureDetector)
102 probeInfo_t probeInfo;
104 if(isOptionEnabled(OPT_EVENT))
107 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
112 void GestureEventListener::OnFlickGestureCanceled (TouchFlickGestureDetector &gestureDetector)
114 probeInfo_t probeInfo;
116 if(isOptionEnabled(OPT_EVENT))
120 int x = 0, y = 0, dur = 0;
121 FlickDirection direction = FLICK_DIRECTION_NONE;
123 gestureDetector.GetDistance(x, y);
124 dur = gestureDetector.GetDuration();
125 direction = gestureDetector.GetDirection();
126 PACK_GESTURE_EVENT(_GESTURE_FLICK, x, y, dur, (int)direction, &gestureDetector);
132 void GestureEventListener::OnFlickGestureDetected (TouchFlickGestureDetector &gestureDetector)
134 probeInfo_t probeInfo;
136 if(isOptionEnabled(OPT_EVENT))
140 int x = 0, y = 0, dur = 0;
141 FlickDirection direction = FLICK_DIRECTION_NONE;
143 gestureDetector.GetDistance(x, y);
144 dur = gestureDetector.GetDuration();
145 direction = gestureDetector.GetDirection();
146 PACK_GESTURE_EVENT(_GESTURE_FLICK, x, y, dur, (int)direction, &gestureDetector);
152 void GestureEventListener::OnLongPressGestureCanceled (TouchLongPressGestureDetector &gestureDetector)
154 probeInfo_t probeInfo;
156 if(isOptionEnabled(OPT_EVENT))
160 int moveallow = 0, tcount = 0, dur = 0;
162 moveallow = gestureDetector.GetMoveAllowance();
163 dur = gestureDetector.GetDuration();
164 tcount = gestureDetector.GetTouchCount();
165 PACK_GESTURE_EVENT(_GESTURE_LONGPRESS, moveallow, 0, dur, tcount, &gestureDetector);
171 void GestureEventListener::OnLongPressGestureDetected (TouchLongPressGestureDetector &gestureDetector)
173 probeInfo_t probeInfo;
175 if(isOptionEnabled(OPT_EVENT))
179 int moveallow = 0, tcount = 0, dur = 0;
181 moveallow = gestureDetector.GetMoveAllowance();
182 dur = gestureDetector.GetDuration();
183 tcount = gestureDetector.GetTouchCount();
184 PACK_GESTURE_EVENT(_GESTURE_LONGPRESS, moveallow, 0, dur, tcount, &gestureDetector);
190 void GestureEventListener::OnPanningGestureCanceled (TouchPanningGestureDetector &gestureDetector)
192 probeInfo_t probeInfo;
194 if(isOptionEnabled(OPT_EVENT))
200 tcount = gestureDetector.GetTouchCount();
201 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
207 void GestureEventListener::OnPanningGestureChanged (TouchPanningGestureDetector &gestureDetector)
209 probeInfo_t probeInfo;
211 if(isOptionEnabled(OPT_EVENT))
217 tcount = gestureDetector.GetTouchCount();
218 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
224 void GestureEventListener::OnPanningGestureFinished (TouchPanningGestureDetector &gestureDetector)
226 probeInfo_t probeInfo;
228 if(isOptionEnabled(OPT_EVENT))
234 tcount = gestureDetector.GetTouchCount();
235 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
241 void GestureEventListener::OnPanningGestureStarted (TouchPanningGestureDetector &gestureDetector)
243 probeInfo_t probeInfo;
245 if(isOptionEnabled(OPT_EVENT))
251 tcount = gestureDetector.GetTouchCount();
252 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
258 void GestureEventListener::OnPinchGestureCanceled (TouchPinchGestureDetector &gestureDetector)
260 probeInfo_t probeInfo;
262 if(isOptionEnabled(OPT_EVENT))
266 Tizen::Graphics::Point point;
269 point = gestureDetector.GetCenterPoint();
270 scale = gestureDetector.GetScale();
271 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
277 void GestureEventListener::OnPinchGestureChanged (TouchPinchGestureDetector &gestureDetector)
279 probeInfo_t probeInfo;
281 if(isOptionEnabled(OPT_EVENT))
285 Tizen::Graphics::Point point;
288 point = gestureDetector.GetCenterPoint();
289 scale = gestureDetector.GetScale();
290 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
296 void GestureEventListener::OnPinchGestureFinished (TouchPinchGestureDetector &gestureDetector)
298 probeInfo_t probeInfo;
300 if(isOptionEnabled(OPT_EVENT))
304 Tizen::Graphics::Point point;
307 point = gestureDetector.GetCenterPoint();
308 scale = gestureDetector.GetScale();
309 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
315 void GestureEventListener::OnPinchGestureStarted (TouchPinchGestureDetector &gestureDetector)
317 probeInfo_t probeInfo;
319 if(isOptionEnabled(OPT_EVENT))
323 Tizen::Graphics::Point point;
326 point = gestureDetector.GetCenterPoint();
327 scale = gestureDetector.GetScale();
328 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
334 void GestureEventListener::OnRotationGestureCanceled (TouchRotationGestureDetector &gestureDetector)
336 probeInfo_t probeInfo;
338 if(isOptionEnabled(OPT_EVENT))
345 distance = gestureDetector.GetDistance();
346 angle = gestureDetector.GetAngle();
347 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
353 void GestureEventListener::OnRotationGestureChanged (TouchRotationGestureDetector &gestureDetector)
355 probeInfo_t probeInfo;
357 if(isOptionEnabled(OPT_EVENT))
364 distance = gestureDetector.GetDistance();
365 angle = gestureDetector.GetAngle();
366 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
372 void GestureEventListener::OnRotationGestureFinished (TouchRotationGestureDetector &gestureDetector)
374 probeInfo_t probeInfo;
376 if(isOptionEnabled(OPT_EVENT))
383 distance = gestureDetector.GetDistance();
384 angle = gestureDetector.GetAngle();
385 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
391 void GestureEventListener::OnRotationGestureStarted (TouchRotationGestureDetector &gestureDetector)
393 probeInfo_t probeInfo;
395 if(isOptionEnabled(OPT_EVENT))
402 distance = gestureDetector.GetDistance();
403 angle = gestureDetector.GetAngle();
404 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
410 void GestureEventListener::OnTapGestureCanceled (TouchTapGestureDetector &gestureDetector)
412 probeInfo_t probeInfo;
414 if(isOptionEnabled(OPT_EVENT))
418 int move = 0, tapcount = 0, touchcount = 0, interval = 0;
420 move = gestureDetector.GetMoveAllowance();
421 tapcount = gestureDetector.GetTapCount();
422 interval = gestureDetector.GetTapInterval();
423 touchcount = gestureDetector.GetTouchCount();
424 PACK_GESTURE_EVENT(_GESTURE_TAP, move, tapcount, interval, touchcount, &gestureDetector);
430 void GestureEventListener::OnTapGestureDetected (TouchTapGestureDetector &gestureDetector)
432 probeInfo_t probeInfo;
434 if(isOptionEnabled(OPT_EVENT))
438 int move = 0, tapcount = 0, touchcount = 0, interval = 0;
440 move = gestureDetector.GetMoveAllowance();
441 tapcount = gestureDetector.GetTapCount();
442 interval = gestureDetector.GetTapInterval();
443 touchcount = gestureDetector.GetTouchCount();
444 PACK_GESTURE_EVENT(_GESTURE_TAP, move, tapcount, interval, touchcount, &gestureDetector);
450 GestureEventListener& GestureEventListener::GetInstance()
456 namespace Tizen { namespace Ui {
458 result TouchFlickGestureDetector::AddFlickGestureEventListener(ITouchFlickGestureEventListener& listener)
460 typedef result (TouchFlickGestureDetector::*methodType)(ITouchFlickGestureEventListener& listener);
461 static methodType addflickgestureeventlistenerp;
464 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui25TouchFlickGestureDetector28AddFlickGestureEventListenerERNS0_31ITouchFlickGestureEventListenerE,
465 LIBOSP_UIFW, addflickgestureeventlistenerp);
468 GestureEventListener& mylistener = GestureEventListener::GetInstance();
469 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
471 iret = (this->*addflickgestureeventlistenerp)(static_cast<ITouchFlickGestureEventListener&>(mylistener));
472 if(likely(iret == E_SUCCESS))
478 del_detector_hash(static_cast<void*>(this));
483 return (this->*addflickgestureeventlistenerp)(listener);
486 result TouchLongPressGestureDetector::AddLongPressGestureEventListener(ITouchLongPressGestureEventListener& listener)
488 typedef result (TouchLongPressGestureDetector::*methodType)(ITouchLongPressGestureEventListener& listener);
489 static methodType addlongpressgestureeventlistenerp;
492 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui29TouchLongPressGestureDetector32AddLongPressGestureEventListenerERNS0_35ITouchLongPressGestureEventListenerE,
493 LIBOSP_UIFW, addlongpressgestureeventlistenerp);
496 GestureEventListener& mylistener = GestureEventListener::GetInstance();
497 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
499 iret = (this->*addlongpressgestureeventlistenerp)(static_cast<ITouchLongPressGestureEventListener&>(mylistener));
500 if(likely(iret == E_SUCCESS))
506 del_detector_hash(static_cast<void*>(this));
511 return (this->*addlongpressgestureeventlistenerp)(listener);
514 result TouchPanningGestureDetector::AddPanningGestureEventListener(ITouchPanningGestureEventListener& listener)
516 typedef result (TouchPanningGestureDetector::*methodType)(ITouchPanningGestureEventListener& listener);
517 static methodType addpanninggestureeventlistenerp;
520 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui27TouchPanningGestureDetector30AddPanningGestureEventListenerERNS0_33ITouchPanningGestureEventListenerE,
521 LIBOSP_UIFW, addpanninggestureeventlistenerp);
524 GestureEventListener& mylistener = GestureEventListener::GetInstance();
525 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
527 iret = (this->*addpanninggestureeventlistenerp)(static_cast<ITouchPanningGestureEventListener&>(mylistener));
528 if(likely(iret == E_SUCCESS))
534 del_detector_hash(static_cast<void*>(this));
539 return (this->*addpanninggestureeventlistenerp)(listener);
542 result TouchPinchGestureDetector::AddPinchGestureEventListener(ITouchPinchGestureEventListener& listener)
544 typedef result (TouchPinchGestureDetector::*methodType)(ITouchPinchGestureEventListener& listener);
545 static methodType addpinchgestureeventlistenerp;
548 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui25TouchPinchGestureDetector28AddPinchGestureEventListenerERNS0_31ITouchPinchGestureEventListenerE,
549 LIBOSP_UIFW, addpinchgestureeventlistenerp);
552 GestureEventListener& mylistener = GestureEventListener::GetInstance();
553 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
555 iret = (this->*addpinchgestureeventlistenerp)(static_cast<ITouchPinchGestureEventListener&>(mylistener));
556 if(likely(iret == E_SUCCESS))
562 del_detector_hash(static_cast<void*>(this));
567 return (this->*addpinchgestureeventlistenerp)(listener);
570 result TouchRotationGestureDetector::AddRotationGestureEventListener(ITouchRotationGestureEventListener& listener)
572 typedef result (TouchRotationGestureDetector::*methodType)(ITouchRotationGestureEventListener& listener);
573 static methodType addrotationgestureeventlistenerp;
576 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui28TouchRotationGestureDetector31AddRotationGestureEventListenerERNS0_34ITouchRotationGestureEventListenerE,
577 LIBOSP_UIFW, addrotationgestureeventlistenerp);
580 GestureEventListener& mylistener = GestureEventListener::GetInstance();
581 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
583 iret = (this->*addrotationgestureeventlistenerp)(static_cast<ITouchRotationGestureEventListener&>(mylistener));
584 if(likely(iret == E_SUCCESS))
590 del_detector_hash(static_cast<void*>(this));
595 return (this->*addrotationgestureeventlistenerp)(listener);
598 result TouchTapGestureDetector::AddTapGestureEventListener(ITouchTapGestureEventListener& listener)
600 typedef result (TouchTapGestureDetector::*methodType)(ITouchTapGestureEventListener& listener);
601 static methodType addtapgestureeventlistenerp;
604 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui23TouchTapGestureDetector26AddTapGestureEventListenerERNS0_29ITouchTapGestureEventListenerE,
605 LIBOSP_UIFW, addtapgestureeventlistenerp);
608 GestureEventListener& mylistener = GestureEventListener::GetInstance();
609 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
611 iret = (this->*addtapgestureeventlistenerp)(static_cast<ITouchTapGestureEventListener&>(mylistener));
612 if(likely(iret == E_SUCCESS))
618 del_detector_hash(static_cast<void*>(this));
623 return (this->*addtapgestureeventlistenerp)(listener);
626 result TouchGestureDetector::AddGestureEventListener(ITouchGestureEventListener& listener)
628 typedef result (TouchGestureDetector::*methodType)(ITouchGestureEventListener& listener);
629 static methodType addgestureeventlistenerp;
632 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui20TouchGestureDetector23AddGestureEventListenerERNS0_26ITouchGestureEventListenerE,
633 LIBOSP_UIFW, addgestureeventlistenerp);
636 GestureEventListener& mylistener = GestureEventListener::GetInstance();
637 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
639 iret = (this->*addgestureeventlistenerp)(static_cast<ITouchGestureEventListener&>(mylistener));
640 if(likely(iret == E_SUCCESS))
646 del_detector_hash(static_cast<void*>(this));
651 return (this->*addgestureeventlistenerp)(listener);
655 } } // end of namespace