1 /* |
1 /* |
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: This file contains the header of the |
14 * Description: |
15 * CHWRMVibra class. |
15 * |
16 * |
16 */ |
17 */ |
17 |
18 |
18 |
19 |
19 |
20 #ifndef HWRMVIBRA_H |
20 #ifndef HWRMVIBRA_H |
21 #define HWRMVIBRA_H |
21 #define HWRMVIBRA_H |
22 |
22 |
26 // CONSTANTS |
26 // CONSTANTS |
27 |
27 |
28 /** |
28 /** |
29 * Minimum allowed intensity setting for vibra. When intensity is negative, |
29 * Minimum allowed intensity setting for vibra. When intensity is negative, |
30 * the vibra motor rotates in the negative direction. |
30 * the vibra motor rotates in the negative direction. |
|
31 |
|
32 * |
|
33 * @publishedAll |
|
34 * @released |
31 */ |
35 */ |
32 const TInt KHWRMVibraMinIntensity = -100; |
36 const TInt KHWRMVibraMinIntensity = -100; |
33 |
37 |
34 /** |
38 /** |
35 * Minimum allowed intensity setting for vibra pulse. |
39 * Minimum allowed intensity setting for vibra pulse. |
|
40 * |
|
41 * @publishedAll |
|
42 * @released |
36 */ |
43 */ |
37 const TInt KHWRMVibraMinPulseIntensity = 1; |
44 const TInt KHWRMVibraMinPulseIntensity = 1; |
|
45 |
38 |
46 |
39 /** |
47 /** |
40 * Maximum allowed intensity setting for vibra. When intensity is positive, |
48 * Maximum allowed intensity setting for vibra. When intensity is positive, |
41 * the vibra motor rotates in the positive direction. Value 0 effectively |
49 * the vibra motor rotates in the positive direction. Value 0 effectively |
42 * stops the vibra. |
50 * stops the vibra. |
|
51 |
|
52 * @publishedAll |
|
53 * @released |
43 */ |
54 */ |
44 const TInt KHWRMVibraMaxIntensity = 100; |
55 const TInt KHWRMVibraMaxIntensity = 100; |
45 |
56 |
46 /** |
57 /** |
47 * Maximum allowed duration value in milliseconds. Maximum vibrating time |
58 * Maximum allowed duration value in milliseconds. Maximum vibrating time |
48 * supported by device is declared in KVibraCtrlMaxTime cenrep-key. |
59 * supported by device is declared in KVibraCtrlMaxTime cenrep-key. |
|
60 |
49 * |
61 * |
50 * Note that duration probably has device specific |
62 * Note that duration probably has device specific |
51 * maximum duration that is much lower. |
63 * maximum duration that is much lower. |
|
64 * |
|
65 * @publishedAll |
|
66 * @released |
52 */ |
67 */ |
53 const TInt KHWRMVibraMaxDuration = (KMaxTInt / 1000) - 1; |
68 const TInt KHWRMVibraMaxDuration = (KMaxTInt / 1000) - 1; |
54 |
69 |
55 /** |
70 /** |
56 * KHWRMVibraInfiniteDuration specifies, that vibrating should continue maximum |
71 * KHWRMVibraInfiniteDuration specifies, that vibrating should continue maximum |
57 * vibrating time supported by device if vibrating is not explicitly stopped. |
72 * vibrating time supported by device if vibrating is not explicitly stopped. |
58 * |
73 * |
|
74 * |
|
75 * @publishedAll |
|
76 * @released |
59 */ |
77 */ |
60 const TInt KHWRMVibraInfiniteDuration = 0; |
78 const TInt KHWRMVibraInfiniteDuration = 0; |
61 |
79 |
62 // FORWARD DECLARATIONS |
80 |
63 class MHWRMVibraObserver; |
81 class MHWRMVibraObserver; |
64 class MHWRMVibraFeedbackObserver; |
82 class MHWRMVibraFeedbackObserver; |
65 |
|
66 // CLASS DECLARATIONS |
|
67 |
83 |
68 /** |
84 /** |
69 * The class used to control the device vibra. |
85 * The class used to control the device vibra. |
70 * |
86 * |
71 * HW Resource Manager Vibra API is a library API providing ability to control |
87 * HW Resource Manager Vibra API is a library API providing ability to control |
72 * the device vibra. The API provides also methods to retrieve the current settings |
88 * the device vibra. The API provides also methods to retrieve the current settings |
73 * of the vibration feature in the user profile and the current status of the vibra. |
89 * of the vibration feature in the user profile and the current status of the vibra. |
74 * |
90 * |
75 * The type of HW Resource Manager Vibra API is a synchronous method call meaning |
91 * The type of HW Resource Manager Vibra API is a synchronous method call meaning |
76 * the method call will block the client application. However, e.g. StartVibraL methods do |
92 * the method call will block the client application. The API is meant for all |
77 * return right after device vibration has successfully been started. Callback is intended only |
|
78 * for observing vibra and feedback on/off changes. The API is meant for all |
|
79 * applications which need to control the device vibra. |
93 * applications which need to control the device vibra. |
80 * |
94 * |
81 * The API consist of the classes CHWRMVibra, MHWRMVibraObserver and MHWRMVibraFeedbackObserver. |
95 * The API consist of the classes CHWRMVibra and MHWRMVibraObserver. If the client |
82 * If the client requires up-to-date status information, it should also provide callback pointer |
96 * requires up-to-date status information, it should also provide callback pointer |
83 * of the MHWRMVibraObserver implementing class for the NewL-method and explicitly set feedback observer. |
97 * of the MHWRMVibraObserver implementing class for the NewL-method. |
84 * |
98 * |
85 * Usage: |
99 * Usage: |
86 * |
100 * |
87 * @code |
101 * @code |
88 * #include <HWRMVibra.h> // link against HWRMVibraClient.lib |
102 * #include <hwrmvibra.h> |
89 * |
103 * |
90 * // A CHWRMVibra instance can be created by using NewL() or NewLC() methods. |
104 * // A CHWRMVibra instance can be created by using NewL() or NewLC() methods. |
91 * // Up-to-date status information not required, no callbacks. |
105 * // Up-to-date status information not required, no callbacks. |
92 * CHWRMVibra* vibra = CHWRMVibra::NewL(); |
106 * CHWRMVibra* vibra = CHWRMVibra::NewL(); |
93 * |
107 * |
97 * |
111 * |
98 * // To clean up, delete the created object: |
112 * // To clean up, delete the created object: |
99 * delete vibra; |
113 * delete vibra; |
100 * @endcode |
114 * @endcode |
101 * |
115 * |
102 * @lib HWRMVIBRACLIENT.DLL |
116 * @publishedAll |
103 * @since S60 3.0 |
117 * @released |
104 */ |
118 */ |
105 class CHWRMVibra : public CBase |
119 class CHWRMVibra : public CBase |
106 { |
120 { |
107 public: // enums |
121 public: // enums |
108 /** |
122 /** |
109 * Vibration setting in the user profile. |
123 * Vibration setting in the user profile. |
110 */ |
124 */ |
111 enum TVibraModeState |
125 enum TVibraModeState |
112 { |
126 { |
113 EVibraModeUnknown = 0, ///< Not initialized yet or there is an error condion. |
127 /** |
114 EVibraModeON, ///< Vibration setting in the user profile is on. |
128 Not initialized yet or there is an error condion. |
115 EVibraModeOFF ///< Vibration setting in the user profile is off. |
129 */ |
|
130 EVibraModeUnknown = 0, |
|
131 /** |
|
132 Vibration setting in the user profile is on. |
|
133 */ |
|
134 EVibraModeON, |
|
135 /** |
|
136 Vibration setting in the user profile is off. |
|
137 */ |
|
138 EVibraModeOFF |
116 }; |
139 }; |
117 |
140 |
118 /** |
141 /** |
119 * Status of the vibration feature |
142 * Status of the vibration feature |
120 */ |
143 */ |
121 enum TVibraStatus |
144 enum TVibraStatus |
122 { |
145 { |
123 EVibraStatusUnknown = 0, ///< Vibra is not initialized yet or status is uncertain |
146 /** |
124 ///< because of an error condition. |
147 Vibra is not initialized yet or status is uncertain because of an error condition. |
125 EVibraStatusNotAllowed, ///< Vibra is set off in the user profile or some |
148 */ |
126 ///< application is specifically blocking vibra. |
149 EVibraStatusUnknown = 0, |
127 EVibraStatusStopped, ///< Vibra is stopped. |
150 /** |
128 EVibraStatusOn ///< Vibra is on. |
151 Vibra is set off in the user profile or some application is specifically blocking vibra. |
|
152 */ |
|
153 EVibraStatusNotAllowed, |
|
154 /** |
|
155 Vibra is stopped. |
|
156 */ |
|
157 EVibraStatusStopped, |
|
158 /** |
|
159 Vibra is on. |
|
160 */ |
|
161 EVibraStatusOn |
129 }; |
162 }; |
130 |
|
131 /** |
163 /** |
132 * Tactile feedback vibration setting in the user profile. |
164 * Tactile feedback vibration setting in the user profile. |
133 */ |
165 */ |
134 enum TVibraFeedbackModeState |
166 enum TVibraFeedbackModeState |
135 { |
167 { |
136 EVibraFeedbackModeUnknown = 0, ///< Not initialized yet or there is an error condion. |
168 EVibraFeedbackModeUnknown = 0, ///< Not initialized yet or there is an error condion. |
137 EVibraFeedbackModeON, ///< Feedback vibration setting in the user profile is on. |
169 EVibraFeedbackModeON, ///< Feedback vibration setting in the user profile is on. |
138 EVibraFeedbackModeOFF ///< Feedback vibration setting in the user profile is off. |
170 EVibraFeedbackModeOFF ///< Feedback vibration setting in the user profile is off. |
139 }; |
171 }; |
140 |
172 public: |
141 public: // Constructors |
|
142 |
|
143 /** |
173 /** |
144 * Two-phased constructor. |
174 * Two-phased constructor. |
145 * |
175 * |
146 * @return A pointer to a new instance of the CHWRMVibra class. |
176 * @return A pointer to a new instance of the CHWRMVibra class. |
147 * |
177 * |
188 |
218 |
189 public: // New functions |
219 public: // New functions |
190 |
220 |
191 /** |
221 /** |
192 * Reserves vibration feature exclusively for this client. |
222 * Reserves vibration feature exclusively for this client. |
193 * A higher priority (not process or thread priority, but the priority defined |
223 * A higher priority client may cause lower priority client reservation |
194 * in the internal vibra policy of the HW Resource Manager) client may cause |
224 * to be temporarily suspended. Commands can still be issued in suspended |
195 * lower priority client reservation to be temporarily suspended. Commands |
225 * state, but they will not be acted upon unless suspension is lifted |
196 * can still be issued in suspended state, but they will not be acted upon |
226 * within specified duration. |
197 * unless suspension is lifted within specified duration. |
227 * The suspended client will not get any notification about suspension. |
198 * The suspended client will not get any notification about suspension and |
|
199 * neither from resumption of reservation. |
|
200 * If vibra is already reserved by a higher or equal priority application, |
228 * If vibra is already reserved by a higher or equal priority application, |
201 * reserving will still succeed, but reservation is immediately suspended. |
229 * reserving will still succeed, but reservation is immediately suspended. |
202 * |
230 * |
203 * Calling this method is equal to call ReserveVibraL(EFalse, EFalse), |
231 * Calling this method is equal to call ReserveVibraL(EFalse, EFalse), |
204 * i.e. any previously frozen state will not be restored and CCoeEnv |
232 * i.e. any previously frozen state will not be restored and CCoeEnv |
210 */ |
238 */ |
211 virtual void ReserveVibraL()=0; |
239 virtual void ReserveVibraL()=0; |
212 |
240 |
213 /** |
241 /** |
214 * Reserves vibration feature exclusively for this client. |
242 * Reserves vibration feature exclusively for this client. |
215 * A higher priority (not process or thread priority, but the priority defined |
243 * A higher priority client may cause lower priority client reservation |
216 * in the internal vibra policy of the HW Resource Manager) client may cause |
244 * to be temporarily suspended. Commands can still be issued in suspended |
217 * lower priority client reservation to be temporarily suspended. Commands |
245 * state, but they will not be acted upon unless suspension is lifted |
218 * can still be issued in suspended state, but they will not be acted upon |
246 * within specified duration. |
219 * unless suspension is lifted within specified duration. |
247 * The suspended client will not get any notification about suspension. |
220 * The suspended client will not get any notification about suspension and |
|
221 * neither from resumption of reservation. |
|
222 * If vibra is already reserved by a higher or equal priority application, |
248 * If vibra is already reserved by a higher or equal priority application, |
223 * reserving will still succeed, but reservation is immediately suspended. |
249 * reserving will still succeed, but reservation is immediately suspended. |
224 * |
250 * |
225 * |
251 * |
226 * @param aRestoreState If ETrue, the state frozen on last release will be |
252 * @param aRestoreState If ETrue, the state frozen on last release will be |
244 * client. |
270 * client. |
245 * Only trusted clients are allowed to set this flag to |
271 * Only trusted clients are allowed to set this flag to |
246 * ETrue. A client is considered trusted if it has nonstandard |
272 * ETrue. A client is considered trusted if it has nonstandard |
247 * priority defined in the internal vibra policy of the |
273 * priority defined in the internal vibra policy of the |
248 * HW Resource Manager. A client can be defined trusted |
274 * HW Resource Manager. A client can be defined trusted |
249 * only by S60 or a product. |
275 * only by a product. |
250 * |
276 * |
251 * @leave KErrAccessDenied Parameter aForceNoCCoeEnv is ETrue and client is not |
277 * @leave KErrAccessDenied Parameter aForceNoCCoeEnv is ETrue and client is not |
252 * trusted. |
278 * trusted. |
253 * @leave KErrBadHandle Parameter aForceNoCCoeEnv is EFalse and no CCoeEnv present. |
279 * @leave KErrBadHandle Parameter aForceNoCCoeEnv is EFalse and no CCoeEnv present. |
254 * @leave KErrNotReady Trying to reserve while on background and parameter |
280 * @leave KErrNotReady Trying to reserve while on background and parameter |
283 * limits to the duration of the vibration feature. In such |
309 * limits to the duration of the vibration feature. In such |
284 * circumstances any vibration will cut off at that limit even if |
310 * circumstances any vibration will cut off at that limit even if |
285 * the duration parameter is greater than the limit. |
311 * the duration parameter is greater than the limit. |
286 * |
312 * |
287 * @param aDuration Duration of the vibration measured in milliseconds. |
313 * @param aDuration Duration of the vibration measured in milliseconds. |
288 * A value of KHWRMVibraInfiniteDuration specifies that |
314 * A value of 0 specifies that the vibration should |
289 * the vibration should continue indefinetely and should |
315 * continue indefinetely and should be stopped with a |
290 * be stopped with a call to StopVibraL. Duration |
316 * call to StopVibraL. Duration can have maximum value |
291 * usually has device specific maximum value. |
317 * of KHWRMVibraMaxDuration. |
292 * |
318 * |
293 * @leave KErrArgument Duration is invalid. |
319 * @leave KErrArgument Duration is invalid. |
294 * @leave KErrAccessDenied Vibration setting in the user profile is not set. |
320 * @leave KErrAccessDenied Vibration setting in the user profile is not set. |
295 * @leave KErrBadHandle Vibra session has been invalidated. |
321 * @leave KErrBadHandle Vibra session has been invalidated. |
296 * @leave KErrLocked Vibra is locked down because too much continuous use |
322 * @leave KErrLocked Vibra is locked down because too much continuous use |
322 * limits to the duration of the vibration feature. In such |
348 * limits to the duration of the vibration feature. In such |
323 * circumstances any vibration will cut off at that limit even if |
349 * circumstances any vibration will cut off at that limit even if |
324 * the duration parameter is greater than the limit. |
350 * the duration parameter is greater than the limit. |
325 * |
351 * |
326 * @param aDuration Duration of the vibration measured in milliseconds. |
352 * @param aDuration Duration of the vibration measured in milliseconds. |
327 * A value of KHWRMVibraInfiniteDuration specifies that |
353 * A value of 0 specifies that the vibration should |
328 * the vibration should continue indefinetely and should |
354 * continue indefinitly and should be stopped with a |
329 * be stopped with a call to StopVibraL. Duration |
355 * call to StopVibraL. Duration can have maximum value |
330 * usually has device specific maximum value. |
356 * of KHWRMVibraMaxDuration. |
331 * @param aIntensity Intensity of the vibra in decimal is KHWRMVibraMinIntensity |
357 * @param aIntensity Intensity of the vibra in decimal is -100 to 100, |
332 * to KHWRMVibraMaxIntensity, |
|
333 * which shows the percentage of the vibra motor full |
358 * which shows the percentage of the vibra motor full |
334 * rotation speed. When intensity is negative, |
359 * rotation speed. When intensity is negative, |
335 * the vibra motor rotates in the negative direction. |
360 * the vibra motor rotates in the negative direction. |
336 * When intensity is positive, the vibra motor rotates |
361 * When intensity is positive, the vibra motor rotates |
337 * in the positive direction. Value 0 stops the vibra. |
362 * in the positive direction. Value 0 stops the vibra. |
505 * to KHWRMVibraMaxIntensity, which shows the percentage |
530 * to KHWRMVibraMaxIntensity, which shows the percentage |
506 * of the vibra motor full rotation speed. |
531 * of the vibra motor full rotation speed. |
507 * NOTE: The device might have hardware-imposed limits |
532 * NOTE: The device might have hardware-imposed limits |
508 * on supported vibra intensity values, so actual |
533 * on supported vibra intensity values, so actual |
509 * effect might vary between different hardware. |
534 * effect might vary between different hardware. |
510 * |
|
511 * @leave KErrNotSupported The device doesn't support user-defined |
535 * @leave KErrNotSupported The device doesn't support user-defined |
512 * vibra intensity. |
536 * vibra intensity. |
|
537 * |
513 * @leave KErrArgument One of the parameters is out of range. |
538 * @leave KErrArgument One of the parameters is out of range. |
514 * @leave KErrAccessDenied Vibration setting in the user profile is not set |
539 * @leave KErrAccessDenied Vibration setting in the user profile is not set |
515 * or client is not privileged to use pulse feature. |
540 * or client is not privileged to use pulse feature. |
516 * @leave KErrBadHandle Vibra session has been invalidated. |
541 * @leave KErrBadHandle Vibra session has been invalidated. |
517 * @leave KErrLocked Vibra is locked down because too much continuous use |
542 * @leave KErrLocked Vibra is locked down because too much continuous use |
632 */ |
658 */ |
633 virtual void VibraStatusChanged(CHWRMVibra::TVibraStatus aStatus) = 0; |
659 virtual void VibraStatusChanged(CHWRMVibra::TVibraStatus aStatus) = 0; |
634 }; |
660 }; |
635 |
661 |
636 /** |
662 /** |
637 * A callback interface for tactile feedback vibra mode reporting. |
663 * |
638 * |
664 * @publishedAll |
639 * If the client requires up-to-date status information, the client needs |
665 * @released |
640 * to derive a class from the MHWRMVibraFeedbackObserver interface and implement |
|
641 * the VibraFeedbackModeChanged() method. In order to register for callback, client |
|
642 * needs to call SetFeedbackObserver-method. |
|
643 * |
|
644 * A callback object header example: |
|
645 * |
|
646 * @code |
|
647 * // INCLUDES |
|
648 * #include <HWRMVibra.h> // Link against HWRMVibraClient.lib. |
|
649 * |
|
650 * class CTest : public CBase, |
|
651 * public MHWRMVibraFeedbackObserver |
|
652 * { |
|
653 * public: |
|
654 * CTest(); |
|
655 * ~CTest(); |
|
656 * |
|
657 * void ConstructL(); |
|
658 * static CTest* NewL(); |
|
659 * |
|
660 * // from MHWRMVibraFeedbackObserver |
|
661 * virtual void VibraFeedbackModeChanged(CHWRMVibra::TVibraFeedbackModeState aMode); |
|
662 * |
|
663 * private: |
|
664 * CHWRMVibra* iVibra; |
|
665 * }; |
|
666 * @endcode |
|
667 * |
|
668 * A callback method implementation example: |
|
669 * |
|
670 * @code |
|
671 * |
|
672 * #include <HWRMVibra.h> // link against HWRMVibraClient.lib |
|
673 * |
|
674 * // A CHWRMVibra instance can be created by using NewL() or NewLC() methods. |
|
675 * CHWRMVibra* vibra = CHWRMVibra::NewL(); |
|
676 * |
|
677 * // Request notification of feedback setting change |
|
678 * vibra->SetFeedbackObserver(this); |
|
679 * |
|
680 * // To clean up, delete the created object: |
|
681 * delete vibra; |
|
682 * |
|
683 * void CTest::VibraFeedbackModeChanged(CHWRMVibra::TVibraFeedbackModeState aMode) |
|
684 * { |
|
685 * switch ( aMode ) |
|
686 * { |
|
687 * case CHWRMVibra::EVibraFeedbackModeUnknown: |
|
688 * RDebug::Print(_L("### Feedback vibration mode : EVibraFeedbackModeUnknown")); |
|
689 * break; |
|
690 * case CHWRMVibra::EVibraFeedbackModeON: |
|
691 * RDebug::Print(_L("### Feedback vibration mode : EVibraFeedbackModeON")); |
|
692 * break; |
|
693 * case CHWRMVibra::EVibraFeedbackModeOFF: |
|
694 * RDebug::Print(_L("### Feedback vibration mode : EVibraFeedbackModeOFF")); |
|
695 * break; |
|
696 * default: |
|
697 * break; |
|
698 * } |
|
699 * } |
|
700 * @endcode |
|
701 * |
|
702 * @since S60 5.0 |
|
703 */ |
666 */ |
704 class MHWRMVibraFeedbackObserver |
667 class MHWRMVibraFeedbackObserver |
705 { |
668 { |
706 public: |
669 public: |
707 |
670 |