|
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 implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <avkon.hrh> |
|
20 #include <e32math.h> |
|
21 #include <eikmenup.h> |
|
22 #include <aknlistquerydialog.h> |
|
23 #include <hapticstest.rsg> |
|
24 #include <utf.h> |
|
25 |
|
26 #include "hapticstest.pan" |
|
27 #include "hapticstestappui.h" |
|
28 #include "hapticstestappview.h" |
|
29 #include "hapticstesteffectdatahandler.h" |
|
30 #include "hapticstest.hrh" |
|
31 |
|
32 _LIT( KSessionPathMem, "C:\\Data\\Others\\" ); |
|
33 _LIT( KSessionPathCrd, "E:\\Others\\" ); |
|
34 _LIT( KIVTFileType, "*.ivt" ); |
|
35 |
|
36 const TInt KSampleCount = 8; |
|
37 |
|
38 static const TUint8 KStreamArray[KSampleCount][10] = |
|
39 { |
|
40 0x00, 0x00, 0x20, 0x13, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0x41, |
|
41 0x29, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42, |
|
42 0x51, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0xc1, |
|
43 0x65, 0x00, 0x20, 0x07, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0xd1, |
|
44 0x7a, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42, |
|
45 0x8e, 0x00, 0x20, 0x16, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0x01, |
|
46 0xa2, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42, |
|
47 0x06, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42 |
|
48 }; |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // ConstructL is called by the application framework |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 void CHapticsTestAppUi::ConstructL() |
|
58 { |
|
59 BaseConstructL(); |
|
60 |
|
61 // create appview |
|
62 iAppView = CHapticsTestAppView::NewL( ClientRect() ); |
|
63 AddToStackL( iAppView ); |
|
64 |
|
65 // create effect data handler |
|
66 iEffectData = CHapticsTestEffectDataHandler::NewL(); |
|
67 |
|
68 // create async play sender |
|
69 iAsyncPlaySender = new ( ELeave ) CHapticsTestAsyncPlaySender( this ); |
|
70 |
|
71 FindIVTFiles(); |
|
72 |
|
73 iAppView->InsertOutput( _L("Haptics usage from options menu.") ); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------- |
|
77 // Constructor. |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 CHapticsTestAppUi::CHapticsTestAppUi() |
|
81 : iSynchronous( ETrue ), iUseHandle( EFalse ), iUsesMemCard( EFalse ) |
|
82 { |
|
83 // no implementation required |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // Destructor. |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 CHapticsTestAppUi::~CHapticsTestAppUi() |
|
91 { |
|
92 if (iAppView) |
|
93 { |
|
94 RemoveFromStack( iAppView ); |
|
95 delete iAppView; |
|
96 iAppView = NULL; |
|
97 } |
|
98 |
|
99 if( iHaptics ) |
|
100 { |
|
101 delete iHaptics; |
|
102 iHaptics = NULL; |
|
103 } |
|
104 |
|
105 if ( iTempHaptics ) |
|
106 { |
|
107 delete iTempHaptics; |
|
108 iTempHaptics = NULL; |
|
109 } |
|
110 |
|
111 delete iEffectData; |
|
112 |
|
113 iIVTFileArray.Close(); |
|
114 |
|
115 while ( iLoadedIVTFileArray.Count() ) |
|
116 { |
|
117 delete iLoadedIVTFileArray[0].iDataBuffer; |
|
118 iLoadedIVTFileArray.Remove( 0 ); |
|
119 } |
|
120 |
|
121 iLoadedIVTFileArray.Close(); |
|
122 |
|
123 if ( iAsyncPlaySender ) |
|
124 { |
|
125 iAsyncPlaySender->Cancel(); |
|
126 delete iAsyncPlaySender; |
|
127 iAsyncPlaySender = NULL; |
|
128 } |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // handle any menu commands |
|
133 // --------------------------------------------------------- |
|
134 // |
|
135 void CHapticsTestAppUi::HandleCommandL( TInt aCommand ) |
|
136 { |
|
137 switch( aCommand ) |
|
138 { |
|
139 case EEikCmdExit: |
|
140 case EAknSoftkeyExit: |
|
141 Exit(); |
|
142 break; |
|
143 |
|
144 case EHapticsTestOpenHaptics: |
|
145 { |
|
146 OpenHapticsL(); |
|
147 } |
|
148 break; |
|
149 |
|
150 case EHapticsTestAutoInit: |
|
151 { |
|
152 // automatically create haptics instance, fetch supported |
|
153 // actuators, and open Any-actuator |
|
154 OpenHapticsL(); |
|
155 FetchSupportedActuators(); |
|
156 OpenActuator( EHWRMLogicalActuatorAny ); |
|
157 } |
|
158 break; |
|
159 |
|
160 case EHapticsTestSupportedActuators: |
|
161 { |
|
162 FetchSupportedActuators(); |
|
163 } |
|
164 break; |
|
165 |
|
166 case EHapticsTestOpenActuator: |
|
167 case EHapticsTestOpenActuatorAny: |
|
168 { |
|
169 OpenActuator( EHWRMLogicalActuatorAny ); |
|
170 } |
|
171 break; |
|
172 case EHapticsTestOpenActuatorDevice: |
|
173 { |
|
174 OpenActuator( EHWRMLogicalActuatorDevice ); |
|
175 } |
|
176 break; |
|
177 case EHapticsTestOpenActuatorPrimaryDisplay: |
|
178 { |
|
179 OpenActuator( EHWRMLogicalActuatorPrimaryDisplay ); |
|
180 } |
|
181 break; |
|
182 case EHapticsTestOpenActuatorSecondaryDisplay: |
|
183 { |
|
184 OpenActuator( EHWRMLogicalActuatorSecondaryDisplay ); |
|
185 } |
|
186 break; |
|
187 case EHapticsTestOpenActuatorGame: |
|
188 { |
|
189 OpenActuator( EHWRMLogicalActuatorGame ); |
|
190 } |
|
191 break; |
|
192 case EHapticsTestOpenActuatorGameLeft: |
|
193 { |
|
194 OpenActuator( EHWRMLogicalActuatorGameLeft ); |
|
195 } |
|
196 break; |
|
197 case EHapticsTestOpenActuatorGameRight: |
|
198 { |
|
199 OpenActuator( EHWRMLogicalActuatorGameRight ); |
|
200 } |
|
201 break; |
|
202 case EHapticsTestOpenActuatorExternalVibra: |
|
203 { |
|
204 OpenActuator( EHWRMLogicalActuatorExternalVibra ); |
|
205 } |
|
206 break; |
|
207 |
|
208 case EHapticsTestLoadIVTFile: |
|
209 case EHapticsTestLoadIVTFileNoneFound: |
|
210 { |
|
211 // nothing to do |
|
212 } |
|
213 break; |
|
214 case EHapticsTestLoadIVTFileSelected: |
|
215 { |
|
216 // open selected file |
|
217 TInt index = iMenuPane->SelectedItem(); |
|
218 LoadIVTDataL( iIVTFileArray[index] ); |
|
219 } |
|
220 break; |
|
221 |
|
222 case EHapticsTestPlayEffect: |
|
223 case EHapticsTestPlayEffectNoneFound: |
|
224 { |
|
225 // nothing to do |
|
226 } |
|
227 break; |
|
228 case EHapticsTestPlayEffectSelected: |
|
229 { |
|
230 // play selected effect |
|
231 TInt index = CountFileHandleAndEffectIndex( iMenuPane->SelectedItem() ); |
|
232 PlayEffect( index ); |
|
233 PrintEffectInfo( index ); |
|
234 } |
|
235 break; |
|
236 case EHapticsTestPlayEffectRepeat: |
|
237 case EHapticsTestPlayEffectRepeatNoneFound: |
|
238 { |
|
239 // nothing to do |
|
240 } |
|
241 break; |
|
242 case EHapticsTestPlayEffectRepeatSelected: |
|
243 { |
|
244 // play selected effect repeatedly |
|
245 TInt index = CountFileHandleAndEffectIndex( iMenuPane->SelectedItem() ); |
|
246 RepeatEffect( index, GetNumberOfRepeats() ); |
|
247 PrintEffectInfo( index ); |
|
248 } |
|
249 break; |
|
250 |
|
251 case EHapticsTestPlayEffectManual: |
|
252 { |
|
253 // nothing to do |
|
254 } |
|
255 break; |
|
256 case EHapticsTestPlayEffectManualMagSweep: |
|
257 { |
|
258 PlayMagSweepL(); |
|
259 } |
|
260 break; |
|
261 case EHapticsTestPlayEffectManualMagSweepInf: |
|
262 { |
|
263 PlayMagSweepL( ETrue ); |
|
264 } |
|
265 break; |
|
266 case EHapticsTestPlayEffectManualMagSweepInfMod: |
|
267 { |
|
268 PlayMagSweepL( ETrue, ETrue ); |
|
269 } |
|
270 break; |
|
271 case EHapticsTestPlayEffectManualPeriodic: |
|
272 { |
|
273 PlayPeriodicL(); |
|
274 } |
|
275 break; |
|
276 case EHapticsTestPlayEffectManualPeriodicInf: |
|
277 { |
|
278 PlayPeriodicL( ETrue ); |
|
279 } |
|
280 break; |
|
281 case EHapticsTestPlayEffectManualPeriodicInfMod: |
|
282 { |
|
283 PlayPeriodicL( ETrue, ETrue ); |
|
284 } |
|
285 break; |
|
286 case EHapticsTestPlayEffectManualRepeat: |
|
287 { |
|
288 PlayRepeatL( GetNumberOfRepeats() ); |
|
289 } |
|
290 break; |
|
291 |
|
292 case EHapticsTestChangeState: |
|
293 case EHapticsTestChangeStateNoneFound: |
|
294 { |
|
295 // nothing to do |
|
296 } |
|
297 break; |
|
298 |
|
299 case EHapticsTestChangeStatePause: |
|
300 { |
|
301 // get itemindex and pause effect |
|
302 TInt itemIndex = iMenuPane->SelectedItem(); |
|
303 PauseEffect( itemIndex ); |
|
304 } |
|
305 break; |
|
306 |
|
307 case EHapticsTestChangeStateResume: |
|
308 { |
|
309 // get itemindex and resume effect |
|
310 TInt itemIndex = iMenuPane->SelectedItem(); |
|
311 ResumeEffect( itemIndex ); |
|
312 } |
|
313 break; |
|
314 |
|
315 case EHapticsTestChangeStateStop: |
|
316 { |
|
317 // get itemindex and stop effect |
|
318 TInt itemIndex = iMenuPane->SelectedItem(); |
|
319 StopEffect( itemIndex ); |
|
320 } |
|
321 break; |
|
322 |
|
323 case EHapticsTestChangeStateStopAll: |
|
324 { |
|
325 TInt err = iHaptics->StopAllPlayingEffects(); |
|
326 if ( err ) |
|
327 { |
|
328 TBuf<8> errBuf; |
|
329 errBuf.AppendNum( err ); |
|
330 iAppView->InsertOutput( _L("Stopping all effects failed, err = "), EFalse ); |
|
331 iAppView->InsertOutput( errBuf ); |
|
332 } |
|
333 else |
|
334 { |
|
335 iAppView->InsertOutput( _L("Stopping all effects succeeded.") ); |
|
336 |
|
337 // reset the auto-modification |
|
338 iEffectData->ResetModifiableEffectTimer(); |
|
339 } |
|
340 } |
|
341 break; |
|
342 |
|
343 case EHapticsTestModifyEffect: |
|
344 { |
|
345 // nothing to do |
|
346 } |
|
347 break; |
|
348 case EHapticsTestModifyEffectDuration1: |
|
349 { |
|
350 iEffectData->SetDuration( KEffectDuration1 ); |
|
351 ModifyEffect(); |
|
352 } |
|
353 break; |
|
354 case EHapticsTestModifyEffectDuration5: |
|
355 { |
|
356 iEffectData->SetDuration( KEffectDuration5 ); |
|
357 ModifyEffect(); |
|
358 } |
|
359 break; |
|
360 case EHapticsTestModifyEffectDuration10: |
|
361 { |
|
362 iEffectData->SetDuration( KEffectDuration10 ); |
|
363 ModifyEffect(); |
|
364 } |
|
365 break; |
|
366 case EHapticsTestModifyEffectDuration30: |
|
367 { |
|
368 iEffectData->SetDuration( KEffectDuration30 ); |
|
369 ModifyEffect(); |
|
370 } |
|
371 break; |
|
372 case EHapticsTestModifyEffectDuration60: |
|
373 { |
|
374 iEffectData->SetDuration( KEffectDuration60 ); |
|
375 ModifyEffect(); |
|
376 } |
|
377 break; |
|
378 case EHapticsTestModifyEffectMagnitudeMin: |
|
379 { |
|
380 iEffectData->SetMagnitude( KHWRMHapticsMinMagnitude ); |
|
381 ModifyEffect(); |
|
382 } |
|
383 break; |
|
384 case EHapticsTestModifyEffectMagnitude25: |
|
385 { |
|
386 iEffectData->SetMagnitude( KEffectMagnitude25 ); |
|
387 ModifyEffect(); |
|
388 } |
|
389 break; |
|
390 case EHapticsTestModifyEffectMagnitude50: |
|
391 { |
|
392 iEffectData->SetMagnitude( KEffectMagnitude50 ); |
|
393 ModifyEffect(); |
|
394 } |
|
395 break; |
|
396 case EHapticsTestModifyEffectMagnitude75: |
|
397 { |
|
398 iEffectData->SetMagnitude( KEffectMagnitude75 ); |
|
399 ModifyEffect(); |
|
400 } |
|
401 break; |
|
402 case EHapticsTestModifyEffectMagnitudeMax: |
|
403 { |
|
404 iEffectData->SetMagnitude( KHWRMHapticsMaxMagnitude ); |
|
405 ModifyEffect(); |
|
406 } |
|
407 break; |
|
408 case EHapticsTestModifyEffectStyleSmooth: |
|
409 { |
|
410 iEffectData->SetStyle( CHWRMHaptics::EHWRMHapticsStyleSmooth ); |
|
411 ModifyEffect(); |
|
412 } |
|
413 break; |
|
414 case EHapticsTestModifyEffectStyleStrong: |
|
415 { |
|
416 iEffectData->SetStyle( CHWRMHaptics::EHWRMHapticsStyleStrong ); |
|
417 ModifyEffect(); |
|
418 } |
|
419 break; |
|
420 case EHapticsTestModifyEffectStyleSharp: |
|
421 { |
|
422 iEffectData->SetStyle( CHWRMHaptics::EHWRMHapticsStyleSharp ); |
|
423 ModifyEffect(); |
|
424 } |
|
425 break; |
|
426 case EHapticsTestModifyEffectAttackMin: |
|
427 { |
|
428 iEffectData->SetAttackLevel( KHWRMHapticsMinMagnitude ); |
|
429 ModifyEffect(); |
|
430 } |
|
431 break; |
|
432 case EHapticsTestModifyEffectAttack25: |
|
433 { |
|
434 iEffectData->SetAttackLevel( KEffectMagnitude25 ); |
|
435 ModifyEffect(); |
|
436 } |
|
437 break; |
|
438 case EHapticsTestModifyEffectAttack50: |
|
439 { |
|
440 iEffectData->SetAttackLevel( KEffectMagnitude50 ); |
|
441 ModifyEffect(); |
|
442 } |
|
443 break; |
|
444 case EHapticsTestModifyEffectAttack75: |
|
445 { |
|
446 iEffectData->SetAttackLevel( KEffectMagnitude75 ); |
|
447 ModifyEffect(); |
|
448 } |
|
449 break; |
|
450 case EHapticsTestModifyEffectAttackMax: |
|
451 { |
|
452 iEffectData->SetAttackLevel( KHWRMHapticsMaxMagnitude ); |
|
453 ModifyEffect(); |
|
454 } |
|
455 break; |
|
456 case EHapticsTestModifyEffectFadeMin: |
|
457 { |
|
458 iEffectData->SetFadeLevel( KHWRMHapticsMinMagnitude ); |
|
459 ModifyEffect(); |
|
460 } |
|
461 break; |
|
462 case EHapticsTestModifyEffectFade25: |
|
463 { |
|
464 iEffectData->SetFadeLevel( KEffectMagnitude25 ); |
|
465 ModifyEffect(); |
|
466 } |
|
467 break; |
|
468 case EHapticsTestModifyEffectFade50: |
|
469 { |
|
470 iEffectData->SetFadeLevel( KEffectMagnitude50 ); |
|
471 ModifyEffect(); |
|
472 } |
|
473 break; |
|
474 case EHapticsTestModifyEffectFade75: |
|
475 { |
|
476 iEffectData->SetFadeLevel( KEffectMagnitude75 ); |
|
477 ModifyEffect(); |
|
478 } |
|
479 break; |
|
480 case EHapticsTestModifyEffectFadeMax: |
|
481 { |
|
482 iEffectData->SetFadeLevel( KHWRMHapticsMaxMagnitude ); |
|
483 ModifyEffect(); |
|
484 } |
|
485 break; |
|
486 case EHapticsTestModifyEffectAttackTime02: |
|
487 { |
|
488 iEffectData->SetAttackTime( KEffectAttackTime02 ); |
|
489 ModifyEffect(); |
|
490 } |
|
491 break; |
|
492 case EHapticsTestModifyEffectAttackTime1: |
|
493 { |
|
494 iEffectData->SetAttackTime( KEffectAttackTime1 ); |
|
495 ModifyEffect(); |
|
496 } |
|
497 break; |
|
498 case EHapticsTestModifyEffectAttackTime5: |
|
499 { |
|
500 iEffectData->SetAttackTime( KEffectAttackTime5 ); |
|
501 ModifyEffect(); |
|
502 } |
|
503 break; |
|
504 case EHapticsTestModifyEffectAttackTime10: |
|
505 { |
|
506 iEffectData->SetAttackTime( KEffectAttackTime10 ); |
|
507 ModifyEffect(); |
|
508 } |
|
509 break; |
|
510 case EHapticsTestModifyEffectAttackTime30: |
|
511 { |
|
512 iEffectData->SetAttackTime( KEffectAttackTime30 ); |
|
513 ModifyEffect(); |
|
514 } |
|
515 break; |
|
516 case EHapticsTestModifyEffectAttackTime60: |
|
517 { |
|
518 iEffectData->SetAttackTime( KEffectAttackTime60 ); |
|
519 ModifyEffect(); |
|
520 } |
|
521 break; |
|
522 case EHapticsTestModifyEffectFadeTime02: |
|
523 { |
|
524 iEffectData->SetFadeTime( KEffectFadeTime02 ); |
|
525 ModifyEffect(); |
|
526 } |
|
527 break; |
|
528 case EHapticsTestModifyEffectFadeTime1: |
|
529 { |
|
530 iEffectData->SetFadeTime( KEffectFadeTime1 ); |
|
531 ModifyEffect(); |
|
532 } |
|
533 break; |
|
534 case EHapticsTestModifyEffectFadeTime5: |
|
535 { |
|
536 iEffectData->SetFadeTime( KEffectFadeTime5 ); |
|
537 ModifyEffect(); |
|
538 } |
|
539 break; |
|
540 case EHapticsTestModifyEffectFadeTime10: |
|
541 { |
|
542 iEffectData->SetFadeTime( KEffectFadeTime10 ); |
|
543 ModifyEffect(); |
|
544 } |
|
545 break; |
|
546 case EHapticsTestModifyEffectFadeTime30: |
|
547 { |
|
548 iEffectData->SetFadeTime( KEffectFadeTime30 ); |
|
549 ModifyEffect(); |
|
550 } |
|
551 break; |
|
552 case EHapticsTestModifyEffectFadeTime60: |
|
553 { |
|
554 iEffectData->SetFadeTime( KEffectFadeTime60 ); |
|
555 ModifyEffect(); |
|
556 } |
|
557 break; |
|
558 case EHapticsTestModifyEffectPeriod50: |
|
559 { |
|
560 iEffectData->SetPeriod( KEffectPeriod50 ); |
|
561 ModifyEffect(); |
|
562 } |
|
563 break; |
|
564 case EHapticsTestModifyEffectPeriod100: |
|
565 { |
|
566 iEffectData->SetPeriod( KEffectPeriod100 ); |
|
567 ModifyEffect(); |
|
568 } |
|
569 break; |
|
570 case EHapticsTestModifyEffectPeriod300: |
|
571 { |
|
572 iEffectData->SetPeriod( KEffectPeriod300 ); |
|
573 ModifyEffect(); |
|
574 } |
|
575 break; |
|
576 case EHapticsTestModifyEffectPeriod600: |
|
577 { |
|
578 iEffectData->SetPeriod( KEffectPeriod600 ); |
|
579 ModifyEffect(); |
|
580 } |
|
581 break; |
|
582 case EHapticsTestModifyEffectPeriod1000: |
|
583 { |
|
584 iEffectData->SetPeriod( KEffectPeriod1000 ); |
|
585 ModifyEffect(); |
|
586 } |
|
587 break; |
|
588 case EHapticsTestModifyEffectPeriod3000: |
|
589 { |
|
590 iEffectData->SetPeriod( KEffectPeriod3000 ); |
|
591 ModifyEffect(); |
|
592 } |
|
593 break; |
|
594 |
|
595 case EHapticsTestCloseHaptics: |
|
596 { |
|
597 CloseHaptics(); |
|
598 } |
|
599 break; |
|
600 |
|
601 case EHapticsTestSynchronousCalls: |
|
602 { |
|
603 iSynchronous = ETrue; |
|
604 iAppView->InsertOutput( _L("Using synchronous methods.") ); |
|
605 } |
|
606 break; |
|
607 |
|
608 case EHapticsTestAsynchronousCalls: |
|
609 { |
|
610 iSynchronous = EFalse; |
|
611 iAppView->InsertOutput( _L("Using asynchronous methods.") ); |
|
612 } |
|
613 break; |
|
614 |
|
615 case EHapticsTestUsingFileHandle: |
|
616 { |
|
617 iUseHandle = ETrue; |
|
618 iAppView->InsertOutput( _L("Using file handle in play methods.") ); |
|
619 } |
|
620 break; |
|
621 |
|
622 case EHapticsTestNotUsingFileHandle: |
|
623 { |
|
624 iUseHandle = EFalse; |
|
625 iAppView->InsertOutput( _L("Using data buffer in play methods.") ); |
|
626 } |
|
627 break; |
|
628 |
|
629 case EHapticsTestShowEffectInfo: |
|
630 { |
|
631 iShowEffectInfo = ETrue; |
|
632 iAppView->InsertOutput( _L("Shows information of played effect.") ); |
|
633 } |
|
634 break; |
|
635 |
|
636 case EHapticsTestHideEffectInfo: |
|
637 { |
|
638 iShowEffectInfo = EFalse; |
|
639 iAppView->InsertOutput( _L("Stops showing information of played effect.") ); |
|
640 } |
|
641 break; |
|
642 |
|
643 case EHapticsTestDeleteIVTData: |
|
644 case EHapticsTestDeleteIVTDataNoneFound: |
|
645 { |
|
646 // nothing to do |
|
647 } |
|
648 break; |
|
649 |
|
650 case EHapticsTestDeleteIVTDataSelected: |
|
651 { |
|
652 // delete selected loaded IVT file |
|
653 TInt index = iMenuPane->SelectedItem(); |
|
654 DeleteLoadedIVTData( index ); |
|
655 } |
|
656 break; |
|
657 |
|
658 case EHapticsTestDeleteAllIVTData: |
|
659 { |
|
660 // delete all loaded IVT files |
|
661 DeleteAllLoadedIVTData(); |
|
662 } |
|
663 break; |
|
664 |
|
665 case EHapticsTestReserve: |
|
666 { |
|
667 // nothing to do |
|
668 } |
|
669 case EHapticsTestReserveNotTrusted: |
|
670 { |
|
671 ReserveHaptics( iHaptics, EFalse ); |
|
672 } |
|
673 break; |
|
674 case EHapticsTestReserveTrusted: |
|
675 { |
|
676 ReserveHaptics( iHaptics, ETrue ); |
|
677 } |
|
678 break; |
|
679 case EHapticsTestReserveNotTrustedTemp: |
|
680 { |
|
681 // create the temp haptics client, if it does not exist |
|
682 if ( !iTempHaptics ) |
|
683 { |
|
684 iTempHaptics = CHWRMHaptics::NewL( NULL, NULL ); |
|
685 } |
|
686 |
|
687 ReserveHaptics( iTempHaptics, EFalse ); |
|
688 } |
|
689 break; |
|
690 case EHapticsTestRelease: |
|
691 { |
|
692 iHaptics->ReleaseHaptics(); |
|
693 iAppView->InsertOutput( _L("Reservation released.") ); |
|
694 } |
|
695 break; |
|
696 case EHapticsTestReleaseTemp: |
|
697 { |
|
698 if ( iTempHaptics ) |
|
699 { |
|
700 iTempHaptics->ReleaseHaptics(); |
|
701 iAppView->InsertOutput( _L("Temp client's reservation released.") ); |
|
702 |
|
703 delete iTempHaptics; |
|
704 iTempHaptics = NULL; |
|
705 } |
|
706 else |
|
707 { |
|
708 iAppView->InsertOutput( _L("Temp client not created/reserved.") ); |
|
709 } |
|
710 } |
|
711 break; |
|
712 |
|
713 case EHapticsTestConstGetters: |
|
714 { |
|
715 ConstGetters(); |
|
716 } |
|
717 break; |
|
718 |
|
719 case EHapticsTestGetStatus: |
|
720 { |
|
721 // fetch haptics status, and print it |
|
722 MHWRMHapticsObserver::THWRMHapticsStatus status = |
|
723 iHaptics->HapticsStatus(); |
|
724 |
|
725 if ( iTempHaptics ) |
|
726 { |
|
727 iAppView->InsertOutput( _L("[Haptics client] - "), EFalse ); |
|
728 PrintStatusInfo( status ); |
|
729 |
|
730 status = iTempHaptics->HapticsStatus(); |
|
731 iAppView->InsertOutput( _L("[Temporary client] - "), EFalse ); |
|
732 PrintStatusInfo( status ); |
|
733 } |
|
734 else |
|
735 { |
|
736 PrintStatusInfo( status ); |
|
737 } |
|
738 |
|
739 } |
|
740 break; |
|
741 |
|
742 case EHapticsTestSetPropertyPriorityMin: |
|
743 { |
|
744 SetPropertyPriorityMin(); |
|
745 } |
|
746 break; |
|
747 |
|
748 case EHapticsTestSetPropertyPriorityDefault: |
|
749 { |
|
750 SetPropertyPriorityDefault(); |
|
751 } |
|
752 break; |
|
753 |
|
754 case EHapticsTestSetPropertyPriorityMax: |
|
755 { |
|
756 SetPropertyPriorityMax(); |
|
757 } |
|
758 break; |
|
759 |
|
760 case EHapticsTestSetPropertyDisableEffectsTrue: |
|
761 { |
|
762 SetPropertyDisableEffectsTrue(); |
|
763 } |
|
764 break; |
|
765 |
|
766 case EHapticsTestSetPropertyDisableEffectsFalse: |
|
767 { |
|
768 SetPropertyDisableEffectsFalse(); |
|
769 } |
|
770 break; |
|
771 |
|
772 case EHapticsTestSetPropertyStrengthMute: |
|
773 { |
|
774 SetPropertyStrengthMin(); |
|
775 } |
|
776 break; |
|
777 |
|
778 case EHapticsTestSetPropertyStrengthHalf: |
|
779 { |
|
780 SetPropertyStrengthMiddle(); |
|
781 } |
|
782 break; |
|
783 |
|
784 case EHapticsTestSetPropertyStrengthFull: |
|
785 { |
|
786 SetPropertyStrengthMax(); |
|
787 } |
|
788 break; |
|
789 |
|
790 case EHapticsTestGetPropertyPriority: |
|
791 { |
|
792 GetPropertyPriority(); |
|
793 } |
|
794 break; |
|
795 |
|
796 case EHapticsTestGetPropertyDisableEffects: |
|
797 { |
|
798 GetPropertyDisableEffects(); |
|
799 } |
|
800 break; |
|
801 |
|
802 case EHapticsTestGetPropertyStrength: |
|
803 { |
|
804 GetPropertyStrength(); |
|
805 } |
|
806 break; |
|
807 |
|
808 |
|
809 case EHapticsTestGetCapabilityDeviceCategory: |
|
810 { |
|
811 GetCapabilityDeviceCategory(); |
|
812 } |
|
813 break; |
|
814 |
|
815 case EHapticsTestGetCapabilityMaxNestedRepeats: |
|
816 { |
|
817 GetCapabilityMaxNestedRepeats(); |
|
818 } |
|
819 break; |
|
820 |
|
821 |
|
822 case EHapticsTestGetCapabilityNumActuators: |
|
823 { |
|
824 GetCapabilityNumActuators(); |
|
825 } |
|
826 break; |
|
827 |
|
828 |
|
829 case EHapticsTestGetCapabilityActuatorType: |
|
830 { |
|
831 GetCapabilityActuatorType(); |
|
832 } |
|
833 break; |
|
834 |
|
835 |
|
836 case EHapticsTestGetCapabilityNumEffectSlots: |
|
837 { |
|
838 GetCapabilityNumEffectSlots(); |
|
839 } |
|
840 break; |
|
841 |
|
842 case EHapticsTestGetCapabilityNumEffectStyles: |
|
843 { |
|
844 GetCapabilityNumEffectStyles(); |
|
845 } |
|
846 break; |
|
847 |
|
848 case EHapticsTestGetCapabilityMinPeriod: |
|
849 { |
|
850 GetCapabilityMinPeriod(); |
|
851 } |
|
852 break; |
|
853 |
|
854 case EHapticsTestGetCapabilityMaxPeriod: |
|
855 { |
|
856 GetCapabilityMaxPeriod(); |
|
857 } |
|
858 break; |
|
859 |
|
860 case EHapticsTestGetCapabilityMaxEffectDuration: |
|
861 { |
|
862 GetCapabilityMaxEffectDuration(); |
|
863 } |
|
864 break; |
|
865 |
|
866 case EHapticsTestGetCapabilitySupportedEffects: |
|
867 { |
|
868 GetCapabilitySupportedEffects(); |
|
869 } |
|
870 break; |
|
871 |
|
872 case EHapticsTestGetCapabilityDeviceName: |
|
873 { |
|
874 GetCapabilityDeviceName(); |
|
875 } |
|
876 break; |
|
877 |
|
878 case EHapticsTestGetCapabilityMaxEnvelopeTime: |
|
879 { |
|
880 GetCapabilityMaxEnvelopeTime(); |
|
881 } |
|
882 break; |
|
883 |
|
884 case EHapticsTestGetCapabilityAPIVersionNumber: |
|
885 { |
|
886 GetCapabilityAPIVersionNumber(); |
|
887 } |
|
888 break; |
|
889 |
|
890 case EHapticsTestGetCapabilityMaxIVTSize: |
|
891 { |
|
892 GetCapabilityMaxIVTSize(); |
|
893 } |
|
894 break; |
|
895 |
|
896 case EHapticsTestClearOutput: |
|
897 { |
|
898 iAppView->ClearOutput(); |
|
899 } |
|
900 break; |
|
901 |
|
902 case EHapticsTestStreaming: |
|
903 { |
|
904 StartStreaming(); |
|
905 } |
|
906 break; |
|
907 |
|
908 case EHapticsTestPlayStreamSample: |
|
909 case EHapticsTestNextStreamSample: |
|
910 { |
|
911 PlayStreamingSample( iCurrentSample ); |
|
912 iCurrentSample >= KSampleCount ? iCurrentSample = 0 : iCurrentSample++; |
|
913 } |
|
914 break; |
|
915 |
|
916 case EHapticsTestPlayAllSamples: |
|
917 { |
|
918 for ( TInt n = 0; n < 8; n++ ) |
|
919 { |
|
920 PlayStreamingSample( n ); |
|
921 User::After( 300000 ); |
|
922 } |
|
923 } |
|
924 break; |
|
925 |
|
926 case EHapticsTestStopStreaming: |
|
927 { |
|
928 StopStreaming(); |
|
929 } |
|
930 break; |
|
931 |
|
932 case EHapticsTestPanic: |
|
933 default: |
|
934 Panic( EHapticsTestBasicUi ); |
|
935 break; |
|
936 } |
|
937 } |
|
938 |
|
939 // --------------------------------------------------------- |
|
940 // Manages the options menu contents based on user actions and data. |
|
941 // --------------------------------------------------------- |
|
942 // |
|
943 void CHapticsTestAppUi::DynInitMenuPaneL( TInt aResourceId, |
|
944 CEikMenuPane* aMenuPane ) |
|
945 { |
|
946 CAknAppUi::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
947 |
|
948 // store menupane to be used in HandleCommandL() |
|
949 iMenuPane = aMenuPane; |
|
950 |
|
951 if ( aResourceId == R_HAPTICSTEST_MENU ) |
|
952 { |
|
953 if ( !iHaptics ) |
|
954 { |
|
955 // haptics client not created, hide commands using it |
|
956 aMenuPane->SetItemDimmed( EHapticsTestReserve, ETrue ); |
|
957 aMenuPane->SetItemDimmed( EHapticsTestConstGetters, ETrue ); |
|
958 aMenuPane->SetItemDimmed( EHapticsTestGetStatus, ETrue ); |
|
959 } |
|
960 if ( !iActuatorOpened ) |
|
961 { |
|
962 // Actuator has not been opened yet, hide ivt-file loading |
|
963 // submenu and general play-submenu |
|
964 aMenuPane->SetItemDimmed( EHapticsTestGeneralPlayEffect, ETrue ); |
|
965 aMenuPane->SetItemDimmed( EHapticsTestLoadIVTFile, ETrue ); |
|
966 aMenuPane->SetItemDimmed( EHapticsTestPropertiesSubmenu, ETrue ); |
|
967 aMenuPane->SetItemDimmed( EHapticsTestCapabilitiesSubmenu, ETrue ); |
|
968 aMenuPane->SetItemDimmed( EHapticsTestStreaming, ETrue ); |
|
969 } |
|
970 if ( 0 == iLoadedIVTFileArray.Count() ) |
|
971 { |
|
972 // also hide the deleteIVT data related menu items |
|
973 aMenuPane->SetItemDimmed( EHapticsTestDeleteIVTData, ETrue ); |
|
974 aMenuPane->SetItemDimmed( EHapticsTestDeleteAllIVTData, ETrue ); |
|
975 } |
|
976 if ( !iEffectData->Count() ) |
|
977 { |
|
978 // hide the pause/resume/stop submenu |
|
979 aMenuPane->SetItemDimmed( EHapticsTestChangeState, ETrue ); |
|
980 } |
|
981 if ( !iEffectData->ModifiableEffectExists() ) |
|
982 { |
|
983 aMenuPane->SetItemDimmed( EHapticsTestModifyEffect, ETrue ); |
|
984 } |
|
985 if ( iStreaming ) |
|
986 { |
|
987 aMenuPane->SetItemDimmed( EHapticsTestStreaming, ETrue ); |
|
988 aMenuPane->SetItemDimmed( EHapticsTestReserve, ETrue ); |
|
989 aMenuPane->SetItemDimmed( EHapticsTestLoadIVTFile, ETrue ); |
|
990 aMenuPane->SetItemDimmed( EHapticsTestGeneralPlayEffect, ETrue ); |
|
991 aMenuPane->SetItemDimmed( EHapticsTestChangeState, ETrue ); |
|
992 aMenuPane->SetItemDimmed( EHapticsTestModifyEffect, ETrue ); |
|
993 aMenuPane->SetItemDimmed( EHapticsTestDeleteIVTData, ETrue ); |
|
994 aMenuPane->SetItemDimmed( EHapticsTestPropertiesSubmenu, ETrue ); |
|
995 aMenuPane->SetItemDimmed( EHapticsTestCapabilitiesSubmenu, ETrue ); |
|
996 aMenuPane->SetItemDimmed( EHapticsTestDeleteAllIVTData, ETrue ); |
|
997 aMenuPane->SetItemDimmed( EHapticsTestGetStatus, ETrue ); |
|
998 aMenuPane->SetItemDimmed( EHapticsTestConstGetters, ETrue ); |
|
999 aMenuPane->SetItemDimmed( EHapticsTestClearOutput, ETrue ); |
|
1000 aMenuPane->SetItemDimmed( EHapticsTestPanic, ETrue ); |
|
1001 aMenuPane->SetItemDimmed( EHapticsTestInit, ETrue ); |
|
1002 aMenuPane->SetItemDimmed( EHapticsToggle, ETrue ); |
|
1003 aMenuPane->SetItemDimmed( EAknSoftkeyExit, ETrue ); |
|
1004 aMenuPane->SetItemDimmed( EHapticsTestPlayStreamSample, iCurrentSample ); |
|
1005 aMenuPane->SetItemDimmed( EHapticsTestNextStreamSample, !iCurrentSample ); |
|
1006 } |
|
1007 else |
|
1008 { |
|
1009 aMenuPane->SetItemDimmed( EHapticsTestPlayAllSamples, ETrue ); |
|
1010 aMenuPane->SetItemDimmed( EHapticsTestPlayStreamSample, ETrue ); |
|
1011 aMenuPane->SetItemDimmed( EHapticsTestNextStreamSample, ETrue ); |
|
1012 aMenuPane->SetItemDimmed( EHapticsTestStopStreaming, ETrue ); |
|
1013 } |
|
1014 } |
|
1015 else if ( aResourceId == R_HAPTICSTEST_INIT_SUBMENU ) |
|
1016 { |
|
1017 if ( !iHaptics ) |
|
1018 { |
|
1019 // haptics client not created, hide commands using it |
|
1020 aMenuPane->SetItemDimmed( EHapticsTestSupportedActuators, ETrue ); |
|
1021 aMenuPane->SetItemDimmed( EHapticsTestOpenActuator, ETrue ); |
|
1022 } |
|
1023 if ( !iSupportedActuators ) |
|
1024 { |
|
1025 // either there are no supported actuators, or they have not |
|
1026 // been fethed yet --> hide actuator opening submenu |
|
1027 aMenuPane->SetItemDimmed( EHapticsTestOpenActuator, ETrue ); |
|
1028 } |
|
1029 } |
|
1030 else if ( aResourceId == R_HAPTICSTEST_GENERALPLAY_SUBMENU ) |
|
1031 { |
|
1032 if ( !iActuatorOpened ) |
|
1033 { |
|
1034 // Actuator has not been opened yet, hide the manual effect |
|
1035 // play submenu |
|
1036 aMenuPane->SetItemDimmed( EHapticsTestPlayEffectManual, ETrue ); |
|
1037 } |
|
1038 if ( 0 == iLoadedIVTFileArray.Count() ) |
|
1039 { |
|
1040 // IVT-data has not been loaded, hide the effect submenu |
|
1041 aMenuPane->SetItemDimmed( EHapticsTestPlayEffect, ETrue ); |
|
1042 aMenuPane->SetItemDimmed( EHapticsTestPlayEffectRepeat, ETrue ); |
|
1043 } |
|
1044 } |
|
1045 else if ( aResourceId == R_HAPTICSTEST_TOGGLE_SUBMENU ) |
|
1046 { |
|
1047 if ( iSynchronous ) |
|
1048 { |
|
1049 // synchronous calls in ON, hide synchronous call selection |
|
1050 aMenuPane->SetItemDimmed( EHapticsTestSynchronousCalls, ETrue ); |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 // asynchronous calls in ON, hide asynchronous call selection |
|
1055 aMenuPane->SetItemDimmed( EHapticsTestAsynchronousCalls, ETrue ); |
|
1056 } |
|
1057 if ( iUseHandle ) |
|
1058 { |
|
1059 aMenuPane->SetItemDimmed( EHapticsTestUsingFileHandle, ETrue ); |
|
1060 if ( iShowEffectInfo ) |
|
1061 { |
|
1062 aMenuPane->SetItemDimmed( EHapticsTestShowEffectInfo, ETrue ); |
|
1063 } |
|
1064 else |
|
1065 { |
|
1066 aMenuPane->SetItemDimmed( EHapticsTestHideEffectInfo, ETrue ); |
|
1067 } |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 aMenuPane->SetItemDimmed( EHapticsTestNotUsingFileHandle, ETrue ); |
|
1072 aMenuPane->SetItemDimmed( EHapticsTestShowEffectInfo, ETrue ); |
|
1073 aMenuPane->SetItemDimmed( EHapticsTestHideEffectInfo, ETrue ); |
|
1074 } |
|
1075 } |
|
1076 else if ( aResourceId == R_HAPTICSTEST_ACTUATORS_SUBMENU ) |
|
1077 { |
|
1078 if ( !(EHWRMLogicalActuatorAny & iSupportedActuators) ) |
|
1079 { |
|
1080 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorAny, ETrue ); |
|
1081 } |
|
1082 if ( !(EHWRMLogicalActuatorDevice & iSupportedActuators) ) |
|
1083 { |
|
1084 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorDevice, ETrue ); |
|
1085 } |
|
1086 if ( !(EHWRMLogicalActuatorPrimaryDisplay & iSupportedActuators) ) |
|
1087 { |
|
1088 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorPrimaryDisplay, ETrue ); |
|
1089 } |
|
1090 if ( !(EHWRMLogicalActuatorSecondaryDisplay & iSupportedActuators) ) |
|
1091 { |
|
1092 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorSecondaryDisplay, ETrue ); |
|
1093 } |
|
1094 if ( !(EHWRMLogicalActuatorGame & iSupportedActuators) ) |
|
1095 { |
|
1096 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorGame, ETrue ); |
|
1097 } |
|
1098 if ( !(EHWRMLogicalActuatorGameLeft & iSupportedActuators) ) |
|
1099 { |
|
1100 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorGameLeft, ETrue ); |
|
1101 } |
|
1102 if ( !(EHWRMLogicalActuatorGameRight & iSupportedActuators) ) |
|
1103 { |
|
1104 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorGameRight, ETrue ); |
|
1105 } |
|
1106 if ( !(EHWRMLogicalActuatorExternalVibra & iSupportedActuators) ) |
|
1107 { |
|
1108 aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorExternalVibra, ETrue ); |
|
1109 } |
|
1110 } |
|
1111 else if ( aResourceId == R_HAPTICSTEST_IVTFILES_SUBMENU ) |
|
1112 { |
|
1113 if ( iIVTFileArray.Count() ) |
|
1114 { |
|
1115 // ivt-files present, hide the "no files" -item |
|
1116 aMenuPane->SetItemDimmed( EHapticsTestLoadIVTFileNoneFound, ETrue ); |
|
1117 |
|
1118 // make file names visible in the submenu |
|
1119 CEikMenuPaneItem::SData data; |
|
1120 for ( TInt i = 0; i < iIVTFileArray.Count(); ++i ) |
|
1121 { |
|
1122 data.iText.Copy( iIVTFileArray[i] ); |
|
1123 data.iCommandId = EHapticsTestLoadIVTFileSelected; |
|
1124 data.iCascadeId = 0; |
|
1125 data.iFlags = 0; |
|
1126 data.iExtraText = KNullDesC; |
|
1127 |
|
1128 aMenuPane->AddMenuItemL( data ); |
|
1129 } |
|
1130 } |
|
1131 } |
|
1132 else if ( aResourceId == R_HAPTICSTEST_PLAYEFFECT_SUBMENU ) |
|
1133 { |
|
1134 CreatePlayEffectSubmenuL( aMenuPane, |
|
1135 EHapticsTestPlayEffectSelected, |
|
1136 EHapticsTestPlayEffectNoneFound ); |
|
1137 } |
|
1138 else if ( aResourceId == R_HAPTICSTEST_PLAYEFFECTREPEAT_SUBMENU ) |
|
1139 { |
|
1140 CreatePlayEffectSubmenuL( aMenuPane, |
|
1141 EHapticsTestPlayEffectRepeatSelected, |
|
1142 EHapticsTestPlayEffectRepeatNoneFound ); |
|
1143 } |
|
1144 else if ( aResourceId == R_HAPTICSTEST_DELETEIVTDATA_SUBMENU ) |
|
1145 { |
|
1146 if ( iLoadedIVTFileArray.Count() ) |
|
1147 { |
|
1148 // loaded ivt-files present, hide the "no files" -item |
|
1149 aMenuPane->SetItemDimmed( EHapticsTestDeleteIVTDataNoneFound, ETrue ); |
|
1150 |
|
1151 // make loaded ivt-files visible in the submenu |
|
1152 CEikMenuPaneItem::SData data; |
|
1153 for ( TInt i = 0; i < iLoadedIVTFileArray.Count(); ++i ) |
|
1154 { |
|
1155 data.iText.Copy( iLoadedIVTFileArray[i].iFileName ); |
|
1156 data.iCommandId = EHapticsTestDeleteIVTDataSelected; |
|
1157 data.iCascadeId = 0; |
|
1158 data.iFlags = 0; |
|
1159 data.iExtraText = KNullDesC; |
|
1160 |
|
1161 aMenuPane->AddMenuItemL( data ); |
|
1162 } |
|
1163 } |
|
1164 } |
|
1165 else if ( aResourceId == R_HAPTICSTEST_PAUSE_SUBMENU ) |
|
1166 { |
|
1167 // fill effect history data to pause submenu |
|
1168 iEffectData->DynInitChangeEffectStateSubmenuL( |
|
1169 aMenuPane, EHapticsTestChangeStatePause, iHaptics ); |
|
1170 } |
|
1171 else if ( aResourceId == R_HAPTICSTEST_RESUME_SUBMENU ) |
|
1172 { |
|
1173 // fill effect history data to resume submenu |
|
1174 iEffectData->DynInitChangeEffectStateSubmenuL( |
|
1175 aMenuPane, EHapticsTestChangeStateResume, iHaptics ); |
|
1176 } |
|
1177 else if ( aResourceId == R_HAPTICSTEST_STOP_SUBMENU ) |
|
1178 { |
|
1179 // fill effect history data to stop submenu |
|
1180 iEffectData->DynInitChangeEffectStateSubmenuL( |
|
1181 aMenuPane, EHapticsTestChangeStateStop, iHaptics ); |
|
1182 } |
|
1183 else if ( aResourceId == R_HAPTICSTEST_MODIFYDURATION_SUBMENU ) |
|
1184 { |
|
1185 iEffectData->DynInitDurationSubmenu( aMenuPane ); |
|
1186 } |
|
1187 else if ( aResourceId == R_HAPTICSTEST_MODIFYMAGNITUDE_SUBMENU ) |
|
1188 { |
|
1189 iEffectData->DynInitMagnitudeSubmenu( aMenuPane ); |
|
1190 } |
|
1191 else if ( aResourceId == R_HAPTICSTEST_MODIFYSTYLE_SUBMENU ) |
|
1192 { |
|
1193 iEffectData->DynInitStyleSubmenu( aMenuPane ); |
|
1194 } |
|
1195 else if ( aResourceId == R_HAPTICSTEST_MODIFYATTACK_SUBMENU ) |
|
1196 { |
|
1197 iEffectData->DynInitAttackLevelSubmenu( aMenuPane ); |
|
1198 } |
|
1199 else if ( aResourceId == R_HAPTICSTEST_MODIFYFADE_SUBMENU ) |
|
1200 { |
|
1201 iEffectData->DynInitFadeLevelSubmenu( aMenuPane ); |
|
1202 } |
|
1203 else if ( aResourceId == R_HAPTICSTEST_MODIFYATTACKTIME_SUBMENU ) |
|
1204 { |
|
1205 iEffectData->DynInitAttackTimeSubmenu( aMenuPane ); |
|
1206 } |
|
1207 else if ( aResourceId == R_HAPTICSTEST_MODIFYFADETIME_SUBMENU ) |
|
1208 { |
|
1209 iEffectData->DynInitFadeTimeSubmenu( aMenuPane ); |
|
1210 } |
|
1211 else if ( aResourceId == R_HAPTICSTEST_MODIFYPERIOD_SUBMENU ) |
|
1212 { |
|
1213 iEffectData->DynInitPeriodSubmenu( aMenuPane ); |
|
1214 } |
|
1215 } |
|
1216 |
|
1217 // --------------------------------------------------------- |
|
1218 // |
|
1219 // --------------------------------------------------------- |
|
1220 // |
|
1221 void CHapticsTestAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination) |
|
1222 { |
|
1223 CAknAppUi::HandleWsEventL(aEvent, aDestination); |
|
1224 |
|
1225 TInt eventType = aEvent.Type(); |
|
1226 if (eventType == EEventKeyUp) |
|
1227 { |
|
1228 TKeyEvent key = *(aEvent.Key()); |
|
1229 GetAliasKeyCodeL(key.iCode, key, EEventKey); |
|
1230 TUint code = key.iScanCode; |
|
1231 |
|
1232 if (code == '5' && !iActuatorOpened ) |
|
1233 { |
|
1234 HandleCommandL(EHapticsTestOpenHaptics); // open client |
|
1235 HandleCommandL(EHapticsTestSupportedActuators); // ask supported actuators |
|
1236 HandleCommandL(EHapticsTestOpenActuatorAny); // open any actuator |
|
1237 |
|
1238 HandleCommandL(EHapticsTestGetCapabilityDeviceName); |
|
1239 } |
|
1240 } |
|
1241 } |
|
1242 |
|
1243 // --------------------------------------------------------- |
|
1244 // Prints received haptics status notifications onto |
|
1245 // the screen. |
|
1246 // --------------------------------------------------------- |
|
1247 // |
|
1248 void CHapticsTestAppUi::HapticsStatusChangedL( THWRMHapticsStatus aStatus ) |
|
1249 { |
|
1250 PrintStatusInfo( aStatus ); |
|
1251 } |
|
1252 |
|
1253 // --------------------------------------------------------- |
|
1254 // Empty implementation. |
|
1255 // --------------------------------------------------------- |
|
1256 // |
|
1257 void CHapticsTestAppUi::EffectCompletedL( TInt /*aError*/, |
|
1258 TInt /*aEffectHandle*/ ) |
|
1259 { |
|
1260 } |
|
1261 |
|
1262 // --------------------------------------------------------- |
|
1263 // Outputs received actuator events onto the screen. |
|
1264 // --------------------------------------------------------- |
|
1265 // |
|
1266 void CHapticsTestAppUi::ActuatorEventL( THWRMActuatorEvents aEvent, |
|
1267 THWRMLogicalActuators aActuator ) |
|
1268 { |
|
1269 // actuator name |
|
1270 TBuf<64> actuator; |
|
1271 switch( aActuator ) |
|
1272 { |
|
1273 case EHWRMLogicalActuatorAny: |
|
1274 actuator.Append( _L("Any") ); |
|
1275 break; |
|
1276 case EHWRMLogicalActuatorDevice: |
|
1277 actuator.Append( _L("Device") ); |
|
1278 break; |
|
1279 case EHWRMLogicalActuatorPrimaryDisplay: |
|
1280 actuator.Append( _L("PrimaryDisplay") ); |
|
1281 break; |
|
1282 case EHWRMLogicalActuatorSecondaryDisplay: |
|
1283 actuator.Append( _L("SecondaryDisplay") ); |
|
1284 break; |
|
1285 case EHWRMLogicalActuatorGame: |
|
1286 actuator.Append( _L("Game") ); |
|
1287 break; |
|
1288 case EHWRMLogicalActuatorGameLeft: |
|
1289 actuator.Append( _L("GameLeft") ); |
|
1290 break; |
|
1291 case EHWRMLogicalActuatorGameRight: |
|
1292 actuator.Append( _L("GameRight") ); |
|
1293 break; |
|
1294 case EHWRMLogicalActuatorExternalVibra: |
|
1295 actuator.Append( _L("ExternalVibra") ); |
|
1296 break; |
|
1297 default: |
|
1298 actuator.Append( _L("<unknown>") ); |
|
1299 break; |
|
1300 } |
|
1301 |
|
1302 iAppView->InsertOutput( _L("Received actuator event: "), EFalse ); |
|
1303 iAppView->InsertOutput( actuator, EFalse ); |
|
1304 |
|
1305 switch( aEvent ) |
|
1306 { |
|
1307 case MHWRMHapticsActuatorObserver::EHWRMActuatorAttached: |
|
1308 { |
|
1309 iAppView->InsertOutput( _L(" Attached.") ); |
|
1310 break; |
|
1311 } |
|
1312 case MHWRMHapticsActuatorObserver::EHWRMActuatorDetached: |
|
1313 { |
|
1314 iAppView->InsertOutput( _L(" Deattached.") ); |
|
1315 break; |
|
1316 } |
|
1317 case MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled: |
|
1318 { |
|
1319 iAppView->InsertOutput( _L(" Enabled.") ); |
|
1320 break; |
|
1321 } |
|
1322 case MHWRMHapticsActuatorObserver::EHWRMActuatorDisabled: |
|
1323 { |
|
1324 iAppView->InsertOutput( _L(" Disabled.") ); |
|
1325 break; |
|
1326 } |
|
1327 default: |
|
1328 { |
|
1329 iAppView->InsertOutput( _L(" <unknown status>") ); |
|
1330 break; |
|
1331 } |
|
1332 } |
|
1333 } |
|
1334 |
|
1335 // --------------------------------------------------------- |
|
1336 // Creates haptics client instance. |
|
1337 // --------------------------------------------------------- |
|
1338 // |
|
1339 void CHapticsTestAppUi::OpenHapticsL() |
|
1340 { |
|
1341 if ( iHaptics ) |
|
1342 { |
|
1343 iAppView->InsertOutput( _L("Already created.") ); |
|
1344 } |
|
1345 else |
|
1346 { |
|
1347 // Create haptics client |
|
1348 if ( iSynchronous ) |
|
1349 { |
|
1350 iHaptics = CHWRMHaptics::NewL( this, this ); |
|
1351 } |
|
1352 else |
|
1353 { |
|
1354 // asynchronous creation |
|
1355 TRequestStatus status; |
|
1356 iHaptics = CHWRMHaptics::NewL( this, this, status ); |
|
1357 User::WaitForRequest( status ); |
|
1358 User::LeaveIfError( status.Int() ); |
|
1359 } |
|
1360 |
|
1361 if ( iHaptics ) |
|
1362 { |
|
1363 iAppView->InsertOutput( _L("Haptics client created.") ); |
|
1364 } |
|
1365 else |
|
1366 { |
|
1367 iAppView->InsertOutput( _L("Error: Creation failed.") ); |
|
1368 } |
|
1369 } |
|
1370 } |
|
1371 |
|
1372 // --------------------------------------------------------- |
|
1373 // Deletes haptics client instance, and resets member variables |
|
1374 // so that options-menu is updated accordingly. |
|
1375 // --------------------------------------------------------- |
|
1376 // |
|
1377 void CHapticsTestAppUi::CloseHaptics() |
|
1378 { |
|
1379 if( iHaptics ) |
|
1380 { |
|
1381 delete iHaptics; |
|
1382 iHaptics = NULL; |
|
1383 iAppView->InsertOutput( _L("Haptics client deleted.") ); |
|
1384 |
|
1385 // uninit members |
|
1386 iSupportedActuators = 0; |
|
1387 iActuatorOpened = EFalse; |
|
1388 iIVTFileHandle = 0; |
|
1389 |
|
1390 while ( iLoadedIVTFileArray.Count() ) |
|
1391 { |
|
1392 if ( iLoadedIVTFileArray[0].iDataBuffer ) |
|
1393 { |
|
1394 delete iLoadedIVTFileArray[0].iDataBuffer; |
|
1395 iLoadedIVTFileArray[0].iDataBuffer = NULL; |
|
1396 } |
|
1397 iLoadedIVTFileArray.Remove( 0 ); |
|
1398 } |
|
1399 |
|
1400 iIVTDataBuffer = NULL; |
|
1401 } |
|
1402 else |
|
1403 { |
|
1404 iAppView->InsertOutput( _L("Error: Haptics client doesn\'t exist.") ); |
|
1405 } |
|
1406 } |
|
1407 |
|
1408 // --------------------------------------------------------- |
|
1409 // Fetches the supported actuators from haptics server, |
|
1410 // and stores the mask to iSupportedActuators. |
|
1411 // --------------------------------------------------------- |
|
1412 // |
|
1413 void CHapticsTestAppUi::FetchSupportedActuators() |
|
1414 { |
|
1415 TInt err = iHaptics->SupportedActuators( iSupportedActuators ); |
|
1416 |
|
1417 if ( err ) |
|
1418 { |
|
1419 iAppView->InsertOutput( _L("Error: Getting supported actuators failed.") ); |
|
1420 } |
|
1421 else |
|
1422 { |
|
1423 PrintSupportedActuators(); |
|
1424 } |
|
1425 } |
|
1426 |
|
1427 // --------------------------------------------------------- |
|
1428 // Prints the given supported actuators to the UI. |
|
1429 // --------------------------------------------------------- |
|
1430 // |
|
1431 void CHapticsTestAppUi::PrintSupportedActuators() |
|
1432 { |
|
1433 iAppView->InsertOutput( _L("Supported actuators:") ); |
|
1434 |
|
1435 if( EHWRMLogicalActuatorAny & iSupportedActuators ) |
|
1436 { |
|
1437 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorAny") ); |
|
1438 } |
|
1439 if( EHWRMLogicalActuatorDevice & iSupportedActuators ) |
|
1440 { |
|
1441 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorDevice") ); |
|
1442 } |
|
1443 if( EHWRMLogicalActuatorPrimaryDisplay & iSupportedActuators ) |
|
1444 { |
|
1445 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorPrimaryDisplay") ); |
|
1446 } |
|
1447 if( EHWRMLogicalActuatorSecondaryDisplay & iSupportedActuators ) |
|
1448 { |
|
1449 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorSecondaryDisplay") ); |
|
1450 } |
|
1451 if( EHWRMLogicalActuatorGame & iSupportedActuators ) |
|
1452 { |
|
1453 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorGame") ); |
|
1454 } |
|
1455 if( EHWRMLogicalActuatorGameLeft & iSupportedActuators ) |
|
1456 { |
|
1457 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorGameLeft") ); |
|
1458 } |
|
1459 if( EHWRMLogicalActuatorGameRight & iSupportedActuators ) |
|
1460 { |
|
1461 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorGameRight") ); |
|
1462 } |
|
1463 if( EHWRMLogicalActuatorExternalVibra & iSupportedActuators ) |
|
1464 { |
|
1465 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorExternalVibra") ); |
|
1466 } |
|
1467 if( EHWRMLogicalActuatorLast & iSupportedActuators ) |
|
1468 { |
|
1469 // ????? |
|
1470 iAppView->InsertOutput( _L(" EHWRMLogicalActuatorLast") ); |
|
1471 } |
|
1472 } |
|
1473 |
|
1474 // --------------------------------------------------------- |
|
1475 // Attemps to open the given actuator. Prints the result |
|
1476 // of the attemp to the UI. |
|
1477 // --------------------------------------------------------- |
|
1478 // |
|
1479 void CHapticsTestAppUi::OpenActuator( THWRMLogicalActuators aActuator ) |
|
1480 { |
|
1481 TRAPD( err, iHaptics->OpenActuatorL( aActuator ) ); |
|
1482 TBuf<100> buf; |
|
1483 if ( err ) |
|
1484 { |
|
1485 buf.Append( _L("Error: Opening actuator failed; ") ); |
|
1486 buf.AppendNum( err ); |
|
1487 iAppView->InsertOutput( buf ); |
|
1488 |
|
1489 iActuatorOpened = EFalse; |
|
1490 } |
|
1491 else |
|
1492 { |
|
1493 iAppView->InsertOutput( _L("Actuator opened successfully.") ); |
|
1494 |
|
1495 iActuatorOpened = ETrue; |
|
1496 |
|
1497 TInt err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsLicensekey, |
|
1498 KNullDesC8() ); |
|
1499 if (err) |
|
1500 { |
|
1501 buf.Append( _L("Error: Setting licensefailed: ") ); |
|
1502 buf.AppendNum( err ); |
|
1503 iAppView->InsertOutput( buf ); |
|
1504 |
|
1505 iActuatorOpened = EFalse; |
|
1506 return; |
|
1507 } |
|
1508 iAppView->InsertOutput( _L("License is set.") ); |
|
1509 |
|
1510 err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, |
|
1511 KHWRMHapticsMaxDevicePriority ); |
|
1512 |
|
1513 } |
|
1514 } |
|
1515 |
|
1516 // --------------------------------------------------------- |
|
1517 // Reserves haptics for this application. |
|
1518 // --------------------------------------------------------- |
|
1519 // |
|
1520 void CHapticsTestAppUi::ReserveHaptics( CHWRMHaptics* aHaptics, |
|
1521 TBool aForceNoCoe ) |
|
1522 { |
|
1523 TInt err = KErrNone; |
|
1524 TBuf<24> forceNoCoe; |
|
1525 |
|
1526 if ( aForceNoCoe ) |
|
1527 { |
|
1528 forceNoCoe.Append( _L("(trusted).") ); |
|
1529 TRAP( err, aHaptics->ReserveHapticsL( ETrue ) ); |
|
1530 } |
|
1531 else |
|
1532 { |
|
1533 forceNoCoe.Append( _L("(not trusted).") ); |
|
1534 TRAP( err, aHaptics->ReserveHapticsL() ); |
|
1535 } |
|
1536 |
|
1537 if ( err ) |
|
1538 { |
|
1539 TBuf<8> errorCode; |
|
1540 errorCode.AppendNum( err ); |
|
1541 |
|
1542 iAppView->InsertOutput( _L("Reserving haptics failed err = "), EFalse ); |
|
1543 iAppView->InsertOutput( errorCode ); |
|
1544 } |
|
1545 else |
|
1546 { |
|
1547 iAppView->InsertOutput( _L("Reserved haptics "), EFalse ); |
|
1548 iAppView->InsertOutput( forceNoCoe ); |
|
1549 } |
|
1550 } |
|
1551 |
|
1552 // --------------------------------------------------------- |
|
1553 // Searches for IVT-files in the filesystem, and writes |
|
1554 // them to iIVTFileArray. |
|
1555 // --------------------------------------------------------- |
|
1556 // |
|
1557 void CHapticsTestAppUi::FindIVTFiles() |
|
1558 { |
|
1559 iAppView->InsertOutput( _L("Searching IVT-files...") ); |
|
1560 |
|
1561 // open file server session |
|
1562 RFs rfs; |
|
1563 TInt err = rfs.Connect(); |
|
1564 |
|
1565 if ( err ) |
|
1566 { |
|
1567 iAppView->InsertOutput( _L("Error occured while opening fileserver session!") ); |
|
1568 return; |
|
1569 } |
|
1570 |
|
1571 // set path where to search files |
|
1572 CDir* dirList = 0; |
|
1573 TInt memCrdUsageErr = KErrNone; |
|
1574 |
|
1575 #ifdef __MARM_ARMV5__ |
|
1576 // first, try to use mem card.. (in ARMV5 builds) |
|
1577 memCrdUsageErr = rfs.SetSessionPath( KSessionPathCrd ); |
|
1578 |
|
1579 if ( !memCrdUsageErr ) |
|
1580 { |
|
1581 memCrdUsageErr = rfs.GetDir( KIVTFileType, KEntryAttMaskSupported, |
|
1582 ESortByName, dirList ); |
|
1583 } |
|
1584 if ( !memCrdUsageErr && dirList ) |
|
1585 { |
|
1586 iUsesMemCard = ETrue; |
|
1587 } |
|
1588 #endif |
|
1589 |
|
1590 if ( !iUsesMemCard ) |
|
1591 { |
|
1592 // secondly, try to use phone mem.. (actually first in non-ARMV5 builds) |
|
1593 err = rfs.SetSessionPath( KSessionPathMem ); |
|
1594 |
|
1595 if ( err ) |
|
1596 { |
|
1597 iAppView->InsertOutput( _L("Setting path for fileserver failed!") ); |
|
1598 return; |
|
1599 } |
|
1600 |
|
1601 // get directory file listing of IVT-files |
|
1602 err = rfs.GetDir( KIVTFileType, KEntryAttMaskSupported, |
|
1603 ESortByName, dirList ); |
|
1604 |
|
1605 if ( err || !dirList ) |
|
1606 { |
|
1607 iAppView->InsertOutput( _L("Fetching folder content failed!") ); |
|
1608 return; |
|
1609 } |
|
1610 } |
|
1611 |
|
1612 // file server session not needed anymore, close it |
|
1613 rfs.Close(); |
|
1614 |
|
1615 // go through all found ivt-files and read directory |
|
1616 // entries to filenamearray |
|
1617 for( TInt i = 0; i < dirList->Count(); i++ ) |
|
1618 { |
|
1619 iIVTFileArray.Append( (*dirList)[i].iName ); |
|
1620 |
|
1621 // print findings to the UI |
|
1622 iAppView->InsertOutput( _L(" "), EFalse ); |
|
1623 iAppView->InsertOutput( (*dirList)[i].iName ); |
|
1624 } |
|
1625 |
|
1626 delete dirList; |
|
1627 dirList = NULL; |
|
1628 } |
|
1629 |
|
1630 // --------------------------------------------------------- |
|
1631 // Loads IVT data from the given file to haptics. |
|
1632 // --------------------------------------------------------- |
|
1633 // |
|
1634 void CHapticsTestAppUi::LoadIVTDataL( TFileName& aFile ) |
|
1635 { |
|
1636 // open file server session |
|
1637 RFs rfs; |
|
1638 if ( rfs.Connect() ) |
|
1639 { |
|
1640 iAppView->InsertOutput( _L("Error occured while opening fileserver session!") ); |
|
1641 return; |
|
1642 } |
|
1643 |
|
1644 // set path where to search files |
|
1645 #ifdef __MARM_ARMV5__ |
|
1646 if ( iUsesMemCard ) |
|
1647 { |
|
1648 rfs.SetSessionPath( KSessionPathCrd ); |
|
1649 } |
|
1650 else |
|
1651 { |
|
1652 #endif |
|
1653 |
|
1654 rfs.SetSessionPath( KSessionPathMem ); |
|
1655 |
|
1656 #ifdef __MARM_ARMV5__ |
|
1657 } |
|
1658 #endif |
|
1659 |
|
1660 RFile effectFile; |
|
1661 TInt fileSize( 0 ); |
|
1662 |
|
1663 User::LeaveIfError( effectFile.Open( rfs, aFile, EFileRead ) ); |
|
1664 |
|
1665 effectFile.Size( fileSize ); |
|
1666 |
|
1667 // create buffer for the IVT-data |
|
1668 HBufC8* IVTDataBuffer = HBufC8::NewLC( fileSize ); |
|
1669 TPtr8 dataBufPtr = IVTDataBuffer->Des(); |
|
1670 |
|
1671 // read the data from file to buffer |
|
1672 effectFile.Read( dataBufPtr ); |
|
1673 |
|
1674 // close file handle and file server session |
|
1675 effectFile.Close(); |
|
1676 rfs.Close(); |
|
1677 |
|
1678 // load data to haptics |
|
1679 TInt IVTFileHandle = 0; |
|
1680 TInt err = iHaptics->LoadEffectData( *IVTDataBuffer, IVTFileHandle ); |
|
1681 |
|
1682 if ( err ) |
|
1683 { |
|
1684 CleanupStack::PopAndDestroy( IVTDataBuffer ); |
|
1685 |
|
1686 if ( err == KErrAlreadyExists ) |
|
1687 { |
|
1688 iAppView->InsertOutput( _L("IVT-data already loaded!") ); |
|
1689 } |
|
1690 else |
|
1691 { |
|
1692 iAppView->InsertOutput( _L("Error loading IVT-data!") ); |
|
1693 } |
|
1694 } |
|
1695 else |
|
1696 { |
|
1697 TInt count; |
|
1698 iHaptics->GetEffectCount( IVTFileHandle, count ); |
|
1699 |
|
1700 TLoadedIVTFileItem newItem; |
|
1701 newItem.iFileName.Copy( aFile ); |
|
1702 newItem.iFileHandle = IVTFileHandle; |
|
1703 newItem.iDataBuffer = IVTDataBuffer; |
|
1704 if ( KErrNotFound == iLoadedIVTFileArray.Find( newItem, TIdentityRelation<TLoadedIVTFileItem>( TLoadedIVTFileItem::Match ) ) ) |
|
1705 { |
|
1706 iLoadedIVTFileArray.AppendL( newItem ); |
|
1707 CleanupStack::Pop( IVTDataBuffer ); // ownership now in the array |
|
1708 TBuf<24> handleBuf; |
|
1709 handleBuf.AppendNum( IVTFileHandle ); |
|
1710 iAppView->InsertOutput( _L("IVT-data loaded succesfully!") ); |
|
1711 iAppView->InsertOutput( _L(" File: "), EFalse ); |
|
1712 iAppView->InsertOutput( aFile ); |
|
1713 iAppView->InsertOutput( _L(" FileHandle: "), EFalse ); |
|
1714 iAppView->InsertOutput( handleBuf, EFalse ); |
|
1715 } |
|
1716 else |
|
1717 { |
|
1718 CleanupStack::PopAndDestroy( IVTDataBuffer ); |
|
1719 iAppView->InsertOutput( _L("IVT-data already loaded!") ); |
|
1720 iAppView->InsertOutput( _L(" File: "), EFalse ); |
|
1721 iAppView->InsertOutput( aFile ); |
|
1722 } |
|
1723 iAppView->InsertOutput( _L(" Effect count: "), EFalse ); |
|
1724 TBuf<5> countBuf; |
|
1725 countBuf.AppendNum( count ); |
|
1726 iAppView->InsertOutput( countBuf ); |
|
1727 } |
|
1728 } |
|
1729 |
|
1730 // --------------------------------------------------------- |
|
1731 // Plays the effect of the given index in the currently |
|
1732 // loaded IVT-file. |
|
1733 // --------------------------------------------------------- |
|
1734 // |
|
1735 void CHapticsTestAppUi::PlayEffect( TInt aIndex ) |
|
1736 { |
|
1737 TInt err = KErrNone; |
|
1738 iEffectHandle = KErrNotFound; |
|
1739 TBool usingAsyncSender( EFalse ); |
|
1740 |
|
1741 if ( iSynchronous ) |
|
1742 { |
|
1743 iAppView->InsertOutput( _L("Playing effect synchronously...") ); |
|
1744 if ( iUseHandle ) |
|
1745 { |
|
1746 err = iHaptics->PlayEffect( iIVTFileHandle, |
|
1747 aIndex, iEffectHandle ); |
|
1748 } |
|
1749 else |
|
1750 { |
|
1751 err = iHaptics->PlayEffect( *iIVTDataBuffer, |
|
1752 aIndex, iEffectHandle ); |
|
1753 } |
|
1754 } |
|
1755 else |
|
1756 { |
|
1757 iAppView->InsertOutput( _L("Playing effect asynchronously...") ); |
|
1758 |
|
1759 if ( iUseHandle ) |
|
1760 { |
|
1761 usingAsyncSender = ETrue; |
|
1762 iAsyncPlaySender->Play( iHaptics, iIVTFileHandle, |
|
1763 aIndex, iEffectHandle ); |
|
1764 } |
|
1765 else |
|
1766 { |
|
1767 TRequestStatus status; |
|
1768 iHaptics->PlayEffect( *iIVTDataBuffer, |
|
1769 aIndex, iEffectHandle, status ); |
|
1770 User::WaitForRequest( status ); |
|
1771 err = status.Int(); |
|
1772 } |
|
1773 } |
|
1774 |
|
1775 if ( !usingAsyncSender ) |
|
1776 { |
|
1777 // print error/success |
|
1778 PrintPlayEffectStatus( err ); |
|
1779 GetCurrentEffectState(); |
|
1780 |
|
1781 // if effect played successfully, add history data |
|
1782 if ( !err ) |
|
1783 { |
|
1784 iEffectData->AddEffectInfo( iEffectHandle, iIVTFileHandle, aIndex ); |
|
1785 } |
|
1786 } |
|
1787 } |
|
1788 |
|
1789 // --------------------------------------------------------- |
|
1790 // Plays the effect of the given index in the currently |
|
1791 // loaded IVT-file repeatedly |
|
1792 // --------------------------------------------------------- |
|
1793 // |
|
1794 void CHapticsTestAppUi::RepeatEffect( TInt aIndex, TInt aRepeats ) |
|
1795 { |
|
1796 TInt err = KErrNone; |
|
1797 iEffectHandle = KErrNotFound; |
|
1798 TBool usingAsyncSender( EFalse ); |
|
1799 |
|
1800 if ( iSynchronous ) |
|
1801 { |
|
1802 _LIT( KInsertedText, "Playing Repeat %d times synchronously..." ); |
|
1803 TBuf<50> buf; |
|
1804 buf.Format( KInsertedText, aRepeats ); |
|
1805 iAppView->InsertOutput( buf ); |
|
1806 |
|
1807 if ( iUseHandle ) |
|
1808 { |
|
1809 err = iHaptics->PlayEffectRepeat( iIVTFileHandle, |
|
1810 aIndex, aRepeats, iEffectHandle ); |
|
1811 } |
|
1812 else |
|
1813 { |
|
1814 err = iHaptics->PlayEffectRepeat( *iIVTDataBuffer, |
|
1815 aIndex, aRepeats, iEffectHandle ); |
|
1816 } |
|
1817 } |
|
1818 else |
|
1819 { |
|
1820 _LIT( KInsertedText, "Playing Repeat %d times asynchronously..." ); |
|
1821 TBuf<50> buf; |
|
1822 buf.Format( KInsertedText, aRepeats ); |
|
1823 iAppView->InsertOutput( buf ); |
|
1824 |
|
1825 if ( iUseHandle ) |
|
1826 { |
|
1827 usingAsyncSender = ETrue; |
|
1828 iAsyncPlaySender->PlayRepeat( iHaptics, |
|
1829 iIVTFileHandle, |
|
1830 aIndex, |
|
1831 aRepeats, |
|
1832 iEffectHandle ); |
|
1833 } |
|
1834 else |
|
1835 { |
|
1836 TRequestStatus status; |
|
1837 iHaptics->PlayEffectRepeat( *iIVTDataBuffer, |
|
1838 aIndex, aRepeats, iEffectHandle, status ); |
|
1839 User::WaitForRequest( status ); |
|
1840 err = status.Int(); |
|
1841 } |
|
1842 } |
|
1843 |
|
1844 if ( !usingAsyncSender ) |
|
1845 { |
|
1846 // print error/success |
|
1847 PrintPlayEffectStatus( err ); |
|
1848 GetCurrentEffectState(); |
|
1849 |
|
1850 // if effect played successfully, add history data |
|
1851 if ( !err ) |
|
1852 { |
|
1853 iEffectData->AddEffectInfo( iEffectHandle, iIVTFileHandle, aIndex ); |
|
1854 } |
|
1855 } |
|
1856 } |
|
1857 |
|
1858 // --------------------------------------------------------- |
|
1859 // Plays a magsweep effect using manual definition. |
|
1860 // --------------------------------------------------------- |
|
1861 // |
|
1862 void CHapticsTestAppUi::PlayMagSweepL( TBool aInfinite, TBool aModifiable ) |
|
1863 { |
|
1864 // construct default magsweep data |
|
1865 CHWRMHaptics::THWRMHapticsMagSweepEffect magsweep; |
|
1866 iEffectData->FillDefaultMagSweepData( magsweep, aInfinite, |
|
1867 aModifiable, iHaptics ); |
|
1868 |
|
1869 TInt err = KErrNone; |
|
1870 iEffectHandle = KErrNotFound; |
|
1871 |
|
1872 if ( iSynchronous ) |
|
1873 { |
|
1874 iAppView->InsertOutput( _L("Playing MagSweep synchronously...") ); |
|
1875 |
|
1876 // synchronous call |
|
1877 err = iHaptics->PlayMagSweepEffect( magsweep, iEffectHandle ); |
|
1878 } |
|
1879 else |
|
1880 { |
|
1881 iAppView->InsertOutput( _L("Playing MagSweep asynchronously...") ); |
|
1882 |
|
1883 // asynchronous call |
|
1884 TRequestStatus status; |
|
1885 iHaptics->PlayMagSweepEffect( magsweep, iEffectHandle, |
|
1886 status ); |
|
1887 User::WaitForRequest( status ); |
|
1888 err = status.Int(); |
|
1889 } |
|
1890 |
|
1891 // print error/success |
|
1892 PrintPlayEffectStatus( err ); |
|
1893 GetCurrentEffectState(); |
|
1894 |
|
1895 // if effect played successfully, add history data |
|
1896 if ( !err ) |
|
1897 { |
|
1898 iEffectData->AddEffectInfo( iEffectHandle ); |
|
1899 iEffectData->ResetModifiableMagSweepEffectL( magsweep, iEffectHandle, |
|
1900 iHaptics ); |
|
1901 |
|
1902 // if this effect should be auto-modifiable, reset modification timer |
|
1903 if ( aModifiable ) |
|
1904 { |
|
1905 iEffectData->StartModifiableEffectTimerL( ModifyPlayingEffect ); |
|
1906 } |
|
1907 } |
|
1908 } |
|
1909 |
|
1910 // --------------------------------------------------------- |
|
1911 // Plays a periodic effect using manual definition. |
|
1912 // --------------------------------------------------------- |
|
1913 // |
|
1914 void CHapticsTestAppUi::PlayPeriodicL( TBool aInfinite, TBool aModifiable ) |
|
1915 { |
|
1916 // construct default periodic data |
|
1917 CHWRMHaptics::THWRMHapticsPeriodicEffect periodic; |
|
1918 iEffectData->FillDefaultPeriodicData( periodic, aInfinite, |
|
1919 aModifiable, iHaptics ); |
|
1920 |
|
1921 TInt err = KErrNone; |
|
1922 iEffectHandle = KErrNotFound; |
|
1923 |
|
1924 if ( iSynchronous ) |
|
1925 { |
|
1926 iAppView->InsertOutput( _L("Playing Periodic synchronously...") ); |
|
1927 |
|
1928 // synchronous call |
|
1929 err = iHaptics->PlayPeriodicEffect( periodic, iEffectHandle ); |
|
1930 } |
|
1931 else |
|
1932 { |
|
1933 iAppView->InsertOutput( _L("Playing Periodic asynchronously...") ); |
|
1934 |
|
1935 // asynchronous call |
|
1936 TRequestStatus status; |
|
1937 iHaptics->PlayPeriodicEffect( periodic, iEffectHandle, |
|
1938 status ); |
|
1939 User::WaitForRequest( status ); |
|
1940 err = status.Int(); |
|
1941 } |
|
1942 |
|
1943 // print error/success |
|
1944 PrintPlayEffectStatus( err ); |
|
1945 GetCurrentEffectState(); |
|
1946 |
|
1947 // if effect played successfully, add history data |
|
1948 if ( !err ) |
|
1949 { |
|
1950 iEffectData->AddEffectInfo( iEffectHandle ); |
|
1951 iEffectData->ResetModifiablePeriodicEffectL( periodic, iEffectHandle, |
|
1952 iHaptics ); |
|
1953 |
|
1954 // if this effect should be auto-modifiable, reset modification timer |
|
1955 if ( aModifiable ) |
|
1956 { |
|
1957 iEffectData->StartModifiableEffectTimerL( ModifyPlayingEffect ); |
|
1958 } |
|
1959 } |
|
1960 } |
|
1961 |
|
1962 // --------------------------------------------------------- |
|
1963 // Plays repeatedly a timeline effect using manual definition. |
|
1964 // --------------------------------------------------------- |
|
1965 // |
|
1966 void CHapticsTestAppUi::PlayRepeatL( TInt aRepeats ) |
|
1967 { |
|
1968 TInt err = KErrNone; |
|
1969 iEffectHandle = KErrNotFound; |
|
1970 |
|
1971 // This is a simple effect (just plays magsweep type thingie for a second) |
|
1972 // produced from VibeStudio (export to C-file functionality there..) |
|
1973 static const TUint8 simpleTimelineEffect[] = |
|
1974 { |
|
1975 0x01, 0x00, 0x02, 0x00, 0x1c, 0x00, 0x28, 0x00, 0x00, 0x00, |
|
1976 0x07, 0x00, 0xf1, 0xe0, 0x01, 0xe2, 0x00, 0x00, 0xff, 0x30, |
|
1977 0xc8, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, |
|
1978 0x00, 0x5f, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x12, 0x00, |
|
1979 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6c, 0x00, |
|
1980 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x00, 0x00, 0x4d, 0x00, |
|
1981 0x61, 0x00, 0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, |
|
1982 0x65, 0x00, 0x70, 0x00, 0x00, 0x00 |
|
1983 }; |
|
1984 |
|
1985 RBuf8 effectBuffer; |
|
1986 CleanupClosePushL( effectBuffer ); |
|
1987 effectBuffer.ReAlloc( sizeof( simpleTimelineEffect ) ); |
|
1988 TUint8* tmpPtr = const_cast<TUint8*>( effectBuffer.Ptr() ); |
|
1989 memcpy( tmpPtr, simpleTimelineEffect, sizeof ( simpleTimelineEffect ) ); |
|
1990 effectBuffer.SetLength( sizeof ( simpleTimelineEffect ) ); |
|
1991 |
|
1992 if ( iSynchronous ) |
|
1993 { |
|
1994 _LIT( KInsertedText, "Playing Repeat %d times synchronously..." ); |
|
1995 TBuf<50> buf; |
|
1996 buf.Format( KInsertedText, aRepeats ); |
|
1997 iAppView->InsertOutput( buf ); |
|
1998 |
|
1999 err = iHaptics->PlayEffectRepeat( effectBuffer, 0, aRepeats, iEffectHandle ); |
|
2000 } |
|
2001 else |
|
2002 { |
|
2003 _LIT( KInsertedText, "Playing Repeat %d times asynchronously..." ); |
|
2004 TBuf<50> buf; |
|
2005 buf.Format( KInsertedText, aRepeats ); |
|
2006 iAppView->InsertOutput( buf ); |
|
2007 |
|
2008 TRequestStatus status; |
|
2009 iHaptics->PlayEffectRepeat( effectBuffer, 0, aRepeats, iEffectHandle, status ); |
|
2010 User::WaitForRequest( status ); |
|
2011 err = status.Int(); |
|
2012 } |
|
2013 |
|
2014 CleanupStack::PopAndDestroy(); // effectBuffer (closed here..) |
|
2015 |
|
2016 // print error/success |
|
2017 PrintPlayEffectStatus( err ); |
|
2018 GetCurrentEffectState(); |
|
2019 |
|
2020 // if effect played successfully, add history data |
|
2021 if ( !err ) |
|
2022 { |
|
2023 iEffectData->AddEffectInfo( iEffectHandle ); |
|
2024 } |
|
2025 } |
|
2026 |
|
2027 // --------------------------------------------------------- |
|
2028 // Pauses the effect of the given index in the effect |
|
2029 // history data. |
|
2030 // --------------------------------------------------------- |
|
2031 // |
|
2032 void CHapticsTestAppUi::PauseEffect( TInt aIndex ) |
|
2033 { |
|
2034 // get effect handle |
|
2035 TInt effectHandle = iEffectData->EffectHandle(aIndex); |
|
2036 |
|
2037 // pause effect |
|
2038 TInt err = iHaptics->PausePlayingEffect( effectHandle ); |
|
2039 |
|
2040 if ( err ) |
|
2041 { |
|
2042 TBuf<8> errBuf; |
|
2043 errBuf.AppendNum( err ); |
|
2044 iAppView->InsertOutput( _L("Pausing effect failed, err = "), EFalse ); |
|
2045 iAppView->InsertOutput( errBuf ); |
|
2046 } |
|
2047 else |
|
2048 { |
|
2049 iAppView->InsertOutput( _L("Pausing effect succeeded.") ); |
|
2050 } |
|
2051 } |
|
2052 |
|
2053 // --------------------------------------------------------- |
|
2054 // Resumes the effect of the given index in the effect |
|
2055 // history data. |
|
2056 // --------------------------------------------------------- |
|
2057 // |
|
2058 void CHapticsTestAppUi::ResumeEffect( TInt aIndex ) |
|
2059 { |
|
2060 // get effect handle |
|
2061 TInt effectHandle = iEffectData->EffectHandle(aIndex); |
|
2062 |
|
2063 // resume effect |
|
2064 TInt err = iHaptics->ResumePausedEffect( effectHandle ); |
|
2065 |
|
2066 if ( err ) |
|
2067 { |
|
2068 TBuf<8> errBuf; |
|
2069 errBuf.AppendNum( err ); |
|
2070 iAppView->InsertOutput( _L("Resuming effect failed, err = "), EFalse ); |
|
2071 iAppView->InsertOutput( errBuf ); |
|
2072 } |
|
2073 else |
|
2074 { |
|
2075 iAppView->InsertOutput( _L("Resuming effect succeeded.") ); |
|
2076 } |
|
2077 } |
|
2078 |
|
2079 // --------------------------------------------------------- |
|
2080 // Stops the effect of the given index in the effect |
|
2081 // history data. |
|
2082 // --------------------------------------------------------- |
|
2083 // |
|
2084 void CHapticsTestAppUi::StopEffect( TInt aIndex ) |
|
2085 { |
|
2086 // get effect handle |
|
2087 TInt effectHandle = iEffectData->EffectHandle(aIndex); |
|
2088 |
|
2089 // stop effect |
|
2090 TInt err = iHaptics->StopPlayingEffect( effectHandle ); |
|
2091 |
|
2092 if ( err ) |
|
2093 { |
|
2094 TBuf<8> errBuf; |
|
2095 errBuf.AppendNum( err ); |
|
2096 iAppView->InsertOutput( _L("Stopping effect failed, err = "), EFalse ); |
|
2097 iAppView->InsertOutput( errBuf ); |
|
2098 } |
|
2099 else |
|
2100 { |
|
2101 iAppView->InsertOutput( _L("Stopping effect succeeded.") ); |
|
2102 } |
|
2103 |
|
2104 // stop auto-modify effect, if it is on |
|
2105 iEffectData->ResetModifiableEffectTimer(); |
|
2106 } |
|
2107 |
|
2108 // --------------------------------------------------------- |
|
2109 // Deletes loaded IVT data |
|
2110 // --------------------------------------------------------- |
|
2111 // |
|
2112 void CHapticsTestAppUi::DeleteLoadedIVTData( TInt aIndex ) |
|
2113 { |
|
2114 if ( 0 > aIndex || aIndex >= iLoadedIVTFileArray.Count() ) |
|
2115 { |
|
2116 iAppView->InsertOutput( _L("Error: Delete index mismatch!") ); |
|
2117 return; |
|
2118 } |
|
2119 |
|
2120 TInt err = iHaptics->DeleteEffectData( iLoadedIVTFileArray[aIndex].iFileHandle ); |
|
2121 if ( KErrNone == err ) |
|
2122 { |
|
2123 // delete effect history |
|
2124 iEffectData->DeleteEffectInfo( iLoadedIVTFileArray[aIndex].iFileHandle ); |
|
2125 |
|
2126 // delete ivt-data item |
|
2127 if ( iLoadedIVTFileArray[aIndex].iDataBuffer ) |
|
2128 { |
|
2129 delete iLoadedIVTFileArray[aIndex].iDataBuffer; |
|
2130 } |
|
2131 |
|
2132 iLoadedIVTFileArray.Remove( aIndex ); |
|
2133 |
|
2134 iAppView->InsertOutput( _L("IVT data deletion succeeded") ); |
|
2135 } |
|
2136 else |
|
2137 { |
|
2138 _LIT( KInsertedText, "IVT data deletion failed: %d" ); |
|
2139 TBuf<80> buf; |
|
2140 buf.Format( KInsertedText, err ); |
|
2141 iAppView->InsertOutput( buf ); |
|
2142 } |
|
2143 } |
|
2144 |
|
2145 // --------------------------------------------------------- |
|
2146 // Deletes all loaded IVT datas |
|
2147 // --------------------------------------------------------- |
|
2148 // |
|
2149 void CHapticsTestAppUi::DeleteAllLoadedIVTData() |
|
2150 { |
|
2151 iAppView->InsertOutput( _L("Deleting all loaded IVT datas.") ); |
|
2152 |
|
2153 TInt err = iHaptics->DeleteAllEffectData(); |
|
2154 |
|
2155 if ( KErrNone == err ) |
|
2156 { |
|
2157 iAppView->InsertOutput( _L("All IVT data deletion succeeded") ); |
|
2158 |
|
2159 while ( iLoadedIVTFileArray.Count() ) |
|
2160 { |
|
2161 // delete effect history |
|
2162 iEffectData->DeleteEffectInfo( iLoadedIVTFileArray[0].iFileHandle ); |
|
2163 |
|
2164 // delete ivt-data item |
|
2165 if ( iLoadedIVTFileArray[0].iDataBuffer ) |
|
2166 { |
|
2167 delete iLoadedIVTFileArray[0].iDataBuffer; |
|
2168 } |
|
2169 |
|
2170 iLoadedIVTFileArray.Remove( 0 ); |
|
2171 } |
|
2172 } |
|
2173 else |
|
2174 { |
|
2175 _LIT( KInsertedText, "All IVT data deletion failed: %d" ); |
|
2176 TBuf<80> buf; |
|
2177 buf.Format( KInsertedText, err ); |
|
2178 iAppView->InsertOutput( buf ); |
|
2179 } |
|
2180 } |
|
2181 |
|
2182 |
|
2183 // --------------------------------------------------------- |
|
2184 // Fetches the current state of the last played effect |
|
2185 // (iEffectHandle), and prints the result to the UI. |
|
2186 // --------------------------------------------------------- |
|
2187 // |
|
2188 void CHapticsTestAppUi::GetCurrentEffectState() |
|
2189 { |
|
2190 TInt effectState = KErrNotFound; |
|
2191 TInt err = iHaptics->GetEffectState( iEffectHandle, effectState ); |
|
2192 |
|
2193 if ( err ) |
|
2194 { |
|
2195 TBuf<16> errCode; |
|
2196 errCode.AppendNum( err ); |
|
2197 iAppView->InsertOutput( _L(" Fetching effect state failed! Err: "), EFalse ); |
|
2198 iAppView->InsertOutput( errCode ); |
|
2199 } |
|
2200 else |
|
2201 { |
|
2202 TBuf<16> stateBuf; |
|
2203 |
|
2204 switch ( effectState ) |
|
2205 { |
|
2206 case CHWRMHaptics::EHWRMHapticsEffectNotPlaying: |
|
2207 stateBuf.Append( _L("Not playing.") ); |
|
2208 break; |
|
2209 case CHWRMHaptics::EHWRMHapticsEffectPlaying: |
|
2210 stateBuf.Append( _L("Playing.") ); |
|
2211 break; |
|
2212 case CHWRMHaptics::EHWRMHapticsEffectPaused: |
|
2213 stateBuf.Append( _L("Paused.") ); |
|
2214 break; |
|
2215 default: |
|
2216 stateBuf.Append( _L("Unknown!") ); |
|
2217 break; |
|
2218 } |
|
2219 |
|
2220 iAppView->InsertOutput( _L(" Effect state: "), EFalse ); |
|
2221 iAppView->InsertOutput( stateBuf ); |
|
2222 } |
|
2223 } |
|
2224 |
|
2225 // --------------------------------------------------------- |
|
2226 // Prints the status of a "play effect". |
|
2227 // --------------------------------------------------------- |
|
2228 // |
|
2229 void CHapticsTestAppUi::PrintPlayEffectStatus( TInt aErrorCode ) const |
|
2230 { |
|
2231 if ( aErrorCode ) |
|
2232 { |
|
2233 TBuf<16> errCode; |
|
2234 errCode.AppendNum( aErrorCode ); |
|
2235 iAppView->InsertOutput( _L("Playing effect failed! Err: "), EFalse ); |
|
2236 iAppView->InsertOutput( errCode ); |
|
2237 } |
|
2238 else |
|
2239 { |
|
2240 TBuf<16> handleBuf; |
|
2241 handleBuf.AppendNum( iEffectHandle ); |
|
2242 iAppView->InsertOutput( _L("Played effect successfully!") ); |
|
2243 iAppView->InsertOutput( _L(" Effect handle: "), EFalse ); |
|
2244 iAppView->InsertOutput( handleBuf ); |
|
2245 } |
|
2246 } |
|
2247 |
|
2248 // --------------------------------------------------------- |
|
2249 // Queries user how many repeats to have in case of playing |
|
2250 // some effect repeatedly. |
|
2251 // --------------------------------------------------------- |
|
2252 // |
|
2253 TInt CHapticsTestAppUi::GetNumberOfRepeats() |
|
2254 { |
|
2255 TInt repeatsIndex; |
|
2256 TInt retVal = 2; // default is 2 repeats |
|
2257 |
|
2258 // Uses non-leavable new for CAknListQueryDialog construction |
|
2259 CAknListQueryDialog* query = new CAknListQueryDialog( &repeatsIndex ); |
|
2260 |
|
2261 if ( query ) |
|
2262 { |
|
2263 query->PrepareLC( R_HAPTICS_REPEATEFFECT_REPEATS_QUERY ); |
|
2264 |
|
2265 if ( query->RunLD() ) |
|
2266 { |
|
2267 switch ( repeatsIndex ) |
|
2268 { |
|
2269 case 0: |
|
2270 retVal = 0; |
|
2271 break; |
|
2272 case 1: |
|
2273 retVal = 1; |
|
2274 break; |
|
2275 case 2: |
|
2276 retVal = 2; |
|
2277 break; |
|
2278 case 3: |
|
2279 retVal = 3; |
|
2280 break; |
|
2281 case 4: |
|
2282 retVal = 7; |
|
2283 break; |
|
2284 case 5: |
|
2285 retVal = iHaptics->InfiniteRepeat(); |
|
2286 break; |
|
2287 default: |
|
2288 break; // uses default (2) as return value |
|
2289 }; |
|
2290 } |
|
2291 } |
|
2292 return retVal; |
|
2293 } |
|
2294 |
|
2295 // --------------------------------------------------------- |
|
2296 // Calculates the effect index from the submenu index. |
|
2297 // --------------------------------------------------------- |
|
2298 // |
|
2299 TInt CHapticsTestAppUi::CountFileHandleAndEffectIndex(TInt aSubmenuIndex) |
|
2300 { |
|
2301 TInt effectFileCount = iLoadedIVTFileArray.Count(); |
|
2302 TInt retVal = 0xFFFFFFFF; |
|
2303 TInt totalRunningEffectCount = 0; |
|
2304 TInt effectCountAfterPreviousFile = 0; |
|
2305 |
|
2306 for ( TInt i = 0; i < effectFileCount; ++i ) |
|
2307 { |
|
2308 TInt effectsInThisFile = 0; |
|
2309 iHaptics->GetEffectCount( iLoadedIVTFileArray[i].iFileHandle, effectsInThisFile ); |
|
2310 effectCountAfterPreviousFile = totalRunningEffectCount; |
|
2311 totalRunningEffectCount += effectsInThisFile; |
|
2312 if ( aSubmenuIndex < totalRunningEffectCount ) |
|
2313 { |
|
2314 iIVTFileHandle = iLoadedIVTFileArray[i].iFileHandle; |
|
2315 iIVTDataBuffer = iLoadedIVTFileArray[i].iDataBuffer; |
|
2316 retVal = aSubmenuIndex - effectCountAfterPreviousFile; |
|
2317 break; |
|
2318 } |
|
2319 } |
|
2320 return retVal; |
|
2321 } |
|
2322 |
|
2323 // --------------------------------------------------------- |
|
2324 // Creates all submenu items for a play effect submenu. |
|
2325 // Fetches all the names of the effects from currently |
|
2326 // loaded IVT-data. |
|
2327 // --------------------------------------------------------- |
|
2328 // |
|
2329 void CHapticsTestAppUi::CreatePlayEffectSubmenuL( CEikMenuPane* aMenuPane, |
|
2330 TInt aCommandId, |
|
2331 TInt aDimCommandId ) |
|
2332 { |
|
2333 TInt loadedIVTFileCount = iLoadedIVTFileArray.Count(); |
|
2334 TBool dimmingNeeded = EFalse; |
|
2335 |
|
2336 if ( loadedIVTFileCount ) |
|
2337 { |
|
2338 // make all effect names (in all loaded files) visible in the submenu |
|
2339 CEikMenuPaneItem::SData data; |
|
2340 for ( TInt j = 0; j < loadedIVTFileCount; ++j) |
|
2341 { |
|
2342 if ( iLoadedIVTFileArray[j].iDataBuffer ) |
|
2343 { |
|
2344 TInt effectCount = 0; |
|
2345 iHaptics->GetEffectCount( iLoadedIVTFileArray[j].iFileHandle, effectCount ); |
|
2346 HBufC8* tempBuf8 = HBufC8::New( iHaptics->MaxEffectNameLength() ); |
|
2347 TPtr8 effectName = tempBuf8->Des(); |
|
2348 for ( TInt i = 0; i < effectCount; ++i ) |
|
2349 { |
|
2350 // fetch effect name |
|
2351 iHaptics->GetEffectName( iLoadedIVTFileArray[j].iFileHandle, i, effectName ); |
|
2352 |
|
2353 data.iText.Copy( effectName ); |
|
2354 data.iCommandId = aCommandId; |
|
2355 data.iCascadeId = 0; |
|
2356 data.iFlags = 0; |
|
2357 data.iExtraText = KNullDesC; |
|
2358 |
|
2359 aMenuPane->AddMenuItemL( data ); |
|
2360 dimmingNeeded = ETrue; |
|
2361 } |
|
2362 delete tempBuf8; |
|
2363 } |
|
2364 } |
|
2365 } |
|
2366 if ( dimmingNeeded ) |
|
2367 { |
|
2368 // effects found in IVT-data, hide the "no effects" -item |
|
2369 aMenuPane->SetItemDimmed( aDimCommandId, ETrue ); |
|
2370 } |
|
2371 } |
|
2372 |
|
2373 // --------------------------------------------------------- |
|
2374 // Prints effect information got from getter functions |
|
2375 // --------------------------------------------------------- |
|
2376 // |
|
2377 void CHapticsTestAppUi::PrintEffectInfo( TInt aIndex ) |
|
2378 { |
|
2379 if ( iUseHandle && iShowEffectInfo ) |
|
2380 { |
|
2381 TInt duration; |
|
2382 iHaptics->GetEffectDuration( iIVTFileHandle, |
|
2383 aIndex, |
|
2384 duration ); |
|
2385 |
|
2386 HBufC8* tempBuf8 = HBufC8::New( iHaptics->MaxEffectNameLength() ); |
|
2387 TPtr8 effectName = tempBuf8->Des(); |
|
2388 |
|
2389 iHaptics->GetEffectName( iIVTFileHandle, aIndex, effectName ); |
|
2390 |
|
2391 TInt effectIndex; |
|
2392 iHaptics->GetEffectIndexFromName( iIVTFileHandle, |
|
2393 effectName, |
|
2394 effectIndex ); |
|
2395 |
|
2396 TInt type; |
|
2397 iHaptics->GetEffectType( iIVTFileHandle, aIndex, type ); |
|
2398 |
|
2399 |
|
2400 HBufC* tempBuf16 = HBufC::New( iHaptics->MaxEffectNameLength() ); |
|
2401 TPtr buf = tempBuf16->Des(); |
|
2402 |
|
2403 iAppView->InsertOutput( _L(" Effect name: "), EFalse ); |
|
2404 buf.Copy( effectName ); |
|
2405 iAppView->InsertOutput( buf, EFalse ); |
|
2406 |
|
2407 buf.Delete( 0, buf.MaxLength() ); |
|
2408 buf.AppendNum( effectIndex ); |
|
2409 iAppView->InsertOutput( _L(" Idx: "), EFalse ); |
|
2410 iAppView->InsertOutput( buf ); |
|
2411 |
|
2412 buf.Delete( 0, buf.MaxLength() ); |
|
2413 buf.AppendNum( duration ); |
|
2414 iAppView->InsertOutput( _L(" Effect duration: "), EFalse ); |
|
2415 iAppView->InsertOutput( buf ); |
|
2416 |
|
2417 buf.Delete( 0, buf.MaxLength() ); |
|
2418 buf.AppendNum( type ); |
|
2419 iAppView->InsertOutput( _L(" Effect type: "), EFalse ); |
|
2420 iAppView->InsertOutput( buf ); |
|
2421 |
|
2422 if ( type == CHWRMHaptics::EHWRMHapticsTypeMagSweep ) |
|
2423 { |
|
2424 CHWRMHaptics::THWRMHapticsMagSweepEffect def; |
|
2425 iHaptics->GetMagSweepEffectDefinition( iIVTFileHandle, |
|
2426 aIndex, |
|
2427 def ); |
|
2428 iAppView->InsertOutput( _L(" MagSweep definition -> Duration:"), EFalse ); |
|
2429 buf.Delete( 0, buf.MaxLength() ); |
|
2430 buf.AppendNum( def.iDuration ); |
|
2431 iAppView->InsertOutput( buf ); |
|
2432 iAppView->InsertOutput( _L(" MagSweep definition -> Magnitude: "), EFalse ); |
|
2433 buf.Delete( 0, buf.MaxLength() ); |
|
2434 buf.AppendNum( def.iMagnitude ); |
|
2435 iAppView->InsertOutput( buf ); |
|
2436 iAppView->InsertOutput( _L(" MagSweep definition -> Style: "), EFalse ); |
|
2437 buf.Delete( 0, buf.MaxLength() ); |
|
2438 buf.AppendNum( def.iStyle ); |
|
2439 iAppView->InsertOutput( buf ); |
|
2440 iAppView->InsertOutput( _L(" MagSweep definition -> Attack time: "), EFalse ); |
|
2441 buf.Delete( 0, buf.MaxLength() ); |
|
2442 buf.AppendNum( def.iAttackTime ); |
|
2443 iAppView->InsertOutput( buf ); |
|
2444 iAppView->InsertOutput( _L(" MagSweep definition -> Attack level: "), EFalse ); |
|
2445 buf.Delete( 0, buf.MaxLength() ); |
|
2446 buf.AppendNum( def.iAttackLevel ); |
|
2447 iAppView->InsertOutput( buf ); |
|
2448 iAppView->InsertOutput( _L(" MagSweep definition -> Fade time: "), EFalse ); |
|
2449 buf.Delete( 0, buf.MaxLength() ); |
|
2450 buf.AppendNum( def.iFadeTime ); |
|
2451 iAppView->InsertOutput( buf ); |
|
2452 iAppView->InsertOutput( _L(" MagSweep definition -> Fade level: "), EFalse ); |
|
2453 buf.Delete( 0, buf.MaxLength() ); |
|
2454 buf.AppendNum( def.iFadeLevel ); |
|
2455 iAppView->InsertOutput( buf ); |
|
2456 } |
|
2457 else if ( type == CHWRMHaptics::EHWRMHapticsTypePeriodic ) |
|
2458 { |
|
2459 CHWRMHaptics::THWRMHapticsPeriodicEffect def; |
|
2460 iHaptics->GetPeriodicEffectDefinition( iIVTFileHandle, |
|
2461 aIndex, |
|
2462 def ); |
|
2463 iAppView->InsertOutput( _L(" Periodic definition -> Duration: "), EFalse ); |
|
2464 buf.Delete( 0, buf.MaxLength() ); |
|
2465 buf.AppendNum( def.iDuration ); |
|
2466 iAppView->InsertOutput( buf ); |
|
2467 iAppView->InsertOutput( _L(" Periodic definition -> Magnitude: "), EFalse ); |
|
2468 buf.Delete( 0, buf.MaxLength() ); |
|
2469 buf.AppendNum( def.iMagnitude ); |
|
2470 iAppView->InsertOutput( buf ); |
|
2471 iAppView->InsertOutput( _L(" Periodic definition -> Period: "), EFalse ); |
|
2472 buf.Delete( 0, buf.MaxLength() ); |
|
2473 buf.AppendNum( def.iPeriod ); |
|
2474 iAppView->InsertOutput( buf ); |
|
2475 iAppView->InsertOutput( _L(" Periodic definition -> Style: "), EFalse ); |
|
2476 buf.Delete( 0, buf.MaxLength() ); |
|
2477 buf.AppendNum( def.iStyle ); |
|
2478 iAppView->InsertOutput( buf ); |
|
2479 iAppView->InsertOutput( _L(" Periodic definition -> Attack time: "), EFalse ); |
|
2480 buf.Delete( 0, buf.MaxLength() ); |
|
2481 buf.AppendNum( def.iAttackTime ); |
|
2482 iAppView->InsertOutput( buf ); |
|
2483 iAppView->InsertOutput( _L(" Periodic definition -> Attack level: "), EFalse ); |
|
2484 buf.Delete( 0, buf.MaxLength() ); |
|
2485 buf.AppendNum( def.iAttackLevel ); |
|
2486 iAppView->InsertOutput( buf ); |
|
2487 iAppView->InsertOutput( _L(" Periodic definition -> Fade time: "), EFalse ); |
|
2488 buf.Delete( 0, buf.MaxLength() ); |
|
2489 buf.AppendNum( def.iFadeTime ); |
|
2490 iAppView->InsertOutput( buf ); |
|
2491 iAppView->InsertOutput( _L(" Periodic definition -> Attack level: "), EFalse ); |
|
2492 buf.Delete( 0, buf.MaxLength() ); |
|
2493 buf.AppendNum( def.iFadeLevel ); |
|
2494 iAppView->InsertOutput( buf ); |
|
2495 } |
|
2496 delete tempBuf8; |
|
2497 delete tempBuf16; |
|
2498 } |
|
2499 } |
|
2500 |
|
2501 // --------------------------------------------------------- |
|
2502 // Prints the given status onto the screen. |
|
2503 // --------------------------------------------------------- |
|
2504 // |
|
2505 void CHapticsTestAppUi::PrintStatusInfo( |
|
2506 MHWRMHapticsObserver::THWRMHapticsStatus aStatus ) const |
|
2507 { |
|
2508 iAppView->InsertOutput( _L("Received status: "), EFalse ); |
|
2509 |
|
2510 switch( aStatus ) |
|
2511 { |
|
2512 case MHWRMHapticsObserver::EHWRMHapticsStatusAvailable: |
|
2513 { |
|
2514 iAppView->InsertOutput( _L("Available.") ); |
|
2515 break; |
|
2516 } |
|
2517 case MHWRMHapticsObserver::EHWRMHapticsStatusReserved: |
|
2518 { |
|
2519 iAppView->InsertOutput( _L("Reserved.") ); |
|
2520 break; |
|
2521 } |
|
2522 case MHWRMHapticsObserver::EHWRMHapticsStatusSuspended: |
|
2523 { |
|
2524 iAppView->InsertOutput( _L("Suspended.") ); |
|
2525 break; |
|
2526 } |
|
2527 default: |
|
2528 { |
|
2529 iAppView->InsertOutput( _L("<unknown status>") ); |
|
2530 break; |
|
2531 } |
|
2532 } |
|
2533 } |
|
2534 |
|
2535 // --------------------------------------------------------- |
|
2536 // Calls the getter methods for system constants |
|
2537 // and prints out the results. |
|
2538 // --------------------------------------------------------- |
|
2539 // |
|
2540 void CHapticsTestAppUi::ConstGetters() const |
|
2541 { |
|
2542 _LIT( KNumFormat, "%d" ); |
|
2543 TBuf<50> buf; |
|
2544 iAppView->InsertOutput( _L(" Infinite repeats: "), EFalse ); |
|
2545 buf.Format( KNumFormat, iHaptics->InfiniteRepeat() ); |
|
2546 iAppView->InsertOutput( buf ); |
|
2547 iAppView->InsertOutput( _L(" Infinite duration: "), EFalse ); |
|
2548 buf.Format( KNumFormat, iHaptics->InfiniteDuration() ); |
|
2549 iAppView->InsertOutput( buf ); |
|
2550 iAppView->InsertOutput( _L(" Max effect name length: "), EFalse ); |
|
2551 buf.Format( KNumFormat, iHaptics->MaxEffectNameLength() ); |
|
2552 iAppView->InsertOutput( buf ); |
|
2553 iAppView->InsertOutput( _L(" Max device name length: "), EFalse ); |
|
2554 buf.Format( KNumFormat, iHaptics->MaxDeviceNameLength() ); |
|
2555 iAppView->InsertOutput( buf ); |
|
2556 iAppView->InsertOutput( _L(" Max capability string length: "), EFalse ); |
|
2557 buf.Format( KNumFormat, iHaptics->MaxCapabilityStringLength() ); |
|
2558 iAppView->InsertOutput( buf ); |
|
2559 iAppView->InsertOutput( _L(" Max property string length: "), EFalse ); |
|
2560 buf.Format( KNumFormat, iHaptics->MaxPropertyStringLength() ); |
|
2561 iAppView->InsertOutput( buf ); |
|
2562 iAppView->InsertOutput( _L(" Max streaming sample size: "), EFalse ); |
|
2563 buf.Format( KNumFormat, iHaptics->MaxStreamingSampleSize() ); |
|
2564 iAppView->InsertOutput( buf ); |
|
2565 iAppView->InsertOutput( _L(" Default device priority: "), EFalse ); |
|
2566 buf.Format( KNumFormat, iHaptics->DefaultDevicePriority() ); |
|
2567 iAppView->InsertOutput( buf ); |
|
2568 } |
|
2569 |
|
2570 // --------------------------------------------------------------------------- |
|
2571 // Modifies an effect using the values set for iModifyEffect. |
|
2572 // --------------------------------------------------------------------------- |
|
2573 // |
|
2574 void CHapticsTestAppUi::ModifyEffect() |
|
2575 { |
|
2576 if ( !iEffectData->ModifiableEffectExists() ) |
|
2577 { |
|
2578 return; |
|
2579 } |
|
2580 |
|
2581 TInt err = KErrNone; |
|
2582 TInt effectHandle = iEffectData->ModifiableEffectHandle(); |
|
2583 |
|
2584 if ( iEffectData->ModifiableEffectIsMagSweep() ) |
|
2585 { |
|
2586 // fill magsweep data |
|
2587 CHWRMHaptics::THWRMHapticsMagSweepEffect magsweep; |
|
2588 iEffectData->FillModifiableMagSweepData( magsweep ); |
|
2589 |
|
2590 // execute modification |
|
2591 if ( iSynchronous ) |
|
2592 { |
|
2593 err = iHaptics->ModifyPlayingMagSweepEffect( effectHandle, magsweep ); |
|
2594 } |
|
2595 else |
|
2596 { |
|
2597 TRequestStatus status; |
|
2598 iHaptics->ModifyPlayingMagSweepEffect( effectHandle, magsweep, status ); |
|
2599 User::WaitForRequest( status ); |
|
2600 err = status.Int(); |
|
2601 } |
|
2602 } |
|
2603 else if ( iEffectData->ModifiableEffectIsPeriodic() ) |
|
2604 { |
|
2605 // fill periodic data |
|
2606 CHWRMHaptics::THWRMHapticsPeriodicEffect periodic; |
|
2607 iEffectData->FillModifiablePeriodicData( periodic ); |
|
2608 |
|
2609 // execute modification |
|
2610 if ( iSynchronous ) |
|
2611 { |
|
2612 err = iHaptics->ModifyPlayingPeriodicEffect( effectHandle, periodic ); |
|
2613 } |
|
2614 else |
|
2615 { |
|
2616 TRequestStatus status; |
|
2617 iHaptics->ModifyPlayingPeriodicEffect( effectHandle, periodic, status ); |
|
2618 User::WaitForRequest( status ); |
|
2619 err = status.Int(); |
|
2620 } |
|
2621 } |
|
2622 |
|
2623 if ( err ) |
|
2624 { |
|
2625 TBuf<8> errBuf; |
|
2626 errBuf.AppendNum( err ); |
|
2627 iAppView->InsertOutput( _L("Modifying effect failed, err = "), EFalse ); |
|
2628 iAppView->InsertOutput( errBuf ); |
|
2629 } |
|
2630 else |
|
2631 { |
|
2632 iAppView->InsertOutput( _L("Modifying effect succeeded.") ); |
|
2633 } |
|
2634 } |
|
2635 |
|
2636 // --------------------------------------------------------------------------- |
|
2637 // Static callback method from a periodic timer used for |
|
2638 // continuous effect modification (magnitude/period). |
|
2639 // --------------------------------------------------------------------------- |
|
2640 // |
|
2641 TInt CHapticsTestAppUi::ModifyPlayingEffect( TAny* aPtr ) |
|
2642 { |
|
2643 CHapticsTestEffectDataHandler* effectData = |
|
2644 static_cast<CHapticsTestEffectDataHandler*>( aPtr ); |
|
2645 |
|
2646 // hundred modifications to get to KPi (up and down with magnitude) |
|
2647 TReal stepLengthRad = KPi/100 * effectData->ModifyCount(); |
|
2648 |
|
2649 // calculate absolute sin value |
|
2650 TReal sinValue = 0; |
|
2651 TInt errSin = Math::Sin( sinValue, stepLengthRad ); |
|
2652 sinValue = Abs( sinValue ); |
|
2653 |
|
2654 // increase the amount of modifications done |
|
2655 effectData->SetModifyCount( effectData->ModifyCount() + 1 ); |
|
2656 |
|
2657 TInt err = KErrNone; |
|
2658 TInt effectHandle = effectData->ModifiableEffectHandle(); |
|
2659 |
|
2660 if ( effectData->ModifiableEffectIsMagSweep() ) |
|
2661 { |
|
2662 // modify magsweep effect |
|
2663 CHWRMHaptics::THWRMHapticsMagSweepEffect magsweep; |
|
2664 effectData->FillModifiableMagSweepData( magsweep ); |
|
2665 |
|
2666 // new magnitude value according to sin value |
|
2667 magsweep.iMagnitude = KHWRMHapticsMaxMagnitude * sinValue; |
|
2668 |
|
2669 // modify effect |
|
2670 err = effectData->Haptics()->ModifyPlayingMagSweepEffect( |
|
2671 effectHandle, magsweep ); |
|
2672 } |
|
2673 else if ( effectData->ModifiableEffectIsPeriodic() ) |
|
2674 { |
|
2675 // modify periodic effect |
|
2676 CHWRMHaptics::THWRMHapticsPeriodicEffect periodic; |
|
2677 effectData->FillModifiablePeriodicData( periodic ); |
|
2678 |
|
2679 // period getting smaller when magnitude getting higher |
|
2680 periodic.iPeriod = 20 + (1-sinValue)*200; |
|
2681 |
|
2682 // modify effect |
|
2683 err = effectData->Haptics()->ModifyPlayingPeriodicEffect( |
|
2684 effectHandle, periodic ); |
|
2685 } |
|
2686 |
|
2687 if ( err ) |
|
2688 { |
|
2689 CEikonEnv::Static()->InfoMsg( _L("Modify failed!") ); |
|
2690 } |
|
2691 |
|
2692 return KErrNone; |
|
2693 } |
|
2694 |
|
2695 // --------------------------------------------------------------------------- |
|
2696 // |
|
2697 // --------------------------------------------------------------------------- |
|
2698 // |
|
2699 void CHapticsTestAppUi::GetCapabilityDeviceCategory() |
|
2700 { |
|
2701 TBuf<50> buf; |
|
2702 iAppView->InsertOutput( _L(" Device category: "), EFalse ); |
|
2703 TInt retValue( CHWRMHaptics::EHWRMHapticsEmbedded ); |
|
2704 TInt err( iHaptics->GetDeviceCapability( |
|
2705 CHWRMHaptics::EHWRMHapticsDeviceCategory, retValue ) ); |
|
2706 |
|
2707 if ( err ) |
|
2708 { |
|
2709 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2710 buf.Format( KFailedFormat, err ); |
|
2711 } |
|
2712 else |
|
2713 { |
|
2714 switch ( retValue ) |
|
2715 { |
|
2716 case CHWRMHaptics::EHWRMHapticsVirtual: |
|
2717 buf.Append( _L("Virtual") ); |
|
2718 break; |
|
2719 case CHWRMHaptics::EHWRMHapticsEmbedded: |
|
2720 buf.Append( _L("Embedded") ); |
|
2721 break; |
|
2722 default: |
|
2723 buf.Append( _L("Unknown") ); |
|
2724 break; |
|
2725 } |
|
2726 } |
|
2727 iAppView->InsertOutput( buf ); |
|
2728 } |
|
2729 |
|
2730 // --------------------------------------------------------------------------- |
|
2731 // |
|
2732 // --------------------------------------------------------------------------- |
|
2733 // |
|
2734 void CHapticsTestAppUi::GetCapabilityMaxNestedRepeats() |
|
2735 { |
|
2736 TBuf<50> buf; |
|
2737 iAppView->InsertOutput( _L(" Max nested repeats: "), EFalse ); |
|
2738 TInt retValue( 0 ); |
|
2739 TInt err( iHaptics->GetDeviceCapability( |
|
2740 CHWRMHaptics::EHWRMHapticsMaxNestedRepeats, retValue ) ); |
|
2741 |
|
2742 if ( err ) |
|
2743 { |
|
2744 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2745 buf.Format( KFailedFormat, err ); |
|
2746 } |
|
2747 else |
|
2748 { |
|
2749 _LIT( KNumFormat, "%d" ); |
|
2750 buf.Format( KNumFormat, retValue ); |
|
2751 } |
|
2752 |
|
2753 iAppView->InsertOutput( buf ); |
|
2754 } |
|
2755 |
|
2756 // --------------------------------------------------------------------------- |
|
2757 // |
|
2758 // --------------------------------------------------------------------------- |
|
2759 // |
|
2760 void CHapticsTestAppUi::GetCapabilityNumActuators() |
|
2761 { |
|
2762 TBuf<50> buf; |
|
2763 iAppView->InsertOutput( _L(" Number of actuators: "), EFalse ); |
|
2764 TInt retValue( 0 ); |
|
2765 TInt err( iHaptics->GetDeviceCapability( |
|
2766 CHWRMHaptics::EHWRMHapticsNumActuators, retValue ) ); |
|
2767 |
|
2768 if ( err ) |
|
2769 { |
|
2770 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2771 buf.Format( KFailedFormat, err ); |
|
2772 } |
|
2773 else |
|
2774 { |
|
2775 _LIT( KNumFormat, "%d" ); |
|
2776 buf.Format( KNumFormat, retValue ); |
|
2777 } |
|
2778 |
|
2779 iAppView->InsertOutput( buf ); |
|
2780 } |
|
2781 |
|
2782 // --------------------------------------------------------------------------- |
|
2783 // |
|
2784 // --------------------------------------------------------------------------- |
|
2785 // |
|
2786 void CHapticsTestAppUi::GetCapabilityActuatorType() |
|
2787 { |
|
2788 TBuf<50> buf; |
|
2789 iAppView->InsertOutput( _L(" Actuator type: "), EFalse ); |
|
2790 TInt retValue( 0 ); |
|
2791 TInt err( iHaptics->GetDeviceCapability( |
|
2792 CHWRMHaptics::EHWRMHapticsActuatorType, retValue ) ); |
|
2793 |
|
2794 if ( err ) |
|
2795 { |
|
2796 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2797 buf.Format( KFailedFormat, err ); |
|
2798 } |
|
2799 else |
|
2800 { |
|
2801 switch (retValue) |
|
2802 { |
|
2803 case CHWRMHaptics::EHWRMHapticsTypeERM: |
|
2804 buf.Append( _L("EHWRMHapticsTypeERM") ); |
|
2805 break; |
|
2806 case CHWRMHaptics::EHWRMHapticsTypeLRA: |
|
2807 buf.Append( _L("EHWRMHapticsTypeLRA") ); |
|
2808 break; |
|
2809 default: |
|
2810 buf.Append( _L("Unknown") ); |
|
2811 break; |
|
2812 } |
|
2813 } |
|
2814 iAppView->InsertOutput( buf ); |
|
2815 } |
|
2816 |
|
2817 // --------------------------------------------------------------------------- |
|
2818 // |
|
2819 // --------------------------------------------------------------------------- |
|
2820 // |
|
2821 void CHapticsTestAppUi::GetCapabilityNumEffectSlots() |
|
2822 { |
|
2823 TBuf<50> buf; |
|
2824 iAppView->InsertOutput( _L(" Number of effect slots: "), EFalse ); |
|
2825 TInt retValue( 0 ); |
|
2826 TInt err( iHaptics->GetDeviceCapability( |
|
2827 CHWRMHaptics::EHWRMHapticsNumEffectSlots, retValue ) ); |
|
2828 |
|
2829 if ( err ) |
|
2830 { |
|
2831 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2832 buf.Format( KFailedFormat, err ); |
|
2833 } |
|
2834 else |
|
2835 { |
|
2836 _LIT( KNumFormat, "%d" ); |
|
2837 buf.Format( KNumFormat, retValue ); |
|
2838 } |
|
2839 |
|
2840 iAppView->InsertOutput( buf ); |
|
2841 } |
|
2842 |
|
2843 // --------------------------------------------------------------------------- |
|
2844 // |
|
2845 // --------------------------------------------------------------------------- |
|
2846 // |
|
2847 void CHapticsTestAppUi::GetCapabilityNumEffectStyles() |
|
2848 { |
|
2849 TBuf<150> buf; |
|
2850 iAppView->InsertOutput( _L(" Effect styles: "), EFalse ); |
|
2851 TInt retValue( 0 ); |
|
2852 TInt err( iHaptics->GetDeviceCapability( |
|
2853 CHWRMHaptics::EHWRMHapticsSupportedStyles, retValue ) ); |
|
2854 |
|
2855 if ( err ) |
|
2856 { |
|
2857 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2858 buf.Format( KFailedFormat, err ); |
|
2859 } |
|
2860 else |
|
2861 { |
|
2862 if ( retValue & CHWRMHaptics::EHWRMHapticsSupportSmooth ) |
|
2863 { |
|
2864 buf.Append( _L(" EHWRMHapticsSupportSmooth") ); |
|
2865 } |
|
2866 |
|
2867 if ( retValue & CHWRMHaptics::EHWRMHapticsSupportStrong ) |
|
2868 { |
|
2869 buf.Append( _L(" EHWRMHapticsSupportStrong") ); |
|
2870 } |
|
2871 |
|
2872 if ( retValue & CHWRMHaptics::EHWRMHapticsSupportSharp ) |
|
2873 { |
|
2874 buf.Append( _L(" EHWRMHapticsSupportSharp") ); |
|
2875 } |
|
2876 } |
|
2877 iAppView->InsertOutput( buf ); |
|
2878 } |
|
2879 |
|
2880 // --------------------------------------------------------------------------- |
|
2881 // |
|
2882 // --------------------------------------------------------------------------- |
|
2883 // |
|
2884 void CHapticsTestAppUi::GetCapabilityMinPeriod() |
|
2885 { |
|
2886 TBuf<50> buf; |
|
2887 iAppView->InsertOutput( _L(" Minimum period for periodic effects: "), EFalse ); |
|
2888 TInt retValue( 0 ); |
|
2889 TInt err( iHaptics->GetDeviceCapability( |
|
2890 CHWRMHaptics::EHWRMHapticsMinPeriod, retValue ) ); |
|
2891 |
|
2892 if ( err ) |
|
2893 { |
|
2894 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2895 buf.Format( KFailedFormat, err ); |
|
2896 } |
|
2897 else |
|
2898 { |
|
2899 _LIT( KNumFormat, "%d" ); |
|
2900 buf.Format( KNumFormat, retValue ); |
|
2901 } |
|
2902 |
|
2903 iAppView->InsertOutput( buf ); |
|
2904 } |
|
2905 |
|
2906 // --------------------------------------------------------------------------- |
|
2907 // |
|
2908 // --------------------------------------------------------------------------- |
|
2909 // |
|
2910 void CHapticsTestAppUi::GetCapabilityMaxPeriod() |
|
2911 { |
|
2912 TBuf<50> buf; |
|
2913 iAppView->InsertOutput( _L(" Maximum period for periodic effects: "), EFalse ); |
|
2914 TInt retValue( 0 ); |
|
2915 TInt err( iHaptics->GetDeviceCapability( |
|
2916 CHWRMHaptics::EHWRMHapticsMaxPeriod, retValue ) ); |
|
2917 |
|
2918 if ( err ) |
|
2919 { |
|
2920 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2921 buf.Format( KFailedFormat, err ); |
|
2922 } |
|
2923 else |
|
2924 { |
|
2925 _LIT( KNumFormat, "%d" ); |
|
2926 buf.Format( KNumFormat, retValue ); |
|
2927 } |
|
2928 |
|
2929 iAppView->InsertOutput( buf ); |
|
2930 } |
|
2931 |
|
2932 // --------------------------------------------------------------------------- |
|
2933 // |
|
2934 // --------------------------------------------------------------------------- |
|
2935 // |
|
2936 void CHapticsTestAppUi::GetCapabilityMaxEffectDuration() |
|
2937 { |
|
2938 TBuf<50> buf; |
|
2939 iAppView->InsertOutput( _L(" Maximum effect duration: "), EFalse ); |
|
2940 TInt retValue( 0 ); |
|
2941 TInt err( iHaptics->GetDeviceCapability( |
|
2942 CHWRMHaptics::EHWRMHapticsMaxEffectDuration, retValue ) ); |
|
2943 |
|
2944 if ( err ) |
|
2945 { |
|
2946 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2947 buf.Format( KFailedFormat, err ); |
|
2948 } |
|
2949 else |
|
2950 { |
|
2951 _LIT( KNumFormat, "%d" ); |
|
2952 buf.Format( KNumFormat, retValue ); |
|
2953 } |
|
2954 |
|
2955 iAppView->InsertOutput( buf ); |
|
2956 } |
|
2957 |
|
2958 // --------------------------------------------------------------------------- |
|
2959 // |
|
2960 // --------------------------------------------------------------------------- |
|
2961 // |
|
2962 void CHapticsTestAppUi::GetCapabilitySupportedEffects() |
|
2963 { |
|
2964 TBuf<150> buf; |
|
2965 iAppView->InsertOutput( _L(" Supported effect types: "), EFalse ); |
|
2966 TInt retValue( 0 ); |
|
2967 TInt err( iHaptics->GetDeviceCapability( |
|
2968 CHWRMHaptics::EHWRMHapticsSupportedEffects, retValue ) ); |
|
2969 |
|
2970 if ( err ) |
|
2971 { |
|
2972 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
2973 buf.Format( KFailedFormat, err ); |
|
2974 } |
|
2975 else |
|
2976 { |
|
2977 if ( retValue & CHWRMHaptics::EHWRMHapticsSupportPeriodic ) |
|
2978 { |
|
2979 buf.Append( _L(" EHWRMHapticsSupportPeriodic") ); |
|
2980 } |
|
2981 |
|
2982 if ( retValue & CHWRMHaptics::EHWRMHapticsSupportMagSweep ) |
|
2983 { |
|
2984 buf.Append( _L(" EHWRMHapticsSupportMagSweep") ); |
|
2985 } |
|
2986 |
|
2987 if ( retValue & CHWRMHaptics::EHWRMHapticsSupportTimeline ) |
|
2988 { |
|
2989 buf.Append( _L(" EHWRMHapticsSupportTimeline") ); |
|
2990 } |
|
2991 |
|
2992 if ( retValue & CHWRMHaptics::EHWRMHapticsSupportStreaming ) |
|
2993 { |
|
2994 buf.Append( _L(" EHWRMHapticsSupportStreaming") ); |
|
2995 } |
|
2996 } |
|
2997 iAppView->InsertOutput( buf ); |
|
2998 } |
|
2999 |
|
3000 // --------------------------------------------------------------------------- |
|
3001 // |
|
3002 // --------------------------------------------------------------------------- |
|
3003 // |
|
3004 void CHapticsTestAppUi::GetCapabilityDeviceName() |
|
3005 { |
|
3006 TBuf<100> buf; |
|
3007 iAppView->InsertOutput( _L(" Device name: "), EFalse ); |
|
3008 TBuf8<100> retValue; |
|
3009 TInt err( iHaptics->GetDeviceCapability( |
|
3010 CHWRMHaptics::EHWRMHapticsDeviceName, retValue ) ); |
|
3011 if ( err ) |
|
3012 { |
|
3013 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
3014 buf.Format( KFailedFormat, err ); |
|
3015 } |
|
3016 else |
|
3017 { |
|
3018 CnvUtfConverter::ConvertToUnicodeFromUtf8( buf, retValue ); |
|
3019 } |
|
3020 |
|
3021 iAppView->InsertOutput( buf ); |
|
3022 } |
|
3023 |
|
3024 // --------------------------------------------------------------------------- |
|
3025 // |
|
3026 // --------------------------------------------------------------------------- |
|
3027 // |
|
3028 void CHapticsTestAppUi::GetCapabilityMaxEnvelopeTime() |
|
3029 { |
|
3030 TBuf<50> buf; |
|
3031 iAppView->InsertOutput( _L(" Maximum envelop time: "), EFalse ); |
|
3032 TInt retValue( 0 ); |
|
3033 TInt err( iHaptics->GetDeviceCapability( |
|
3034 CHWRMHaptics::EHWRMHapticsMaxEnvelopeTime, retValue ) ); |
|
3035 |
|
3036 if ( err ) |
|
3037 { |
|
3038 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
3039 buf.Format( KFailedFormat, err ); |
|
3040 } |
|
3041 else |
|
3042 { |
|
3043 _LIT( KNumFormat, "%d" ); |
|
3044 buf.Format( KNumFormat, retValue ); |
|
3045 } |
|
3046 |
|
3047 iAppView->InsertOutput( buf ); |
|
3048 } |
|
3049 |
|
3050 // --------------------------------------------------------------------------- |
|
3051 // |
|
3052 // --------------------------------------------------------------------------- |
|
3053 // |
|
3054 void CHapticsTestAppUi::GetCapabilityAPIVersionNumber() |
|
3055 { |
|
3056 TBuf<50> buf; |
|
3057 TInt retValue( 0 ); |
|
3058 iAppView->InsertOutput( _L(" API version: "), EFalse ); |
|
3059 TInt err( iHaptics->GetDeviceCapability( |
|
3060 CHWRMHaptics::EHWRMHapticsAPIVersionNumber, retValue ) ); |
|
3061 |
|
3062 if ( err ) |
|
3063 { |
|
3064 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
3065 buf.Format( KFailedFormat, err ); |
|
3066 } |
|
3067 else |
|
3068 { |
|
3069 _LIT( KNumFormat, "%d" ); |
|
3070 buf.Format( KNumFormat, retValue ); |
|
3071 } |
|
3072 |
|
3073 iAppView->InsertOutput( buf ); |
|
3074 } |
|
3075 |
|
3076 // --------------------------------------------------------------------------- |
|
3077 // |
|
3078 // --------------------------------------------------------------------------- |
|
3079 // |
|
3080 void CHapticsTestAppUi::GetCapabilityMaxIVTSize() |
|
3081 { |
|
3082 TBuf<50> buf; |
|
3083 iAppView->InsertOutput( _L(" Maximum size of IVT file: "), EFalse ); |
|
3084 TInt retValue( 0 ); |
|
3085 TInt err( iHaptics->GetDeviceCapability( |
|
3086 CHWRMHaptics::EHWRMHapticsMaxEffectDataSize, retValue ) ); |
|
3087 |
|
3088 if ( err ) |
|
3089 { |
|
3090 _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); |
|
3091 buf.Format( KFailedFormat, err ); |
|
3092 } |
|
3093 else |
|
3094 { |
|
3095 _LIT( KNumFormat, "%d" ); |
|
3096 buf.Format( KNumFormat, retValue ); |
|
3097 } |
|
3098 |
|
3099 iAppView->InsertOutput( buf, ETrue ); |
|
3100 } |
|
3101 |
|
3102 // --------------------------------------------------------------------------- |
|
3103 // |
|
3104 // --------------------------------------------------------------------------- |
|
3105 // |
|
3106 void CHapticsTestAppUi::SetPropertyPriorityMin() |
|
3107 { |
|
3108 iAppView->InsertOutput( _L(" Setting priority to minimum"), ETrue ); |
|
3109 TInt value(KHWRMHapticsMinDevicePriority); |
|
3110 TRAPD( err, iHaptics->SetDeviceProperty(CHWRMHaptics::EHWRMHapticsPriority, value)); |
|
3111 if ( err ) |
|
3112 { |
|
3113 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3114 } |
|
3115 } |
|
3116 |
|
3117 // --------------------------------------------------------------------------- |
|
3118 // |
|
3119 // --------------------------------------------------------------------------- |
|
3120 // |
|
3121 void CHapticsTestAppUi::SetPropertyPriorityDefault() |
|
3122 { |
|
3123 iAppView->InsertOutput( _L(" Setting priority to default" ), ETrue ); |
|
3124 TInt value( KHWRMHapticsMinDevicePriority ); |
|
3125 |
|
3126 TRAPD( err1, value = iHaptics->DefaultDevicePriority() ); |
|
3127 if ( err1 ) |
|
3128 { |
|
3129 CEikonEnv::Static()->InfoMsg( _L( "DefaultDevicePriority() failed!" ) ); |
|
3130 return; |
|
3131 } |
|
3132 |
|
3133 TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, value ) ); |
|
3134 if ( err2 ) |
|
3135 { |
|
3136 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3137 } |
|
3138 } |
|
3139 |
|
3140 // --------------------------------------------------------------------------- |
|
3141 // |
|
3142 // --------------------------------------------------------------------------- |
|
3143 // |
|
3144 void CHapticsTestAppUi::SetPropertyPriorityMax() |
|
3145 { |
|
3146 iAppView->InsertOutput( _L(" Setting priority to maximum"), ETrue ); |
|
3147 TInt value(KHWRMHapticsMaxDevicePriority); |
|
3148 TRAPD( err, iHaptics->SetDeviceProperty(CHWRMHaptics::EHWRMHapticsPriority, value)); |
|
3149 if ( err ) |
|
3150 { |
|
3151 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3152 } |
|
3153 } |
|
3154 |
|
3155 // --------------------------------------------------------------------------- |
|
3156 // |
|
3157 // --------------------------------------------------------------------------- |
|
3158 // |
|
3159 void CHapticsTestAppUi::GetPropertyPriority() |
|
3160 { |
|
3161 _LIT( KNumFormat, "%d" ); |
|
3162 TBuf<50> buf; |
|
3163 iAppView->InsertOutput( _L(" Device priority: "), EFalse ); |
|
3164 TInt retValue(0); |
|
3165 TRAPD( err, iHaptics->GetDeviceProperty(CHWRMHaptics::EHWRMHapticsPriority, retValue)); |
|
3166 if ( err ) |
|
3167 { |
|
3168 CEikonEnv::Static()->InfoMsg( _L("GetDeviceProperty failed!") ); |
|
3169 } |
|
3170 |
|
3171 buf.Format( KNumFormat, retValue ); |
|
3172 iAppView->InsertOutput( buf, ETrue ); |
|
3173 } |
|
3174 |
|
3175 // --------------------------------------------------------------------------- |
|
3176 // |
|
3177 // --------------------------------------------------------------------------- |
|
3178 // |
|
3179 void CHapticsTestAppUi::SetPropertyDisableEffectsTrue() |
|
3180 { |
|
3181 iAppView->InsertOutput( _L(" Disabling effects" ), ETrue ); |
|
3182 TBool value( ETrue ); |
|
3183 TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, value ) ); |
|
3184 if ( err2 ) |
|
3185 { |
|
3186 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3187 } |
|
3188 } |
|
3189 |
|
3190 // --------------------------------------------------------------------------- |
|
3191 // |
|
3192 // --------------------------------------------------------------------------- |
|
3193 // |
|
3194 void CHapticsTestAppUi::SetPropertyDisableEffectsFalse() |
|
3195 { |
|
3196 iAppView->InsertOutput( _L(" Enabling effects" ), ETrue ); |
|
3197 TBool value( EFalse ); |
|
3198 TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, value ) ); |
|
3199 if ( err2 ) |
|
3200 { |
|
3201 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3202 } |
|
3203 } |
|
3204 |
|
3205 // --------------------------------------------------------------------------- |
|
3206 // |
|
3207 // --------------------------------------------------------------------------- |
|
3208 // |
|
3209 void CHapticsTestAppUi::GetPropertyDisableEffects() |
|
3210 { |
|
3211 iAppView->InsertOutput( _L(" Effects disabled: "), EFalse ); |
|
3212 TInt retValue( EFalse ); |
|
3213 TRAPD( err, iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, retValue ) ); |
|
3214 if ( err ) |
|
3215 { |
|
3216 CEikonEnv::Static()->InfoMsg( _L("GetDeviceProperty failed!") ); |
|
3217 } |
|
3218 else |
|
3219 { |
|
3220 if ( retValue ) |
|
3221 { |
|
3222 iAppView->InsertOutput( _L("TRUE"), ETrue ); |
|
3223 } |
|
3224 else |
|
3225 { |
|
3226 iAppView->InsertOutput( _L("FALSE"), ETrue ); |
|
3227 } |
|
3228 } |
|
3229 } |
|
3230 |
|
3231 // --------------------------------------------------------------------------- |
|
3232 // |
|
3233 // --------------------------------------------------------------------------- |
|
3234 // |
|
3235 void CHapticsTestAppUi::SetPropertyStrengthMin() |
|
3236 { |
|
3237 iAppView->InsertOutput( _L(" Setting strength to mininum" ), ETrue ); |
|
3238 TBool value( KHWRMHapticsMinStrength ); |
|
3239 TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, value ) ); |
|
3240 if ( err2 ) |
|
3241 { |
|
3242 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3243 } |
|
3244 } |
|
3245 |
|
3246 // --------------------------------------------------------------------------- |
|
3247 // |
|
3248 // --------------------------------------------------------------------------- |
|
3249 // |
|
3250 void CHapticsTestAppUi::SetPropertyStrengthMiddle() |
|
3251 { |
|
3252 iAppView->InsertOutput( _L(" Setting strength to middle" ), ETrue ); |
|
3253 TBool value( ( KHWRMHapticsMaxStrength - KHWRMHapticsMinStrength ) / 2 ); |
|
3254 TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, value ) ); |
|
3255 if ( err2 ) |
|
3256 { |
|
3257 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3258 } |
|
3259 } |
|
3260 |
|
3261 // --------------------------------------------------------------------------- |
|
3262 // |
|
3263 // --------------------------------------------------------------------------- |
|
3264 // |
|
3265 void CHapticsTestAppUi::SetPropertyStrengthMax() |
|
3266 { |
|
3267 iAppView->InsertOutput( _L(" Setting strength to max" ), ETrue ); |
|
3268 TBool value( KHWRMHapticsMaxStrength ); |
|
3269 TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, value ) ); |
|
3270 if ( err2 ) |
|
3271 { |
|
3272 CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); |
|
3273 } |
|
3274 } |
|
3275 |
|
3276 // --------------------------------------------------------------------------- |
|
3277 // |
|
3278 // --------------------------------------------------------------------------- |
|
3279 // |
|
3280 void CHapticsTestAppUi::GetPropertyStrength() |
|
3281 { |
|
3282 _LIT( KNumFormat, "%d" ); |
|
3283 TBuf<50> buf; |
|
3284 iAppView->InsertOutput( _L(" Strength level: "), EFalse ); |
|
3285 TInt retValue(0); |
|
3286 TRAPD( err, iHaptics->GetDeviceProperty(CHWRMHaptics::EHWRMHapticsStrength, retValue)); |
|
3287 if ( err ) |
|
3288 { |
|
3289 CEikonEnv::Static()->InfoMsg( _L("GetDeviceProperty failed!") ); |
|
3290 } |
|
3291 |
|
3292 buf.Format( KNumFormat, retValue ); |
|
3293 iAppView->InsertOutput( buf, ETrue ); |
|
3294 } |
|
3295 |
|
3296 |
|
3297 // --------------------------------------------------------------------------- |
|
3298 // Enables streaming mode. |
|
3299 // --------------------------------------------------------------------------- |
|
3300 // |
|
3301 void CHapticsTestAppUi::StartStreaming() |
|
3302 { |
|
3303 iCurrentSample = 0; |
|
3304 iEffectHandle = KErrNotFound; |
|
3305 TInt err = iHaptics->CreateStreamingEffect( iEffectHandle ); |
|
3306 |
|
3307 if ( err ) |
|
3308 { |
|
3309 TBuf<16> errCode; |
|
3310 errCode.AppendNum( err ); |
|
3311 iAppView->InsertOutput( _L("Create streaming effect failed! Err: "), EFalse ); |
|
3312 iAppView->InsertOutput( errCode ); |
|
3313 } |
|
3314 else |
|
3315 { |
|
3316 TBuf<16> handleBuf; |
|
3317 handleBuf.AppendNum( iEffectHandle ); |
|
3318 iAppView->InsertOutput( _L("Streaming effect created successfully!") ); |
|
3319 iAppView->InsertOutput( _L(" Effect handle: "), EFalse ); |
|
3320 iAppView->InsertOutput( handleBuf ); |
|
3321 |
|
3322 iStreaming = ETrue; |
|
3323 } |
|
3324 } |
|
3325 |
|
3326 |
|
3327 // --------------------------------------------------------------------------- |
|
3328 // Plays one streaming sample from KStreamArray. |
|
3329 // --------------------------------------------------------------------------- |
|
3330 // |
|
3331 void CHapticsTestAppUi::PlayStreamingSample( TInt aSampleId ) |
|
3332 { |
|
3333 RBuf8 sampleBuffer; |
|
3334 sampleBuffer.ReAlloc( sizeof( KStreamArray[aSampleId] ) ); |
|
3335 TUint8* tmpPtr = const_cast<TUint8*>( sampleBuffer.Ptr() ); |
|
3336 memcpy( tmpPtr, KStreamArray[aSampleId], sizeof( KStreamArray[aSampleId] ) ); |
|
3337 sampleBuffer.SetLength( sizeof( KStreamArray[aSampleId] ) ); |
|
3338 |
|
3339 iHaptics->PlayStreamingSample( iEffectHandle, sampleBuffer ); |
|
3340 |
|
3341 sampleBuffer.Close(); |
|
3342 } |
|
3343 |
|
3344 |
|
3345 // --------------------------------------------------------------------------- |
|
3346 // Disables streaming mode. |
|
3347 // --------------------------------------------------------------------------- |
|
3348 // |
|
3349 void CHapticsTestAppUi::StopStreaming() |
|
3350 { |
|
3351 iStreaming = EFalse; |
|
3352 |
|
3353 TInt err = iHaptics->DestroyStreamingEffect( iEffectHandle ); |
|
3354 if ( err ) |
|
3355 { |
|
3356 TBuf<16> errCode; |
|
3357 errCode.AppendNum( err ); |
|
3358 iAppView->InsertOutput( _L("Destoy streaming effect failed! Err: "), EFalse ); |
|
3359 iAppView->InsertOutput( errCode ); |
|
3360 } |
|
3361 else |
|
3362 { |
|
3363 TBuf<16> handleBuf; |
|
3364 handleBuf.AppendNum( iEffectHandle ); |
|
3365 iAppView->InsertOutput( _L("Streaming effect destroyed successfully!") ); |
|
3366 } |
|
3367 } |
|
3368 |
|
3369 // End of file |