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>
11 * Anastasia Lyupa <a.lyupa@samsung.com>
13 * This library is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU Lesser General Public License as published by the
15 * Free Software Foundation; either version 2.1 of the License, or (at your option)
18 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21 * License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library; if not, write to the Free Software Foundation, Inc., 51
25 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * - Samsung RnD Institute Russia
35 #include "probeinfo.h"
36 #include "osp_probe.h"
37 #include "dacollection.h"
42 #define PACK_GESTURE_EVENT(_GESTURETYPE, _X, _Y, _INFO1, _INFO2, _ARGDETECTOR) \
45 setProbePoint(&probeInfo); \
46 PREPARE_LOCAL_BUF(); \
47 PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT, LC_UIEVENT, "p", _ARGDETECTOR); \
48 PACK_COMMON_END(0, 0, 0); \
49 sprintf(info1_str, "%d", _INFO1); \
50 PACK_UIEVENT(_EVENT_GESTURE, _GESTURETYPE, _X, _Y, info1_str, _INFO2); \
54 GestureEventListener GestureEventListener::rInstance;
56 GestureEventListener::GestureEventListener()
61 GestureEventListener::~GestureEventListener()
66 void GestureEventListener::OnCustomGestureCanceled (TouchGestureDetector &gestureDetector)
68 probeInfo_t probeInfo;
70 if(isOptionEnabled(OPT_EVENT))
73 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
78 void GestureEventListener::OnCustomGestureChanged (TouchGestureDetector &gestureDetector)
80 probeInfo_t probeInfo;
82 if(isOptionEnabled(OPT_EVENT))
85 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
90 void GestureEventListener::OnCustomGestureFinished (TouchGestureDetector &gestureDetector)
92 probeInfo_t probeInfo;
94 if(isOptionEnabled(OPT_EVENT))
97 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
102 void GestureEventListener::OnCustomGestureStarted (TouchGestureDetector &gestureDetector)
104 probeInfo_t probeInfo;
106 if(isOptionEnabled(OPT_EVENT))
109 PACK_GESTURE_EVENT(_GESTURE_CUSTOM, 0, 0, 0, 0, &gestureDetector);
114 void GestureEventListener::OnFlickGestureCanceled (TouchFlickGestureDetector &gestureDetector)
116 probeInfo_t probeInfo;
118 if(isOptionEnabled(OPT_EVENT))
122 int x = 0, y = 0, dur = 0;
123 FlickDirection direction = FLICK_DIRECTION_NONE;
125 gestureDetector.GetDistance(x, y);
126 dur = gestureDetector.GetDuration();
127 direction = gestureDetector.GetDirection();
128 PACK_GESTURE_EVENT(_GESTURE_FLICK, x, y, dur, (int)direction, &gestureDetector);
134 void GestureEventListener::OnFlickGestureDetected (TouchFlickGestureDetector &gestureDetector)
136 probeInfo_t probeInfo;
138 if(isOptionEnabled(OPT_EVENT))
142 int x = 0, y = 0, dur = 0;
143 FlickDirection direction = FLICK_DIRECTION_NONE;
145 gestureDetector.GetDistance(x, y);
146 dur = gestureDetector.GetDuration();
147 direction = gestureDetector.GetDirection();
148 PACK_GESTURE_EVENT(_GESTURE_FLICK, x, y, dur, (int)direction, &gestureDetector);
154 void GestureEventListener::OnLongPressGestureCanceled (TouchLongPressGestureDetector &gestureDetector)
156 probeInfo_t probeInfo;
158 if(isOptionEnabled(OPT_EVENT))
162 int moveallow = 0, tcount = 0, dur = 0;
164 moveallow = gestureDetector.GetMoveAllowance();
165 dur = gestureDetector.GetDuration();
166 tcount = gestureDetector.GetTouchCount();
167 PACK_GESTURE_EVENT(_GESTURE_LONGPRESS, moveallow, 0, dur, tcount, &gestureDetector);
173 void GestureEventListener::OnLongPressGestureDetected (TouchLongPressGestureDetector &gestureDetector)
175 probeInfo_t probeInfo;
177 if(isOptionEnabled(OPT_EVENT))
181 int moveallow = 0, tcount = 0, dur = 0;
183 moveallow = gestureDetector.GetMoveAllowance();
184 dur = gestureDetector.GetDuration();
185 tcount = gestureDetector.GetTouchCount();
186 PACK_GESTURE_EVENT(_GESTURE_LONGPRESS, moveallow, 0, dur, tcount, &gestureDetector);
192 void GestureEventListener::OnPanningGestureCanceled (TouchPanningGestureDetector &gestureDetector)
194 probeInfo_t probeInfo;
196 if(isOptionEnabled(OPT_EVENT))
202 tcount = gestureDetector.GetTouchCount();
203 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
209 void GestureEventListener::OnPanningGestureChanged (TouchPanningGestureDetector &gestureDetector)
211 probeInfo_t probeInfo;
213 if(isOptionEnabled(OPT_EVENT))
219 tcount = gestureDetector.GetTouchCount();
220 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
226 void GestureEventListener::OnPanningGestureFinished (TouchPanningGestureDetector &gestureDetector)
228 probeInfo_t probeInfo;
230 if(isOptionEnabled(OPT_EVENT))
236 tcount = gestureDetector.GetTouchCount();
237 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
243 void GestureEventListener::OnPanningGestureStarted (TouchPanningGestureDetector &gestureDetector)
245 probeInfo_t probeInfo;
247 if(isOptionEnabled(OPT_EVENT))
253 tcount = gestureDetector.GetTouchCount();
254 PACK_GESTURE_EVENT(_GESTURE_PANNING, 0, 0, 0, tcount, &gestureDetector);
260 void GestureEventListener::OnPinchGestureCanceled (TouchPinchGestureDetector &gestureDetector)
262 probeInfo_t probeInfo;
264 if(isOptionEnabled(OPT_EVENT))
268 Tizen::Graphics::Point point;
271 point = gestureDetector.GetCenterPoint();
272 scale = gestureDetector.GetScale();
273 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
279 void GestureEventListener::OnPinchGestureChanged (TouchPinchGestureDetector &gestureDetector)
281 probeInfo_t probeInfo;
283 if(isOptionEnabled(OPT_EVENT))
287 Tizen::Graphics::Point point;
290 point = gestureDetector.GetCenterPoint();
291 scale = gestureDetector.GetScale();
292 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
298 void GestureEventListener::OnPinchGestureFinished (TouchPinchGestureDetector &gestureDetector)
300 probeInfo_t probeInfo;
302 if(isOptionEnabled(OPT_EVENT))
306 Tizen::Graphics::Point point;
309 point = gestureDetector.GetCenterPoint();
310 scale = gestureDetector.GetScale();
311 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
317 void GestureEventListener::OnPinchGestureStarted (TouchPinchGestureDetector &gestureDetector)
319 probeInfo_t probeInfo;
321 if(isOptionEnabled(OPT_EVENT))
325 Tizen::Graphics::Point point;
328 point = gestureDetector.GetCenterPoint();
329 scale = gestureDetector.GetScale();
330 PACK_GESTURE_EVENT(_GESTURE_PINCH, point.x, point.y, scale, 0, &gestureDetector);
336 void GestureEventListener::OnRotationGestureCanceled (TouchRotationGestureDetector &gestureDetector)
338 probeInfo_t probeInfo;
340 if(isOptionEnabled(OPT_EVENT))
347 distance = gestureDetector.GetDistance();
348 angle = gestureDetector.GetAngle();
349 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
355 void GestureEventListener::OnRotationGestureChanged (TouchRotationGestureDetector &gestureDetector)
357 probeInfo_t probeInfo;
359 if(isOptionEnabled(OPT_EVENT))
366 distance = gestureDetector.GetDistance();
367 angle = gestureDetector.GetAngle();
368 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
374 void GestureEventListener::OnRotationGestureFinished (TouchRotationGestureDetector &gestureDetector)
376 probeInfo_t probeInfo;
378 if(isOptionEnabled(OPT_EVENT))
385 distance = gestureDetector.GetDistance();
386 angle = gestureDetector.GetAngle();
387 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
393 void GestureEventListener::OnRotationGestureStarted (TouchRotationGestureDetector &gestureDetector)
395 probeInfo_t probeInfo;
397 if(isOptionEnabled(OPT_EVENT))
404 distance = gestureDetector.GetDistance();
405 angle = gestureDetector.GetAngle();
406 PACK_GESTURE_EVENT(_GESTURE_ROTATION, 0, 0, distance, static_cast<int>(angle), &gestureDetector);
412 void GestureEventListener::OnTapGestureCanceled (TouchTapGestureDetector &gestureDetector)
414 probeInfo_t probeInfo;
416 if(isOptionEnabled(OPT_EVENT))
420 int move = 0, tapcount = 0, touchcount = 0, interval = 0;
422 move = gestureDetector.GetMoveAllowance();
423 tapcount = gestureDetector.GetTapCount();
424 interval = gestureDetector.GetTapInterval();
425 touchcount = gestureDetector.GetTouchCount();
426 PACK_GESTURE_EVENT(_GESTURE_TAP, move, tapcount, interval, touchcount, &gestureDetector);
432 void GestureEventListener::OnTapGestureDetected (TouchTapGestureDetector &gestureDetector)
434 probeInfo_t probeInfo;
436 if(isOptionEnabled(OPT_EVENT))
440 int move = 0, tapcount = 0, touchcount = 0, interval = 0;
442 move = gestureDetector.GetMoveAllowance();
443 tapcount = gestureDetector.GetTapCount();
444 interval = gestureDetector.GetTapInterval();
445 touchcount = gestureDetector.GetTouchCount();
446 PACK_GESTURE_EVENT(_GESTURE_TAP, move, tapcount, interval, touchcount, &gestureDetector);
452 GestureEventListener& GestureEventListener::GetInstance()
458 namespace Tizen { namespace Ui {
460 result TouchFlickGestureDetector::AddFlickGestureEventListener(ITouchFlickGestureEventListener& listener)
462 typedef result (TouchFlickGestureDetector::*methodType)(ITouchFlickGestureEventListener& listener);
463 static methodType addflickgestureeventlistenerp;
466 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui25TouchFlickGestureDetector28AddFlickGestureEventListenerERNS0_31ITouchFlickGestureEventListenerE,
467 LIBOSP_UIFW, addflickgestureeventlistenerp);
470 GestureEventListener& mylistener = GestureEventListener::GetInstance();
471 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
473 iret = (this->*addflickgestureeventlistenerp)(static_cast<ITouchFlickGestureEventListener&>(mylistener));
474 if(likely(iret == E_SUCCESS))
480 del_detector_hash(static_cast<void*>(this));
485 return (this->*addflickgestureeventlistenerp)(listener);
488 result TouchLongPressGestureDetector::AddLongPressGestureEventListener(ITouchLongPressGestureEventListener& listener)
490 typedef result (TouchLongPressGestureDetector::*methodType)(ITouchLongPressGestureEventListener& listener);
491 static methodType addlongpressgestureeventlistenerp;
494 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui29TouchLongPressGestureDetector32AddLongPressGestureEventListenerERNS0_35ITouchLongPressGestureEventListenerE,
495 LIBOSP_UIFW, addlongpressgestureeventlistenerp);
498 GestureEventListener& mylistener = GestureEventListener::GetInstance();
499 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
501 iret = (this->*addlongpressgestureeventlistenerp)(static_cast<ITouchLongPressGestureEventListener&>(mylistener));
502 if(likely(iret == E_SUCCESS))
508 del_detector_hash(static_cast<void*>(this));
513 return (this->*addlongpressgestureeventlistenerp)(listener);
516 result TouchPanningGestureDetector::AddPanningGestureEventListener(ITouchPanningGestureEventListener& listener)
518 typedef result (TouchPanningGestureDetector::*methodType)(ITouchPanningGestureEventListener& listener);
519 static methodType addpanninggestureeventlistenerp;
522 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui27TouchPanningGestureDetector30AddPanningGestureEventListenerERNS0_33ITouchPanningGestureEventListenerE,
523 LIBOSP_UIFW, addpanninggestureeventlistenerp);
526 GestureEventListener& mylistener = GestureEventListener::GetInstance();
527 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
529 iret = (this->*addpanninggestureeventlistenerp)(static_cast<ITouchPanningGestureEventListener&>(mylistener));
530 if(likely(iret == E_SUCCESS))
536 del_detector_hash(static_cast<void*>(this));
541 return (this->*addpanninggestureeventlistenerp)(listener);
544 result TouchPinchGestureDetector::AddPinchGestureEventListener(ITouchPinchGestureEventListener& listener)
546 typedef result (TouchPinchGestureDetector::*methodType)(ITouchPinchGestureEventListener& listener);
547 static methodType addpinchgestureeventlistenerp;
550 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui25TouchPinchGestureDetector28AddPinchGestureEventListenerERNS0_31ITouchPinchGestureEventListenerE,
551 LIBOSP_UIFW, addpinchgestureeventlistenerp);
554 GestureEventListener& mylistener = GestureEventListener::GetInstance();
555 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
557 iret = (this->*addpinchgestureeventlistenerp)(static_cast<ITouchPinchGestureEventListener&>(mylistener));
558 if(likely(iret == E_SUCCESS))
564 del_detector_hash(static_cast<void*>(this));
569 return (this->*addpinchgestureeventlistenerp)(listener);
572 result TouchRotationGestureDetector::AddRotationGestureEventListener(ITouchRotationGestureEventListener& listener)
574 typedef result (TouchRotationGestureDetector::*methodType)(ITouchRotationGestureEventListener& listener);
575 static methodType addrotationgestureeventlistenerp;
578 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui28TouchRotationGestureDetector31AddRotationGestureEventListenerERNS0_34ITouchRotationGestureEventListenerE,
579 LIBOSP_UIFW, addrotationgestureeventlistenerp);
582 GestureEventListener& mylistener = GestureEventListener::GetInstance();
583 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
585 iret = (this->*addrotationgestureeventlistenerp)(static_cast<ITouchRotationGestureEventListener&>(mylistener));
586 if(likely(iret == E_SUCCESS))
592 del_detector_hash(static_cast<void*>(this));
597 return (this->*addrotationgestureeventlistenerp)(listener);
600 result TouchTapGestureDetector::AddTapGestureEventListener(ITouchTapGestureEventListener& listener)
602 typedef result (TouchTapGestureDetector::*methodType)(ITouchTapGestureEventListener& listener);
603 static methodType addtapgestureeventlistenerp;
606 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui23TouchTapGestureDetector26AddTapGestureEventListenerERNS0_29ITouchTapGestureEventListenerE,
607 LIBOSP_UIFW, addtapgestureeventlistenerp);
610 GestureEventListener& mylistener = GestureEventListener::GetInstance();
611 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
613 iret = (this->*addtapgestureeventlistenerp)(static_cast<ITouchTapGestureEventListener&>(mylistener));
614 if(likely(iret == E_SUCCESS))
620 del_detector_hash(static_cast<void*>(this));
625 return (this->*addtapgestureeventlistenerp)(listener);
628 result TouchGestureDetector::AddGestureEventListener(ITouchGestureEventListener& listener)
630 typedef result (TouchGestureDetector::*methodType)(ITouchGestureEventListener& listener);
631 static methodType addgestureeventlistenerp;
634 GET_REAL_FUNC_OSP(_ZN5Tizen2Ui20TouchGestureDetector23AddGestureEventListenerERNS0_26ITouchGestureEventListenerE,
635 LIBOSP_UIFW, addgestureeventlistenerp);
638 GestureEventListener& mylistener = GestureEventListener::GetInstance();
639 if(add_detector_hash(static_cast<void*>(this), static_cast<void*>(&mylistener)) <= 0)
641 iret = (this->*addgestureeventlistenerp)(static_cast<ITouchGestureEventListener&>(mylistener));
642 if(likely(iret == E_SUCCESS))
648 del_detector_hash(static_cast<void*>(this));
653 return (this->*addgestureeventlistenerp)(listener);
657 } } // end of namespace