|
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 "pangesturerecogniser.h" |
|
19 #include "GenericSimpleGesture.h" |
|
20 #include "rt_uievent.h" |
|
21 |
|
22 #include "filelogger.h" |
|
23 |
|
24 using namespace stmGesture ; |
|
25 |
|
26 CPanGestureRecogniser::CPanGestureRecogniser(MGestureListener* aListener) : |
|
27 CGestureRecogniser(aListener) |
|
28 { |
|
29 } |
|
30 |
|
31 CPanGestureRecogniser* CPanGestureRecogniser::NewL(MGestureListener* aListener) |
|
32 { |
|
33 CPanGestureRecogniser* self = new (ELeave) CPanGestureRecogniser(aListener) ; |
|
34 return self; |
|
35 } |
|
36 |
|
37 CPanGestureRecogniser::~CPanGestureRecogniser() |
|
38 { |
|
39 } |
|
40 |
|
41 TGestureRecognitionState CPanGestureRecogniser::recognise(int numOfActiveStreams, |
|
42 MGestureEngineIf* pge) |
|
43 { |
|
44 TGestureRecognitionState state = ENotMyGesture; |
|
45 // Check if we are enabled or not |
|
46 if (!m_gestureEnabled) return state ; |
|
47 |
|
48 // Look at the events to see if it looks like a tap or double tap |
|
49 if (numOfActiveStreams == 1) |
|
50 { |
|
51 // Then look at the event stream, it has to be tap and release |
|
52 const stmUiEventEngine::MUiEvent* puie = pge->getUiEvents(0); |
|
53 if (!puie) return state; |
|
54 int countOfEvents = puie->countOfEvents() ; |
|
55 stmUiEventEngine::TUiEventCode eventCode = puie->Code() ; |
|
56 if (countOfEvents > 1) // do we have more than one event in the stream? |
|
57 { |
|
58 // Then look at the events to see if they are suitable for us |
|
59 // should we check that all of the events are targeted to our window? |
|
60 // currently we only check if the last one is for us and is EMove, then we pan if the speed is OK |
|
61 if (puie->Target() == m_powner && |
|
62 eventCode == stmUiEventEngine::EMove) // The last one is move in our window |
|
63 |
|
64 { |
|
65 if (m_loggingenabled) |
|
66 { |
|
67 LOGARG("CPanGestureRecogniser: Pan: num %d code %d", countOfEvents, eventCode); |
|
68 } |
|
69 float speedX = puie->speedX(); |
|
70 float speedY = puie->speedY(); |
|
71 |
|
72 using stmUiEventEngine::TUiEventSpeed; |
|
73 |
|
74 state = EGestureActive; |
|
75 TUiEventSpeed speedIf(speedX, speedY); |
|
76 // Panning gesture |
|
77 stmGesture::TDirectionalGesture pgest( |
|
78 KUid, |
|
79 puie->CurrentXY(), |
|
80 puie->PreviousXY(), |
|
81 &speedIf, |
|
82 m_loggingenabled); |
|
83 |
|
84 // Call the listener to inform that a Pan has occurred... |
|
85 m_listener->gestureEnter(pgest); |
|
86 } |
|
87 } |
|
88 } |
|
89 return state; |
|
90 } |
|
91 |
|
92 void CPanGestureRecogniser::release(MGestureEngineIf* /*ge*/) |
|
93 { |
|
94 m_listener->gestureExit(KUid) ; |
|
95 } |
|
96 |
|
97 void CPanGestureRecogniser::setPanningSpeedLow(float aSpeed) __SOFTFP |
|
98 { |
|
99 m_panningspeedlow = aSpeed ; |
|
100 } |
|
101 |
|
102 void CPanGestureRecogniser::setPanningSpeedHigh(float aSpeed) __SOFTFP |
|
103 { |
|
104 m_panningspeedhigh = aSpeed ; |
|
105 } |
|
106 |