|
1 /* |
|
2 * Copyright (c) 2006-2006 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: CVibraAction class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_VIBRAACTION_H |
|
20 #define C_VIBRAACTION_H |
|
21 |
|
22 #include <hwrmvibra.h> |
|
23 #include <cfactionplugin.h> |
|
24 |
|
25 class MVibraActionObserver; |
|
26 |
|
27 /** |
|
28 * Helper class to start vibra. |
|
29 */ |
|
30 NONSHARABLE_CLASS( TVibraActionInfo ) |
|
31 { |
|
32 public: |
|
33 |
|
34 // Constructor |
|
35 TVibraActionInfo(): |
|
36 iDelay( 0 ), |
|
37 iDuration( 0 ), |
|
38 iIntensity( 0 ), |
|
39 iRepeats( 0 ), |
|
40 iRepeatInterval( 0 ) |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 public: |
|
46 |
|
47 /** Delay before vibra is started */ |
|
48 TInt iDelay; |
|
49 |
|
50 /** Duration of vibra feedback */ |
|
51 TInt iDuration; |
|
52 |
|
53 /** Vibra intensity */ |
|
54 TInt iIntensity; |
|
55 |
|
56 /** How many times vibra is repeated */ |
|
57 TInt iRepeats; |
|
58 |
|
59 /** Vibra repeat interval */ |
|
60 TInt iRepeatInterval; |
|
61 }; |
|
62 |
|
63 /** |
|
64 * Vibra action is a wrapper to vibra client. |
|
65 * Vibra action can be configured via following parameters: |
|
66 * - Delay: Delay when the action notification is received to actually start vibra |
|
67 * - Duration: Vibra duration |
|
68 * - Intensity: Vibra intensity |
|
69 * - Repeats: How many times vibra is repeated with the same parameters |
|
70 * - Repeat interval: Interval between repeats |
|
71 * |
|
72 * @lib - |
|
73 * @since S60 4.0 |
|
74 */ |
|
75 NONSHARABLE_CLASS( CVibraAction ): public CTimer, |
|
76 public MHWRMVibraObserver |
|
77 { |
|
78 public: |
|
79 |
|
80 /** |
|
81 * Two phased constructors. |
|
82 * |
|
83 * @since S60 4.0 |
|
84 * @param |
|
85 * @return CVibraAction* |
|
86 */ |
|
87 static CVibraAction* NewL( MVibraActionObserver& aObserver ); |
|
88 static CVibraAction* NewLC( MVibraActionObserver& aObserver ); |
|
89 |
|
90 // Destructor |
|
91 ~CVibraAction(); |
|
92 |
|
93 public: // New methods |
|
94 |
|
95 /** |
|
96 * Starts vibra. |
|
97 * If there is ongoing vibra it will be automatically cancelled and |
|
98 * new vibra is started. Vibra feedbacks are not cumulative. |
|
99 * |
|
100 * @since S60 4.0 |
|
101 * @param aVibraInfo Vibra information. |
|
102 * @return CCFActionPlugIn::TExecutionTime. |
|
103 */ |
|
104 CCFActionPlugIn::TExecutionTime StartVibraL( |
|
105 const TVibraActionInfo& aVibraInfo ); |
|
106 |
|
107 /** |
|
108 * Stops ongoing vibra. |
|
109 * |
|
110 * @since S60 4.0 |
|
111 * @param None. |
|
112 * @return None. |
|
113 */ |
|
114 void StopVibraL(); |
|
115 |
|
116 private: // From base classes |
|
117 |
|
118 // @see CActive |
|
119 void RunL(); |
|
120 |
|
121 // @see CActive |
|
122 TInt RunError( TInt aError ); |
|
123 |
|
124 // @see CActive |
|
125 void DoCancel(); |
|
126 |
|
127 // @see MHWRMVibraObserver |
|
128 void VibraModeChanged( CHWRMVibra::TVibraModeState aStatus ); |
|
129 |
|
130 // @see MHWRMVibraObserver |
|
131 void VibraStatusChanged( CHWRMVibra::TVibraStatus aStatus ); |
|
132 |
|
133 private: // New methods |
|
134 |
|
135 // Start vibra |
|
136 CCFActionPlugIn::TExecutionTime DoRunVibraL(); |
|
137 |
|
138 // Stop vibra |
|
139 void DoStopVibraL(); |
|
140 |
|
141 // Converts milliseconds to microseconds |
|
142 TTimeIntervalMicroSeconds32 MicroSeconds( TInt aMilliSeconds ) const; |
|
143 |
|
144 private: |
|
145 |
|
146 CVibraAction( MVibraActionObserver& aObserver ); |
|
147 void ConstructL(); |
|
148 |
|
149 private: // Data |
|
150 |
|
151 /** Vibra controller */ |
|
152 CHWRMVibra* iVibra; |
|
153 |
|
154 /** Current vibra mode */ |
|
155 CHWRMVibra::TVibraModeState iVibraModeState; |
|
156 |
|
157 /** Vibra info */ |
|
158 TVibraActionInfo iInfo; |
|
159 |
|
160 /** Repeats info */ |
|
161 TInt iRepeats; |
|
162 |
|
163 /** Observer */ |
|
164 MVibraActionObserver& iObserver; |
|
165 }; |
|
166 |
|
167 #endif |