|
1 /* |
|
2 * Copyright (c) 2007 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 "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: AppUi class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __HAPTICSTEST_APPUI_H__ |
|
20 #define __HAPTICSTEST_APPUI_H__ |
|
21 |
|
22 #include <aknappui.h> |
|
23 #include <hwrmhaptics.h> |
|
24 #include <hwrmlogicalactuators.h> |
|
25 #include "hapticstestasyncplaysender.h" |
|
26 |
|
27 // Forward reference |
|
28 class CHapticsTestAppView; |
|
29 class CHWRMHaptics; |
|
30 class CHapticsTestEffectDataHandler; |
|
31 class CHapticsTestAsyncPlaySender; |
|
32 |
|
33 /** |
|
34 * @class CHapticsTestAppUi |
|
35 * |
|
36 * An instance of class ChapticstestAppUi is the UserInterface part of the AVKON |
|
37 * application framework for the hapticstest example application |
|
38 */ |
|
39 class CHapticsTestAppUi : public CAknAppUi, |
|
40 public MHWRMHapticsObserver, |
|
41 public MHWRMHapticsActuatorObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Perform the second phase construction of a ChapticstestAppUi object |
|
47 * this needs to be public due to the way the framework constructs the AppUi |
|
48 */ |
|
49 void ConstructL(); |
|
50 |
|
51 /** |
|
52 * Perform the first phase of two phase construction. |
|
53 * This needs to be public due to the way the framework constructs the AppUi |
|
54 */ |
|
55 CHapticsTestAppUi(); |
|
56 |
|
57 /** |
|
58 * Destroy the object and release all memory objects |
|
59 */ |
|
60 ~CHapticsTestAppUi(); |
|
61 |
|
62 public: // from CAknAppUi |
|
63 |
|
64 /** |
|
65 * Handle user menu selections |
|
66 * |
|
67 * @param aCommand the enumerated code for the option selected |
|
68 */ |
|
69 void HandleCommandL(TInt aCommand); |
|
70 |
|
71 void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination); |
|
72 |
|
73 public: // from MEikMenuObserver |
|
74 |
|
75 /** |
|
76 * @see MEikMenuObserver |
|
77 * |
|
78 * Manages the options menu contents based on user actions and data. |
|
79 */ |
|
80 virtual void DynInitMenuPaneL( TInt aResourceId, |
|
81 CEikMenuPane* aMenuPane ); |
|
82 |
|
83 public: // from MHWRMHapticsObserver |
|
84 |
|
85 /** |
|
86 * @see MHWRMHapticsObserver |
|
87 * |
|
88 * Outputs received status values onto the screen. |
|
89 */ |
|
90 virtual void HapticsStatusChangedL( THWRMHapticsStatus aStatus ); |
|
91 |
|
92 /** |
|
93 * @see MHWRMHapticsObserver |
|
94 * |
|
95 * Future use --> empty implementation. |
|
96 */ |
|
97 virtual void EffectCompletedL( TInt aError, TInt aEffectHandle ); |
|
98 |
|
99 public: |
|
100 |
|
101 /** |
|
102 * @see MHWRMHapticsActuatorObserver |
|
103 * |
|
104 * Outputs received actuator events onto the screen. |
|
105 */ |
|
106 virtual void ActuatorEventL( THWRMActuatorEvents aEvent, |
|
107 THWRMLogicalActuators aActuator ); |
|
108 |
|
109 private: |
|
110 |
|
111 /** |
|
112 * Creates haptics client instance. |
|
113 */ |
|
114 void OpenHapticsL(); |
|
115 |
|
116 /** |
|
117 * Deletes haptics client instance, and resets member variables |
|
118 * so that options-menu is updated accordingly; i.e. actions, which |
|
119 * require usage of haptics client become hidden. |
|
120 */ |
|
121 void CloseHaptics(); |
|
122 |
|
123 /** |
|
124 * Fetches the supported actuators from haptics server, and stores |
|
125 * the mask to iSupportedActuators. |
|
126 */ |
|
127 void FetchSupportedActuators(); |
|
128 |
|
129 /** |
|
130 * Prints the supported actuators to the UI according to |
|
131 * the value in iSupportedActuators. |
|
132 */ |
|
133 void PrintSupportedActuators(); |
|
134 |
|
135 /** |
|
136 * Attemps to open the given actuator. Prints the result |
|
137 * of the attemp to the UI. |
|
138 * |
|
139 * @param aActuator The logical actuator type to open. |
|
140 */ |
|
141 void OpenActuator( THWRMLogicalActuators aActuator ); |
|
142 |
|
143 /** |
|
144 * Reserves haptics for this application. |
|
145 * |
|
146 * @param aHaptics Haptics client instance, which should be used to |
|
147 * make the reservation. |
|
148 * @param aForceNoCoe If true, forces for haptics not to do automatic |
|
149 * reserve/release on focus gain/lost (in this case this application |
|
150 * must be trusted, otherwise the reservation call will end to |
|
151 * KErrAccessDenied). If false, haptics will use automatic reserve/release |
|
152 * on focus gain/lost (default). |
|
153 */ |
|
154 void ReserveHaptics( CHWRMHaptics* aHaptics, TBool aForceNoCoe ); |
|
155 |
|
156 /** |
|
157 * Searches for IVT-files in the filesystem, and writes |
|
158 * them to iIVTFileArray. |
|
159 */ |
|
160 void FindIVTFiles(); |
|
161 |
|
162 /** |
|
163 * Loads IVT data from the given file to haptics. |
|
164 * |
|
165 * @param aFile File where the IVT-data is stored. |
|
166 */ |
|
167 void LoadIVTDataL( TFileName& aFile ); |
|
168 |
|
169 /** |
|
170 * Plays the effect of the given index in the currently |
|
171 * loaded IVT-file using its filehandle or IVT-data. |
|
172 * |
|
173 * @param aIndex Index of the effect in the IVT-file. |
|
174 */ |
|
175 void PlayEffect( TInt aIndex ); |
|
176 |
|
177 /** |
|
178 * Plays the effect of the given index in the currently |
|
179 * loaded IVT-file repeatedly using its filehandle or IVT-data. |
|
180 * |
|
181 * @param aIndex Index of the effect in the IVT-file. |
|
182 * @param aRepeat Number of times the effect is to be repeated. |
|
183 */ |
|
184 void RepeatEffect( TInt aIndex, TInt aRepeats ); |
|
185 |
|
186 /** |
|
187 * Plays a magsweep effect using manual definition. |
|
188 * |
|
189 * @param aInfinite Whether or not the effect should last infinitely. |
|
190 * @param aModifiable Whether or not the effect should stored to member |
|
191 * variables as the current modifiable effect. |
|
192 */ |
|
193 void PlayMagSweepL( TBool aInfinite = EFalse, TBool aModifiable = EFalse ); |
|
194 |
|
195 /** |
|
196 * Plays a periodic effect using manual definition. |
|
197 * |
|
198 * @param aInfinite Whether or not the effect should last infinitely. |
|
199 * @param aModifiable Whether or not the effect should stored to member |
|
200 * variables as the current modifiable effect. |
|
201 */ |
|
202 void PlayPeriodicL( TBool aInfinite = EFalse, TBool aModifiable = EFalse ); |
|
203 |
|
204 /** |
|
205 * Repeats a timeline effect using manual definition. |
|
206 * |
|
207 * @param aRepeat Number of times the effect is to be repeated. |
|
208 */ |
|
209 void PlayRepeatL( TInt aRepeat ); |
|
210 |
|
211 /** |
|
212 * Pauses the effect of the given index in the effect history data. |
|
213 * |
|
214 * @param aIndex Index of the effect in the effect history data. |
|
215 */ |
|
216 void PauseEffect( TInt aIndex ); |
|
217 |
|
218 /** |
|
219 * Resumes the effect of the given index in the effect history data. |
|
220 * |
|
221 * @param aIndex Index of the effect in the effect history data. |
|
222 */ |
|
223 void ResumeEffect( TInt aIndex ); |
|
224 |
|
225 /** |
|
226 * Stops the effect of the given index in the effect history data. |
|
227 * |
|
228 * @param aIndex Index of the effect in the effect history data. |
|
229 */ |
|
230 void StopEffect( TInt aIndex ); |
|
231 |
|
232 /** |
|
233 * Deletes loaded IVT data. |
|
234 * |
|
235 * @param aIndex Array index to the loaded IVT file array item |
|
236 * (defined below) that is to be deleted. |
|
237 */ |
|
238 void DeleteLoadedIVTData( TInt aIndex ); |
|
239 |
|
240 /** |
|
241 * Deletes all loaded IVT datas. |
|
242 */ |
|
243 void DeleteAllLoadedIVTData(); |
|
244 |
|
245 /** |
|
246 * Fetches the current state of the last played effect |
|
247 * (iEffectHandle), and prints the result to the UI. |
|
248 */ |
|
249 void GetCurrentEffectState(); |
|
250 |
|
251 /** |
|
252 * Prints the status of a "play effect". |
|
253 * |
|
254 * @param aErrorCode Return code from playing an effect. |
|
255 */ |
|
256 void PrintPlayEffectStatus( TInt aErrorCode ) const; |
|
257 |
|
258 /** |
|
259 * Gets the number of repeats from user in case of |
|
260 * "play effect repeatedly" cases. |
|
261 * In practice opens a list query where user may choose |
|
262 * one of the available repeats values. |
|
263 * |
|
264 * @returns Number of repeats (one of 0,1,2,3,7,255), |
|
265 * where 255 represents infinite value in vibra player. |
|
266 */ |
|
267 TInt GetNumberOfRepeats(); |
|
268 |
|
269 /** |
|
270 * Creates all submenu items for a play effect submenu. |
|
271 * Fetches all the names of the effects from currently |
|
272 * loaded IVT-data. |
|
273 * |
|
274 * @param aMenuPane Menu object to which menu items are added. |
|
275 * @param aCommandId Id of an options menu command to be used |
|
276 * for all items. |
|
277 * @param aDimCommand Id of a command, which needs to be dimmed, |
|
278 * when the submenu contains items. |
|
279 */ |
|
280 void CreatePlayEffectSubmenuL( CEikMenuPane* aMenuPane, |
|
281 TInt aCommandId, |
|
282 TInt aDimCommandId ); |
|
283 |
|
284 /** |
|
285 * Counts the actual effect index (within an IVT file) based |
|
286 * on the index of the selected item in effects submenu. |
|
287 * Also sets the iIVTFileHandle and iIVTDataBuffer members |
|
288 * based on the file containing the selected effect. |
|
289 * |
|
290 * @param aSubmenuIndex Index from the submenu that contains |
|
291 * all currently loaded effects (i.e., |
|
292 * that contains all effects in all |
|
293 * currently loaded IVT files). |
|
294 * |
|
295 * @returns Effect index. |
|
296 */ |
|
297 TInt CountFileHandleAndEffectIndex( TInt aSubmenuIndex ); |
|
298 |
|
299 /** |
|
300 * Prints effect information got from getter functions. |
|
301 * |
|
302 * @param aIndex Index of the effect in the IVT-file. |
|
303 */ |
|
304 void PrintEffectInfo( TInt aIndex ); |
|
305 |
|
306 /** |
|
307 * Prints the given status onto the screen. |
|
308 * |
|
309 * @param aStatus Status value to be printed. |
|
310 */ |
|
311 void PrintStatusInfo( MHWRMHapticsObserver::THWRMHapticsStatus aStatus ) const; |
|
312 |
|
313 /** |
|
314 * Runs test for all getter methods for constants |
|
315 * and prints out the results. |
|
316 */ |
|
317 void ConstGetters() const; |
|
318 |
|
319 /** |
|
320 * Modifies an effect using the values set for iModifyEffect. |
|
321 */ |
|
322 void ModifyEffect(); |
|
323 |
|
324 /** |
|
325 * Sets property Priority to min |
|
326 */ |
|
327 void SetPropertyPriorityMin(); |
|
328 |
|
329 /** |
|
330 * Sets property Priority to default |
|
331 */ |
|
332 void SetPropertyPriorityDefault(); |
|
333 |
|
334 /** |
|
335 * Sets property Priority to max |
|
336 */ |
|
337 void SetPropertyPriorityMax(); |
|
338 |
|
339 /** |
|
340 * Sets property Disable effects to ETrue |
|
341 */ |
|
342 void SetPropertyDisableEffectsTrue(); |
|
343 |
|
344 /** |
|
345 * Sets property Disable effects to EFalse |
|
346 */ |
|
347 void SetPropertyDisableEffectsFalse(); |
|
348 |
|
349 /** |
|
350 * Sets property Strength to Min level |
|
351 */ |
|
352 void SetPropertyStrengthMin(); |
|
353 |
|
354 /** |
|
355 * Sets property Strength to middle level |
|
356 */ |
|
357 void SetPropertyStrengthMiddle(); |
|
358 |
|
359 /** |
|
360 * Sets property Strength to Max level |
|
361 */ |
|
362 void SetPropertyStrengthMax(); |
|
363 |
|
364 /** |
|
365 * Gets Priority property value |
|
366 */ |
|
367 void GetPropertyPriority(); |
|
368 |
|
369 /** |
|
370 * Gets Disable Effects property value |
|
371 */ |
|
372 void GetPropertyDisableEffects(); |
|
373 |
|
374 /** |
|
375 * Gets Strength property value |
|
376 */ |
|
377 void GetPropertyStrength(); |
|
378 |
|
379 /** |
|
380 * Gets device category capability. |
|
381 */ |
|
382 void GetCapabilityDeviceCategory(); |
|
383 |
|
384 /** |
|
385 * Gets max nested repeats.. |
|
386 */ |
|
387 void GetCapabilityMaxNestedRepeats(); |
|
388 |
|
389 /** |
|
390 * Gets number of actuators capability. |
|
391 */ |
|
392 void GetCapabilityNumActuators(); |
|
393 |
|
394 /** |
|
395 * Gets actuator type capability. |
|
396 */ |
|
397 void GetCapabilityActuatorType(); |
|
398 |
|
399 /** |
|
400 * Gets number of effect slots. |
|
401 */ |
|
402 void GetCapabilityNumEffectSlots(); |
|
403 |
|
404 /** |
|
405 * Gets number of effect styles. |
|
406 */ |
|
407 void GetCapabilityNumEffectStyles(); |
|
408 |
|
409 /** |
|
410 * Gets minimum period of periodic effects. |
|
411 */ |
|
412 void GetCapabilityMinPeriod(); |
|
413 |
|
414 /** |
|
415 * Gets maximum period of periodic effects. |
|
416 */ |
|
417 void GetCapabilityMaxPeriod(); |
|
418 |
|
419 /** |
|
420 * Gets maximum effect duration.. |
|
421 */ |
|
422 void GetCapabilityMaxEffectDuration(); |
|
423 |
|
424 /** |
|
425 * Gets supported effect types.. |
|
426 */ |
|
427 void GetCapabilitySupportedEffects(); |
|
428 |
|
429 /** |
|
430 * Gets device name capability. |
|
431 */ |
|
432 void GetCapabilityDeviceName(); |
|
433 |
|
434 /** |
|
435 * Gets max envelope type. |
|
436 */ |
|
437 void GetCapabilityMaxEnvelopeTime(); |
|
438 |
|
439 /** |
|
440 * Gets API version number. |
|
441 */ |
|
442 void GetCapabilityAPIVersionNumber(); |
|
443 |
|
444 /** |
|
445 * Gets max size of IVT file. |
|
446 */ |
|
447 void GetCapabilityMaxIVTSize(); |
|
448 |
|
449 /** |
|
450 * Callback method for CPeriodic timer for modifying a certain effect |
|
451 * after each time period. |
|
452 * |
|
453 * @param aPtr Pointer to a TModifyEffect data used for the modification. |
|
454 * @return System wide error code. |
|
455 */ |
|
456 static TInt ModifyPlayingEffect( TAny* aPtr ); |
|
457 |
|
458 /** |
|
459 * Enables streaming mode. |
|
460 */ |
|
461 void StartStreaming(); |
|
462 |
|
463 /** |
|
464 * Plays one streaming sample from KStreamArray. |
|
465 * |
|
466 * @param aSampleId Index to KStreamArray. |
|
467 */ |
|
468 void PlayStreamingSample( TInt aSampleId ); |
|
469 |
|
470 /** |
|
471 * Disables streaming mode. |
|
472 */ |
|
473 void StopStreaming(); |
|
474 |
|
475 private: |
|
476 |
|
477 /** |
|
478 * Internal struct for IVT files that contain file name, |
|
479 * file handle (received from haptics) and IVT data |
|
480 * as data buffer. |
|
481 */ |
|
482 struct TLoadedIVTFileItem |
|
483 { |
|
484 TFileName iFileName; |
|
485 TInt iFileHandle; |
|
486 HBufC8* iDataBuffer; // owns |
|
487 |
|
488 // ctor |
|
489 TLoadedIVTFileItem() : iFileHandle( 0 ), iDataBuffer ( NULL ) |
|
490 { |
|
491 // empty |
|
492 } |
|
493 |
|
494 // static matcher method used in checking whether the |
|
495 // given file (name) is already in the loaded IVT |
|
496 // files storage. |
|
497 static TBool Match( const TLoadedIVTFileItem& a, const TLoadedIVTFileItem& b ) |
|
498 { |
|
499 TBool retVal = EFalse; |
|
500 if ( 0 == a.iFileName.CompareF( b.iFileName ) ) |
|
501 { |
|
502 retVal = ETrue; |
|
503 } |
|
504 return retVal; |
|
505 } |
|
506 }; |
|
507 |
|
508 private: |
|
509 |
|
510 /** |
|
511 * Menu pane pointer received in DynInitMenuPaneL() used |
|
512 * in handling dynamic submenus (in HandleCommandL()). |
|
513 * Not owned. |
|
514 */ |
|
515 CEikMenuPane* iMenuPane; |
|
516 |
|
517 /** |
|
518 * Application view instance. Owned. |
|
519 */ |
|
520 CHapticsTestAppView* iAppView; |
|
521 |
|
522 /** |
|
523 * Haptics client instance. Owned. |
|
524 */ |
|
525 CHWRMHaptics* iHaptics; |
|
526 |
|
527 /** |
|
528 * Second haptics client instance used for making reservations, |
|
529 * which cause iHaptics unable to use play-commands. Owned. |
|
530 */ |
|
531 CHWRMHaptics* iTempHaptics; |
|
532 |
|
533 /** |
|
534 * Holds the information which logical actuators are supported |
|
535 * by the haptics system. In the options menu, this value is used |
|
536 * in construction of the actuator opening submenu. |
|
537 */ |
|
538 TUint32 iSupportedActuators; |
|
539 |
|
540 /** |
|
541 * Constains the names of the IVT-files found in the |
|
542 * filesystem, when the application was launched. |
|
543 */ |
|
544 RArray<TFileName> iIVTFileArray; |
|
545 |
|
546 /** |
|
547 * Array that contains above defined items that represent |
|
548 * currently loaded IVT files. |
|
549 */ |
|
550 RArray<TLoadedIVTFileItem> iLoadedIVTFileArray; |
|
551 |
|
552 /** |
|
553 * Whether or not an actuator has been successfully opened. |
|
554 */ |
|
555 TBool iActuatorOpened; |
|
556 |
|
557 /** |
|
558 * Filehandle to loaded IVT-data. |
|
559 */ |
|
560 TInt iIVTFileHandle; |
|
561 |
|
562 /** |
|
563 * Buffer containing latest loaded IVT-data. |
|
564 */ |
|
565 HBufC8* iIVTDataBuffer; // not owned |
|
566 |
|
567 /** |
|
568 * Effect handle to the last played effect. |
|
569 */ |
|
570 TInt iEffectHandle; |
|
571 |
|
572 /** |
|
573 * Whether or not to use synchronous calls to haptics by defualt. |
|
574 */ |
|
575 TBool iSynchronous; |
|
576 |
|
577 /** |
|
578 * Whether or not to use fileHandle when calling "play" Haptics API |
|
579 * methods. |
|
580 */ |
|
581 TBool iUseHandle; |
|
582 |
|
583 /** |
|
584 * Whether or not files are read from mem card (if not, they're |
|
585 * read from phone memory). |
|
586 */ |
|
587 TBool iUsesMemCard; |
|
588 |
|
589 /** |
|
590 * Is effect information showed or not |
|
591 */ |
|
592 TBool iShowEffectInfo; |
|
593 |
|
594 /** |
|
595 * Objects used for storaging effect related history data and |
|
596 * modifiable effect data. |
|
597 */ |
|
598 CHapticsTestEffectDataHandler* iEffectData; |
|
599 |
|
600 /** |
|
601 * Is effect streaming on or not |
|
602 */ |
|
603 TBool iStreaming; |
|
604 |
|
605 /** |
|
606 * played stream sample number |
|
607 */ |
|
608 TInt iCurrentSample; |
|
609 |
|
610 /** |
|
611 * Active object for sending async play commands |
|
612 */ |
|
613 CHapticsTestAsyncPlaySender* iAsyncPlaySender; |
|
614 friend class CHapticsTestAsyncPlaySender; |
|
615 }; |
|
616 |
|
617 |
|
618 #endif // __HAPTICSTEST_APPUI_H__ |
|
619 |