|
1 /* |
|
2 * Copyright (c) 2009 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 "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: Base class for touch gesture recognizers. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "akntouchgesturefwdefs.h" |
|
19 #include "akntouchgesturefwrecognitionengine.h" |
|
20 #include "akntouchgesturefwbaserecognizer.h" |
|
21 #include "akntouchgesturefwsettings.h" |
|
22 |
|
23 using namespace AknTouchGestureFw; |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Checks if the recognizer is currently enabled. |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 TBool CAknTouchGestureFwBaseRecognizer::Enabled() const |
|
30 { |
|
31 return iEnabled; |
|
32 } |
|
33 |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Sets the recognizer enabled or disabled. |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 void CAknTouchGestureFwBaseRecognizer::SetEnabled( TBool aEnable ) |
|
40 { |
|
41 CancelRecognizing(); |
|
42 iEnabled = aEnable; |
|
43 } |
|
44 |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // C++ constructor. |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CAknTouchGestureFwBaseRecognizer::CAknTouchGestureFwBaseRecognizer( |
|
51 CAknTouchGestureFwRecognitionEngine& aEngine ) |
|
52 : iEngine( aEngine ), |
|
53 iEnabled( EFalse ), |
|
54 iGestureTypesForTactile( 0 ), |
|
55 iGestureTypesForAudio( 0 ) |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Sends a gesture event to the observer. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CAknTouchGestureFwBaseRecognizer::SendGestureEventL( |
|
65 MAknTouchGestureFwEvent& aEvent ) |
|
66 { |
|
67 iEngine.NotifyObserverL( aEvent ); |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Returns the framework settings provider. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CAknTouchGestureFwSettings& CAknTouchGestureFwBaseRecognizer::Settings() const |
|
76 { |
|
77 return iEngine.Settings(); |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Returns the value of the drag threshold setting. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 TInt CAknTouchGestureFwBaseRecognizer::DragThreshold() const |
|
86 { |
|
87 return Settings().DragThreshold(); |
|
88 } |
|
89 |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CAknTouchGestureFwBaseRecognizer::ImmediateFeedback |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CAknTouchGestureFwBaseRecognizer::ImmediateFeedback( |
|
96 TTouchLogicalFeedback aLogicalFeedback, |
|
97 TTouchFeedbackType aFeedbackType ) |
|
98 { |
|
99 iEngine.ImmediateFeedback( aLogicalFeedback, aFeedbackType ); |
|
100 } |
|
101 |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CAknTouchGestureFwBaseRecognizer::StartContinuousFeedback |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CAknTouchGestureFwBaseRecognizer::StartContinuousFeedback( |
|
108 TTouchContinuousFeedback aType, |
|
109 TInt aIntensity, |
|
110 TTimeIntervalMicroSeconds32 aTimeout ) |
|
111 { |
|
112 iEngine.StartContinuousFeedback( aType, aIntensity, aTimeout ); |
|
113 } |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CAknTouchGestureFwBaseRecognizer::ModifyContinuousFeedback |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CAknTouchGestureFwBaseRecognizer::ModifyContinuousFeedback( |
|
121 TInt aIntensity ) |
|
122 { |
|
123 iEngine.ModifyContinuousFeedback( aIntensity ); |
|
124 } |
|
125 |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CAknTouchGestureFwBaseRecognizer::StopContinuousFeedback |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CAknTouchGestureFwBaseRecognizer::StopContinuousFeedback() |
|
133 { |
|
134 iEngine.StopContinuousFeedback(); |
|
135 } |
|
136 |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // Sets gesture types which generate tactile and audio feedback. |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CAknTouchGestureFwBaseRecognizer::SetFeedbackForTypesL( |
|
143 TUint aGestureTypesForTactile, |
|
144 TUint aGestureTypesForAudio ) |
|
145 { |
|
146 iGestureTypesForTactile = aGestureTypesForTactile; |
|
147 iGestureTypesForAudio = aGestureTypesForAudio; |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // Returns feedback types of requested gesture type. |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 TTouchFeedbackType CAknTouchGestureFwBaseRecognizer::FeedbackType( |
|
156 TAknTouchGestureFwType aGestureType ) |
|
157 { |
|
158 TUint feedbackType( 0 ); |
|
159 if ( iGestureTypesForTactile & aGestureType ) |
|
160 { |
|
161 feedbackType |= ETouchFeedbackVibra; |
|
162 } |
|
163 if ( iGestureTypesForAudio & aGestureType ) |
|
164 { |
|
165 feedbackType |= ETouchFeedbackAudio; |
|
166 } |
|
167 return TTouchFeedbackType( feedbackType ); |
|
168 } |
|
169 |
|
170 // End of File |