|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Gesture helper implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "GenericSimpleGesture.h" |
|
19 #include "unknowngesturerecogniser.h" |
|
20 #include "rt_uievent.h" |
|
21 #include "filelogger.h" |
|
22 |
|
23 using namespace stmGesture ; |
|
24 |
|
25 CUnknownGestureRecogniser::CUnknownGestureRecogniser(MGestureListener* aListener) : |
|
26 CGestureRecogniser(aListener) |
|
27 { |
|
28 } |
|
29 |
|
30 CUnknownGestureRecogniser* CUnknownGestureRecogniser::NewL(MGestureListener* aListener) |
|
31 { |
|
32 CUnknownGestureRecogniser* self = new (ELeave) CUnknownGestureRecogniser(aListener) ; |
|
33 return self; |
|
34 } |
|
35 |
|
36 CUnknownGestureRecogniser::~CUnknownGestureRecogniser() |
|
37 { |
|
38 } |
|
39 |
|
40 /*! |
|
41 * recognise the long press; basically it is just the EHold UI event |
|
42 */ |
|
43 TGestureRecognitionState CUnknownGestureRecogniser::recognise(int numOfActiveStreams, |
|
44 MGestureEngineIf* pge) |
|
45 { |
|
46 TGestureRecognitionState state = ENotMyGesture; |
|
47 // Check if we are enabled or not |
|
48 if (!m_gestureEnabled) return state ; |
|
49 |
|
50 |
|
51 // Look at the events to see if it looks like long press with one pointer |
|
52 if (numOfActiveStreams == 1) |
|
53 { |
|
54 // Then look at the event stream, it has to be EHold |
|
55 const stmUiEventEngine::MUiEvent* puie = pge->getUiEvents(0); |
|
56 int countOfEvents = puie->countOfEvents(); |
|
57 stmUiEventEngine::TUiEventCode eventCode = puie->Code(); |
|
58 |
|
59 if (m_loggingenabled) |
|
60 { |
|
61 LOGARG("CUnknownGestureRecogniser: %d num %d code %d", eventCode, countOfEvents, eventCode); |
|
62 } |
|
63 if (puie->Target() == m_powner && eventCode == stmUiEventEngine::ERelease) // The last one is ERelease |
|
64 { |
|
65 const TPoint& currentXY = puie->CurrentXY() ; |
|
66 if (m_loggingenabled) |
|
67 { |
|
68 LOGARG("CUnknownGestureRecogniser: (%d, %d) ", currentXY.iX, currentXY.iY) ; |
|
69 } |
|
70 state = EGestureActive ; |
|
71 // issue the gesture |
|
72 stmGesture::TGenericSimpleGesture pgest(KUid, currentXY, 0, puie) ; |
|
73 // Call the listener to inform that a gesture has occurred... |
|
74 m_listener->gestureEnter(pgest) ; |
|
75 } |
|
76 } |
|
77 return state; |
|
78 } |
|
79 |
|
80 void CUnknownGestureRecogniser::release(MGestureEngineIf* /*ge*/) |
|
81 { |
|
82 if (m_loggingenabled) |
|
83 { |
|
84 LOGARG("CUnknownGestureRecogniser: 0x%x release", this); |
|
85 } |
|
86 } |
|
87 |