1 /* |
|
2 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Generic hid implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <etel3rdparty.h> |
|
20 #include <e32std.h> |
|
21 #include <e32svr.h> |
|
22 #include <coedef.h> |
|
23 #include <eiksvdef.h> |
|
24 #include <apgcli.h> |
|
25 #include <apgtask.h> |
|
26 #include <e32property.h> |
|
27 #include <alarmuidomainpskeys.h> |
|
28 |
|
29 #include <mpxplaybackmessage.h> |
|
30 #include <mpxmessagegeneraldefs.h> |
|
31 #include <mpxplaybackmessagedefs.h> |
|
32 |
|
33 #include "hidremconbearerinternalpskeys.h" |
|
34 #include "hidremconbearerscancodes.h" |
|
35 #include "headset.h" |
|
36 #include "finder.h" |
|
37 |
|
38 #include "debug.h" |
|
39 |
|
40 const TInt KHidUndefinedKeyCode = 0; |
|
41 const TInt KHidNotSetKeyValue = 0; |
|
42 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds |
|
43 const TInt KDoubleClickTimeoutRing = 500000; // 0,5 seconds |
|
44 const TInt KScanClickTimeout = 500000; // 0,5 seconds |
|
45 const TInt KLongClickTimeout = 3000000; // 3 seconds |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CHidHeadsetDriver() |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CHidHeadsetDriver::CHidHeadsetDriver( MDriverAccess* aGenericHid ) : |
|
54 iGenericHid( aGenericHid ), iFieldList(), iDriverState( EUninitialised ), |
|
55 iConnectionId( 0 ), iSupportedFieldCount( 0 ), iForwardStatus( |
|
56 EScanNotPressed ), iBackwardStatus( EScanNotPressed ) |
|
57 { |
|
58 TRACE_FUNC_ENTRY_THIS |
|
59 TRACE_FUNC_EXIT |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // NewLC |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CHidHeadsetDriver* CHidHeadsetDriver::NewLC( MDriverAccess* aGenericHid ) |
|
67 { |
|
68 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::NewLC(0x%08x)"), aGenericHid)); |
|
69 CHidHeadsetDriver* self = new ( ELeave ) CHidHeadsetDriver( aGenericHid ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // NewL |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 CHidHeadsetDriver* CHidHeadsetDriver::NewL( MDriverAccess* aGenericHid ) |
|
80 { |
|
81 CHidHeadsetDriver* self = CHidHeadsetDriver::NewLC( aGenericHid ); |
|
82 CleanupStack::Pop(); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // ConstructL() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CHidHeadsetDriver::ConstructL() |
|
91 { |
|
92 TRACE_FUNC_THIS |
|
93 iTelephony = CTelephony::NewL(); |
|
94 User::LeaveIfError( iAlarmServerSession.Connect() ); |
|
95 iMusicPlayer = MMPXPlaybackUtility::UtilityL( KPbModeActivePlayer ); |
|
96 iMusicPlayer->AddObserverL( *this ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Destructor |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CHidHeadsetDriver::~CHidHeadsetDriver() |
|
104 { |
|
105 TRACE_FUNC_THIS |
|
106 iAlarmServerSession.Close(); |
|
107 delete iTelephony; |
|
108 iFieldList.Reset(); |
|
109 iFieldList.Close(); |
|
110 delete iDoubleClicktimer; |
|
111 if ( iMusicPlayer ) |
|
112 { |
|
113 iMusicPlayer->Close(); |
|
114 } |
|
115 delete iScanPreviousTimer; |
|
116 delete iScanNextTimer; |
|
117 delete iLongClicktimer; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // From class CHidDriver |
|
122 // StartL() |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CHidHeadsetDriver::StartL( TInt /*aConnectionId*/) |
|
126 { |
|
127 TRACE_FUNC |
|
128 // Ready to process headset events: |
|
129 iDriverState = EInitialised; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // From class CHidDriver |
|
134 // InitialiseL() |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CHidHeadsetDriver::InitialiseL( TInt aConnectionId ) |
|
138 { |
|
139 TRACE_FUNC |
|
140 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::InitialiseL(%d)"), |
|
141 aConnectionId)); |
|
142 // Store the connection ID: |
|
143 iConnectionId = aConnectionId; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // From class CHidDriver |
|
148 // Stop() |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CHidHeadsetDriver::Stop() |
|
152 { |
|
153 TRACE_FUNC |
|
154 iDriverState = EDisabled; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // From class CHidDriver |
|
159 // DataIn() |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 TInt CHidHeadsetDriver::DataIn( CHidTransport::THidChannelType aChannel, |
|
163 const TDesC8& aPayload ) |
|
164 { |
|
165 TInt retVal = KErrNone; |
|
166 switch ( aChannel ) |
|
167 { |
|
168 case CHidTransport::EHidChannelInt: |
|
169 if ( EInitialised == iDriverState ) |
|
170 { |
|
171 retVal = InterruptData( aPayload ); |
|
172 } |
|
173 break; |
|
174 |
|
175 case CHidTransport::EHidChannelCtrl: |
|
176 retVal = KErrNotSupported; |
|
177 break; |
|
178 |
|
179 default: |
|
180 retVal = KErrNotSupported; |
|
181 break; |
|
182 } |
|
183 return retVal; |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // From class CHidDriver |
|
188 // CommandResult() |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CHidHeadsetDriver::CommandResult( TInt /*aCmdAck*/) |
|
192 { |
|
193 // No implementation as we don't issue any requests to be acknowledged |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // From class CHidDriver |
|
198 // Disconnected() |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 void CHidHeadsetDriver::Disconnected( TInt aReason ) |
|
202 { |
|
203 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::Disconnected(%d)"), aReason)); |
|
204 aReason = aReason; |
|
205 Stop(); |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // From class CHidDriver |
|
210 // SetInputHandlingReg() |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 void CHidHeadsetDriver::SetInputHandlingReg( |
|
214 CHidInputDataHandlingReg* aHandlingReg ) |
|
215 { |
|
216 iInputHandlingReg = aHandlingReg; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // From class CHidDriver |
|
221 // InterruptData() |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 TInt CHidHeadsetDriver::InterruptData( const TDesC8& aPayload ) |
|
225 { |
|
226 // If the report has a report ID, it is in the first byte. |
|
227 // If not, this value is ignored (see CField::IsInReport()). |
|
228 // |
|
229 TInt retVal = KErrNone; |
|
230 TInt ret = KErrNotSupported; |
|
231 TInt firstByte = aPayload[0]; |
|
232 |
|
233 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::InterruptData(), report \ |
|
234 0x%x (%d), length %d"),firstByte, firstByte, aPayload.Length())); |
|
235 |
|
236 if ( iFieldList.Count() == 0 ) |
|
237 { |
|
238 retVal = KErrNotSupported; |
|
239 } |
|
240 for ( TInt i = 0; i < iFieldList.Count(); i++ ) |
|
241 { |
|
242 if ( iFieldList[i]->IsInReport( firstByte ) ) |
|
243 { |
|
244 ret = HandleReport( aPayload, iFieldList[i] ); |
|
245 if ( ret == KErrNone ) |
|
246 { |
|
247 retVal = KErrNone; |
|
248 } |
|
249 } |
|
250 else |
|
251 { |
|
252 retVal = KErrNotSupported; |
|
253 } |
|
254 } |
|
255 return retVal; |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // HandleReport() |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 TInt CHidHeadsetDriver::HandleReport( const TDesC8& aReport, |
|
263 const CField* aField ) |
|
264 { |
|
265 TRACE_FUNC_ENTRY |
|
266 TReportTranslator report( aReport, aField ); |
|
267 TInt retVal = KErrNotSupported; |
|
268 |
|
269 // release if key if it pressed and relased |
|
270 ReleasePressedKeys( report ); |
|
271 |
|
272 if ( HandleTelephonyUsage( report ) == KErrNone ) |
|
273 { |
|
274 retVal = KErrNone; |
|
275 } |
|
276 |
|
277 if ( HandleControlUsage( report ) == KErrNone ) |
|
278 { |
|
279 retVal = KErrNone; |
|
280 } |
|
281 |
|
282 if ( HandleVolumeUsage( report ) == KErrNone ) |
|
283 { |
|
284 retVal = KErrNone; |
|
285 } |
|
286 TRACE_FUNC_EXIT |
|
287 return retVal; |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // HandleTelephonyUsage() |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 TInt CHidHeadsetDriver::HandleTelephonyUsage( TReportTranslator& aReport ) |
|
295 { |
|
296 TRACE_FUNC_ENTRY |
|
297 TInt retVal = KErrNotSupported; |
|
298 TInt hookSwitch = 0; |
|
299 TInt mute = 0; |
|
300 TInt poc = 0; |
|
301 |
|
302 // P&S key variables |
|
303 TUint key = KHidUndefinedKeyCode; |
|
304 TInt value = KHidNotSetKeyValue; |
|
305 |
|
306 if ( aReport.GetValue( mute, ETelephonyUsagePhoneMute ) == KErrNone |
|
307 && mute == 1 ) |
|
308 { |
|
309 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send mute \ |
|
310 command")); |
|
311 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageTelephony, |
|
312 ETelephonyUsagePhoneMute ) ) |
|
313 { |
|
314 key = KHidMuteKeyEvent; |
|
315 value = KPSMuteClicked; |
|
316 iInputHandlingReg->AddHandledEvent( EUsagePageTelephony, |
|
317 ETelephonyUsagePhoneMute ); |
|
318 } |
|
319 } |
|
320 else if ( aReport.GetValue( hookSwitch, ETelephonyUsageHookSwitch ) |
|
321 == KErrNone && hookSwitch == 1 ) |
|
322 { |
|
323 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send hook \ |
|
324 switch command (disabled)")); |
|
325 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageTelephony, |
|
326 ETelephonyUsageHookSwitch ) ) |
|
327 { |
|
328 HookKeyPres( ETrue ); |
|
329 iInputHandlingReg->AddHandledEvent( EUsagePageTelephony, |
|
330 ETelephonyUsageHookSwitch ); |
|
331 } |
|
332 } |
|
333 else if ( aReport.GetValue( poc, ETelephonyUsagePoC ) == KErrNone && poc |
|
334 == 1 ) |
|
335 { |
|
336 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send PoC \ |
|
337 command (disabled)")); |
|
338 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageTelephony, |
|
339 ETelephonyUsagePoC ) ) |
|
340 { |
|
341 key = KHidMuteKeyEvent; |
|
342 value = KPSMuteClicked; |
|
343 iInputHandlingReg->AddHandledEvent( EUsagePageTelephony, |
|
344 ETelephonyUsagePoC ); |
|
345 } |
|
346 } |
|
347 if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue ) |
|
348 { |
|
349 TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value ); |
|
350 retVal = KErrNone; |
|
351 } |
|
352 |
|
353 TRACE_FUNC_EXIT |
|
354 return retVal; |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // HandleTelephonyUsage() |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 TInt CHidHeadsetDriver::HandleControlUsage( TReportTranslator& aReport ) |
|
362 { |
|
363 TRACE_FUNC_ENTRY |
|
364 TInt retVal = KErrNotSupported; |
|
365 TInt playPause = 0; |
|
366 TInt scanNext = 0; |
|
367 TInt scanPrev = 0; |
|
368 TInt stop = 0; |
|
369 |
|
370 // P&S key variables |
|
371 TUint key = KHidUndefinedKeyCode; |
|
372 TInt value = KHidNotSetKeyValue; |
|
373 |
|
374 if ( aReport.GetValue( playPause, EConsumerUsagePlayPause ) == KErrNone |
|
375 && playPause ) |
|
376 { |
|
377 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer, |
|
378 EConsumerUsagePlayPause ) ) |
|
379 { |
|
380 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \ |
|
381 play/pause command (currently only play)")); |
|
382 key = KHidControlKeyEvent; |
|
383 value = EPlayClicked; |
|
384 iInputHandlingReg->AddHandledEvent( EUsagePageConsumer, |
|
385 EConsumerUsagePlayPause ); |
|
386 } |
|
387 } |
|
388 else if ( aReport.GetValue( scanNext, EConsumerUsageScanNext ) |
|
389 == KErrNone && scanNext ) |
|
390 { |
|
391 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer, |
|
392 EConsumerUsageScanNext ) ) |
|
393 { |
|
394 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \ |
|
395 scan next command")); |
|
396 TRAP_IGNORE( HandleScanNextPressL() ); |
|
397 iInputHandlingReg->AddHandledEvent( EUsagePageConsumer, |
|
398 EConsumerUsageScanNext ); |
|
399 } |
|
400 } |
|
401 else if ( aReport.GetValue( scanPrev, EConsumerUsageScanPrev ) |
|
402 == KErrNone && scanPrev ) |
|
403 { |
|
404 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer, |
|
405 EConsumerUsageScanPrev ) ) |
|
406 { |
|
407 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan \ |
|
408 prev command")); |
|
409 TRAP_IGNORE( HandleScanPrevPressL()); |
|
410 iInputHandlingReg->AddHandledEvent( EUsagePageConsumer, |
|
411 EConsumerUsageScanPrev ); |
|
412 } |
|
413 } |
|
414 else if ( aReport.GetValue( stop, EConsumerUsageStop ) == KErrNone |
|
415 && stop ) |
|
416 { |
|
417 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer, |
|
418 EConsumerUsageStop ) ) |
|
419 { |
|
420 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \ |
|
421 stop command")); |
|
422 key = KHidControlKeyEvent; |
|
423 value = EStopClicked; |
|
424 iInputHandlingReg->AddHandledEvent( EUsagePageConsumer, |
|
425 EConsumerUsageScanPrev ); |
|
426 } |
|
427 } |
|
428 if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue ) |
|
429 { |
|
430 TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value ); |
|
431 retVal = KErrNone; |
|
432 } |
|
433 |
|
434 TRACE_FUNC_EXIT |
|
435 return retVal; |
|
436 } |
|
437 |
|
438 // --------------------------------------------------------------------------- |
|
439 // HandleVolumeUsage() |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 TInt CHidHeadsetDriver::HandleVolumeUsage( TReportTranslator& aReport ) |
|
443 { |
|
444 TRACE_FUNC_ENTRY |
|
445 TInt retVal = KErrNotSupported; |
|
446 |
|
447 TInt volUp = 0; |
|
448 TInt volDown = 0; |
|
449 TInt speakermute = 0; |
|
450 |
|
451 // P&S key variables |
|
452 TUint key = KHidUndefinedKeyCode; |
|
453 TInt value = KHidNotSetKeyValue; |
|
454 |
|
455 if ( aReport.GetValue( volUp, EConsumerUsageVolumeInc ) == KErrNone |
|
456 && volUp ) |
|
457 { |
|
458 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer, |
|
459 EConsumerUsageVolumeInc ) ) |
|
460 { |
|
461 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): \ |
|
462 Send volume up command")); |
|
463 key = KHidAccessoryVolumeEvent; |
|
464 iVolumeUpPressed = ETrue; |
|
465 value = KPSVolumeUpPressed; |
|
466 iInputHandlingReg->AddHandledEvent( EUsagePageConsumer, |
|
467 EConsumerUsageScanPrev ); |
|
468 } |
|
469 } |
|
470 else if ( aReport.GetValue( volDown, EConsumerUsageVolumeDec ) |
|
471 == KErrNone && volDown ) |
|
472 { |
|
473 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer, |
|
474 EConsumerUsageVolumeDec ) ) |
|
475 { |
|
476 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \ |
|
477 volume down command")); |
|
478 key = KHidAccessoryVolumeEvent; |
|
479 iVolumeDownPressed = ETrue; |
|
480 value = KPSVolumeDownPressed; |
|
481 iInputHandlingReg->AddHandledEvent( EUsagePageConsumer, |
|
482 EConsumerUsageVolumeDec ); |
|
483 } |
|
484 } |
|
485 else if ( ( aReport.GetValue( speakermute, EConsumerUsageMute ) |
|
486 == KErrNone && speakermute == 1 ) ) |
|
487 { |
|
488 if ( iInputHandlingReg->AllowedToHandleEvent( EUsagePageConsumer, |
|
489 EConsumerUsageMute ) ) |
|
490 { |
|
491 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Send \ |
|
492 mute command")); |
|
493 key = KHidMuteKeyEvent; |
|
494 value = KPSMuteClicked; |
|
495 iInputHandlingReg->AddHandledEvent( EUsagePageConsumer, |
|
496 EConsumerUsageMute ); |
|
497 } |
|
498 } |
|
499 |
|
500 if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue ) |
|
501 { |
|
502 TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value ); |
|
503 retVal = KErrNone; |
|
504 } |
|
505 |
|
506 TRACE_FUNC_EXIT |
|
507 return retVal; |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 // HandleScanNextPressL() |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 void CHidHeadsetDriver::HandleScanNextPressL() |
|
515 { |
|
516 TRACE_FUNC_ENTRY |
|
517 iForwardStatus = EScanPressed; |
|
518 |
|
519 delete iScanNextTimer; |
|
520 iScanNextTimer = NULL; |
|
521 |
|
522 /** |
|
523 * Scan key has two different behaviour if you are short click buttun or long |
|
524 * click button. In short press next track command is sent and whit long press |
|
525 * is sending seek forward command. iScanNextTimer is used to detect if click |
|
526 * is long click or short click. |
|
527 */ |
|
528 |
|
529 iScanNextTimer = CKeyPressTimer::NewL( this, TTimeIntervalMicroSeconds32( |
|
530 KScanClickTimeout ), EScanNextPressTimer ); |
|
531 |
|
532 TRACE_FUNC_EXIT |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // HandleScanNextPressL() |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 void CHidHeadsetDriver::HandleScanPrevPressL() |
|
540 { |
|
541 TRACE_FUNC_ENTRY |
|
542 iBackwardStatus = EScanPressed; |
|
543 |
|
544 delete iScanPreviousTimer; |
|
545 iScanPreviousTimer = NULL; |
|
546 |
|
547 /** |
|
548 * Scan key has two different behaviour if you are short click buttun or |
|
549 * long click button. In short press previous track command is sent and |
|
550 * whit long press is sending seek forward command. iScanPreviousTimer |
|
551 * is used to detect if click is long click or short click. |
|
552 */ |
|
553 iScanPreviousTimer = CKeyPressTimer::NewL( this, |
|
554 TTimeIntervalMicroSeconds32( KScanClickTimeout ), |
|
555 EScanPrevPressTimer ); |
|
556 TRACE_FUNC_EXIT |
|
557 } |
|
558 |
|
559 // --------------------------------------------------------------------------- |
|
560 // ReleasePressedVolumeKeys |
|
561 // --------------------------------------------------------------------------- |
|
562 // |
|
563 void CHidHeadsetDriver::ReleasePressedVolumeKeys( |
|
564 TReportTranslator& aReportTranslator ) |
|
565 { |
|
566 TInt volUp = 0; |
|
567 TInt volDown = 0; |
|
568 TUint key = KHidUndefinedKeyCode; |
|
569 TInt value = KHidNotSetKeyValue; |
|
570 |
|
571 if ( iVolumeUpPressed ) |
|
572 { |
|
573 if ( aReportTranslator.GetValue( volUp, EConsumerUsageVolumeInc ) |
|
574 == KErrNone && volDown == 0 ) |
|
575 { |
|
576 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::ReleasepressedKeys(): \ |
|
577 Volume up released")); |
|
578 key = KHidAccessoryVolumeEvent; |
|
579 iVolumeUpPressed = EFalse; |
|
580 value = KPSVolumeUpReleased; |
|
581 } |
|
582 } |
|
583 else if ( iVolumeDownPressed ) |
|
584 { |
|
585 if ( aReportTranslator.GetValue( volDown, EConsumerUsageVolumeDec ) |
|
586 == KErrNone && volDown == 0 ) |
|
587 { |
|
588 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::ReleasepressedKeys(): \ |
|
589 Volume downkey realeased")); |
|
590 key = KHidAccessoryVolumeEvent; |
|
591 iVolumeDownPressed = EFalse; |
|
592 value = KPSVolumeDownReleased; |
|
593 } |
|
594 } |
|
595 if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue ) |
|
596 { |
|
597 TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value ); |
|
598 |
|
599 } |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------------------------- |
|
603 // ReleasePressedScanKeys() |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 void CHidHeadsetDriver::ReleasePressedScanKeys( |
|
607 TReportTranslator& aReportTranslator ) |
|
608 { |
|
609 TInt scanNext = 0; |
|
610 TInt scanPrev = 0; |
|
611 TUint key = KHidUndefinedKeyCode; |
|
612 TInt value = KHidNotSetKeyValue; |
|
613 |
|
614 if ( iForwardStatus != EScanNotPressed ) |
|
615 { |
|
616 if ( aReportTranslator.GetValue( scanNext, EConsumerUsageScanNext ) |
|
617 == KErrNone && scanNext == 0 ) |
|
618 { |
|
619 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan \ |
|
620 next command released")); |
|
621 HandleScanNextRelease( key, value ); |
|
622 } |
|
623 } |
|
624 else if ( iBackwardStatus != EScanNotPressed ) |
|
625 { |
|
626 if ( aReportTranslator.GetValue( scanPrev, EConsumerUsageScanPrev ) |
|
627 == KErrNone && scanPrev == 0 ) |
|
628 { |
|
629 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan \ |
|
630 prev command released")); |
|
631 HandleScanPreviousRelease( key, value ); |
|
632 } |
|
633 } |
|
634 if ( key != KHidUndefinedKeyCode && value != KHidNotSetKeyValue ) |
|
635 { |
|
636 TInt err = RProperty::Set( KPSUidHidEventNotifier, key, value ); |
|
637 } |
|
638 } |
|
639 // --------------------------------------------------------------------------- |
|
640 // ReleasePressedKeys() |
|
641 // --------------------------------------------------------------------------- |
|
642 // |
|
643 void CHidHeadsetDriver::ReleasePressedKeys( |
|
644 TReportTranslator& aReportTranslator ) |
|
645 { |
|
646 TRACE_FUNC_ENTRY |
|
647 |
|
648 TInt hookSwitch = 0; |
|
649 /* |
|
650 * Check hook key release here, because hook key long press |
|
651 * is handled different way. |
|
652 */ |
|
653 if ( iOnHookPressed || iOffHookPressed || iNoneHookPressed ) |
|
654 { |
|
655 if ( aReportTranslator.GetValue( hookSwitch, |
|
656 ETelephonyUsageHookSwitch ) == KErrNone && hookSwitch == 0 ) |
|
657 { |
|
658 ReleaseHookKey(); |
|
659 } |
|
660 } |
|
661 ReleasePressedVolumeKeys( aReportTranslator ); |
|
662 |
|
663 ReleasePressedScanKeys( aReportTranslator ); |
|
664 |
|
665 TRACE_FUNC_EXIT |
|
666 } |
|
667 |
|
668 // --------------------------------------------------------------------------- |
|
669 // HandleScanNextRelease() |
|
670 // --------------------------------------------------------------------------- |
|
671 // |
|
672 void CHidHeadsetDriver::HandleScanNextRelease( TUint& aKeyCode, TInt& aValue ) |
|
673 { |
|
674 TRACE_FUNC_ENTRY |
|
675 aKeyCode = KHidControlKeyEvent; |
|
676 if ( iForwardStatus == EScanPressed ) |
|
677 { |
|
678 aValue = EForwardClicked; |
|
679 } |
|
680 else //long press |
|
681 { |
|
682 aValue = EFastForwardReleased; |
|
683 } |
|
684 iForwardStatus = EScanNotPressed; |
|
685 |
|
686 delete iScanNextTimer; |
|
687 iScanNextTimer = NULL; |
|
688 |
|
689 TRACE_FUNC_EXIT |
|
690 } |
|
691 |
|
692 // --------------------------------------------------------------------------- |
|
693 // HandleScanPreviousRelease() |
|
694 // --------------------------------------------------------------------------- |
|
695 // |
|
696 void CHidHeadsetDriver::HandleScanPreviousRelease( TUint& aKeyCode, |
|
697 TInt& aValue ) |
|
698 { |
|
699 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::HandleReport(): Scan prev \ |
|
700 command released")); |
|
701 aKeyCode = KHidControlKeyEvent; |
|
702 if ( iBackwardStatus == EScanPressed ) |
|
703 { |
|
704 aValue = EBackwardClicked; |
|
705 } |
|
706 else //long press |
|
707 { |
|
708 aValue = ERewindReleased; |
|
709 } |
|
710 iBackwardStatus = EScanNotPressed; |
|
711 |
|
712 delete iScanPreviousTimer; |
|
713 iScanPreviousTimer = NULL; |
|
714 |
|
715 TRACE_FUNC_EXIT |
|
716 } |
|
717 // --------------------------------------------------------------------------- |
|
718 // HookKeyPres() |
|
719 // --------------------------------------------------------------------------- |
|
720 // |
|
721 void CHidHeadsetDriver::HookKeyPres( TBool aStatus ) |
|
722 { |
|
723 TRACE_FUNC_ENTRY |
|
724 |
|
725 THookHandling hookStatus = HookStatus(); |
|
726 if ( !iAlarmStatus ) |
|
727 { |
|
728 iAlarmStatus = AlarmStatus(); |
|
729 } |
|
730 |
|
731 iPlayingStatus = MusicPlayingStatus(); |
|
732 |
|
733 if ( aStatus ) |
|
734 { |
|
735 switch ( hookStatus ) |
|
736 { |
|
737 case EOnHook: |
|
738 if ( !iIncomingCallStatus ) |
|
739 { |
|
740 // For the first click, trigger the timer |
|
741 // single click is handled in ExpiredDoubleClickTimer |
|
742 if ( iDoubleClicktimer ) |
|
743 { |
|
744 delete iDoubleClicktimer; |
|
745 iDoubleClicktimer = NULL; |
|
746 } |
|
747 TRAP_IGNORE( iDoubleClicktimer = CKeyPressTimer::NewL( this, |
|
748 TTimeIntervalMicroSeconds32( KDoubleClickTimeoutRing ), |
|
749 EDoubleClickTimer ) ); |
|
750 if ( iDoubleClicktimer ) |
|
751 { |
|
752 iIncomingCallStatus = ETrue; |
|
753 } |
|
754 else // If fail to create timer, handle as single click, |
|
755 // for double click case, the next click will hang off |
|
756 { |
|
757 iIncomingCallStatus = EFalse; |
|
758 iOnHookPressed = ETrue; |
|
759 } |
|
760 break; // switch |
|
761 } |
|
762 else |
|
763 { |
|
764 iIncomingCallStatus = EFalse; |
|
765 if ( iDoubleClicktimer ) |
|
766 { |
|
767 delete iDoubleClicktimer; |
|
768 iDoubleClicktimer = NULL; |
|
769 } |
|
770 // This is the double click case, handle as EOffHook |
|
771 } |
|
772 // No break here |
|
773 case EOffHook: |
|
774 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed")); |
|
775 iOffHookPressed = ETrue; |
|
776 break; |
|
777 case ENoHook: |
|
778 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); |
|
779 TRAP_IGNORE( HandleNoneHookPressL() ); |
|
780 break; |
|
781 default: |
|
782 TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \ |
|
783 supported")); |
|
784 } |
|
785 } |
|
786 else |
|
787 { |
|
788 ReleaseHookKey(); |
|
789 } |
|
790 TRACE_FUNC_EXIT |
|
791 } |
|
792 |
|
793 // --------------------------------------------------------------------------- |
|
794 // ReleaseHookKey() |
|
795 // --------------------------------------------------------------------------- |
|
796 // |
|
797 void CHidHeadsetDriver::ReleaseHookKey() |
|
798 { |
|
799 TRACE_FUNC_ENTRY |
|
800 |
|
801 if ( iOnHookPressed ) |
|
802 { |
|
803 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook On released")); |
|
804 iOnHookPressed = EFalse; |
|
805 // Incoming call |
|
806 RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent, |
|
807 KPSAnsweClicked ); |
|
808 } |
|
809 if ( iOffHookPressed ) |
|
810 { |
|
811 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off released")); |
|
812 iOffHookPressed = EFalse; |
|
813 // Disconnect connected call |
|
814 RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent, |
|
815 KPSHangUpClicked ); |
|
816 } |
|
817 if ( iNoneHookPressed && !iAlarmStatus ) |
|
818 { |
|
819 TRAP_IGNORE( HandleIdleHookReleaseL() ); |
|
820 } |
|
821 if ( iNoneHookPressed && iAlarmStatus ) |
|
822 { |
|
823 TRAP_IGNORE( HandleAlarmHookReleaseL() ); |
|
824 } |
|
825 if ( iLongClicktimer ) |
|
826 { |
|
827 iLongPress = EFalse; |
|
828 } |
|
829 delete iLongClicktimer; |
|
830 iLongClicktimer = NULL; |
|
831 TRACE_FUNC_EXIT |
|
832 } |
|
833 |
|
834 // --------------------------------------------------------------------------- |
|
835 // HandleNoneHook() |
|
836 // --------------------------------------------------------------------------- |
|
837 // |
|
838 void CHidHeadsetDriver::HandleNoneHookPressL() |
|
839 { |
|
840 TRACE_FUNC_ENTRY |
|
841 /** Start long press timer is alarm is ongoing, or phone |
|
842 * is not alarming and thre are no hook key press whitout |
|
843 * release |
|
844 */ |
|
845 if ( iAlarmStatus || ( !iNoneHookPressed && !iAlarmStatus ) ) |
|
846 { |
|
847 iNoneHookPressed = ETrue; |
|
848 iLongPress = EFalse; |
|
849 |
|
850 delete iLongClicktimer; |
|
851 iLongClicktimer = NULL; |
|
852 |
|
853 iLongClicktimer = CKeyPressTimer::NewL( this, |
|
854 TTimeIntervalMicroSeconds32( KLongClickTimeout ), |
|
855 ELongPressTimer ); |
|
856 } |
|
857 TRACE_FUNC_EXIT |
|
858 } |
|
859 |
|
860 // --------------------------------------------------------------------------- |
|
861 // HandleAlarmHookReleaseL() |
|
862 // --------------------------------------------------------------------------- |
|
863 // |
|
864 void CHidHeadsetDriver::HandleAlarmHookReleaseL() |
|
865 { |
|
866 TRACE_FUNC_ENTRY |
|
867 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None released")); |
|
868 /** |
|
869 * Hook key is released when there is active alarm. Start double |
|
870 * click timer for monitoring double click. |
|
871 */ |
|
872 if ( !iDoubleClicktimer && !iLongPress ) |
|
873 { |
|
874 iDoubleClicktimer = CKeyPressTimer::NewL( this, |
|
875 TTimeIntervalMicroSeconds32( KDoubleClickTimeout ), |
|
876 EDoubleClickTimer ); |
|
877 } |
|
878 /** |
|
879 * Stot alar when hook key is pressed long time during alarm. |
|
880 */ |
|
881 else if ( iLongPress ) |
|
882 { |
|
883 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Stop alarm")); |
|
884 RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, |
|
885 EAlarmUIStopAlarm ); |
|
886 iAlarmStatus = EFalse; |
|
887 iLongPress = EFalse; |
|
888 } |
|
889 /** |
|
890 * Double click timer exsist and is it not long press, so |
|
891 * this is double click release. Then snooze alarm. |
|
892 */ |
|
893 else if ( !iLongPress ) |
|
894 { |
|
895 delete iDoubleClicktimer; |
|
896 iDoubleClicktimer = NULL; |
|
897 iAlarmStatus = EFalse; |
|
898 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Snooze")); |
|
899 RProperty::Set( KPSUidAlarmExtCntl, KAlarmSnoozeKey, |
|
900 EAlarmUISnoozeAlarm ); |
|
901 } |
|
902 TRACE_FUNC_EXIT |
|
903 } |
|
904 |
|
905 // --------------------------------------------------------------------------- |
|
906 // HandleIdleHookReleaseL |
|
907 // --------------------------------------------------------------------------- |
|
908 // |
|
909 void CHidHeadsetDriver::HandleIdleHookReleaseL() |
|
910 { |
|
911 TRACE_FUNC_ENTRY |
|
912 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None released")); |
|
913 iNoneHookPressed = EFalse; |
|
914 /** |
|
915 * Hook key is released when there is music playing ongoing. Start double |
|
916 * click timer for monitoring double click. |
|
917 */ |
|
918 if ( !iDoubleClicktimer && !iLongPress ) |
|
919 { |
|
920 iDoubleClicktimer = CKeyPressTimer::NewL( this, |
|
921 TTimeIntervalMicroSeconds32( KDoubleClickTimeout ), |
|
922 EDoubleClickTimer ); |
|
923 } |
|
924 /** |
|
925 * Hook key is released when there is not music playing ongoing. |
|
926 * Because double click timer is active this is second release in |
|
927 * short beriod and redial needs to be issued. |
|
928 */ |
|
929 else if ( !iLongPress && !iPlayingStatus ) |
|
930 { |
|
931 delete iDoubleClicktimer; |
|
932 iDoubleClicktimer = NULL; |
|
933 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Redial")); |
|
934 RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent, |
|
935 KPSRedial ); |
|
936 } |
|
937 /** |
|
938 * Hook key is released when there is music playing ongoing. |
|
939 * Because double click timer is active, is send forward command sent |
|
940 * and DoubleNextClick set to true for sending next command. |
|
941 */ |
|
942 else if ( iPlayingStatus && !iLongPress ) |
|
943 { |
|
944 delete iDoubleClicktimer; |
|
945 iDoubleClicktimer = NULL; |
|
946 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver next after next")); |
|
947 if ( !iLongPress ) |
|
948 { |
|
949 iDoubleNextClick = ETrue; //set to true and when player change |
|
950 //track press next again |
|
951 } |
|
952 RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent, |
|
953 EForwardClicked ); //next after next |
|
954 } |
|
955 /** |
|
956 * Long press release when there are no actie calls, alarms, and music |
|
957 * playing is stopped, activates voice dialing. |
|
958 */ |
|
959 else if ( iLongPress ) |
|
960 { |
|
961 delete iDoubleClicktimer; |
|
962 iDoubleClicktimer = NULL; |
|
963 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver VoiceDial")); |
|
964 RProperty::Set( KPSUidHidEventNotifier, KHidHookKeyEvent, |
|
965 KPSVoiceDial ); |
|
966 iLongPress = EFalse; |
|
967 } |
|
968 TRACE_FUNC_EXIT |
|
969 } |
|
970 |
|
971 // --------------------------------------------------------------------------- |
|
972 // GetHookStatus() |
|
973 // --------------------------------------------------------------------------- |
|
974 // |
|
975 CHidHeadsetDriver::THookHandling CHidHeadsetDriver::HookStatus() |
|
976 { |
|
977 TRACE_FUNC_ENTRY |
|
978 THookHandling retVal = EOffHook; |
|
979 TInt ret = KErrNone; |
|
980 CTelephony::TCallStatusV1 callStatusV1; |
|
981 CTelephony::TCallStatusV1Pckg callStatusV1Pckg( callStatusV1 ); |
|
982 ret = iTelephony->GetLineStatus( CTelephony::EVoiceLine, |
|
983 callStatusV1Pckg ); |
|
984 if ( ret != KErrNone ) |
|
985 { |
|
986 retVal = ENoHook; |
|
987 } |
|
988 CTelephony::TCallStatus voiceLineStatus = callStatusV1.iStatus; |
|
989 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver GetHookStatus voiceline \ |
|
990 status %d"), voiceLineStatus)); |
|
991 |
|
992 if ( voiceLineStatus == CTelephony::EStatusHold || voiceLineStatus |
|
993 == CTelephony::EStatusRinging ) |
|
994 { |
|
995 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver GetHookStatus on hook")); |
|
996 retVal = EOnHook; |
|
997 } |
|
998 else if ( voiceLineStatus == CTelephony::EStatusUnknown |
|
999 || voiceLineStatus == CTelephony::EStatusIdle ) |
|
1000 { |
|
1001 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver GetHookStatus no hook")); |
|
1002 retVal = ENoHook; |
|
1003 } |
|
1004 TRACE_FUNC_EXIT |
|
1005 return retVal; |
|
1006 } |
|
1007 |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // From class CHidDriver |
|
1010 // CanHandleReportL() |
|
1011 // --------------------------------------------------------------------------- |
|
1012 // |
|
1013 TInt CHidHeadsetDriver::CanHandleReportL( CReportRoot* aReportRoot ) |
|
1014 { |
|
1015 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::CanHandleReport(0x%08x)"), |
|
1016 aReportRoot)); |
|
1017 |
|
1018 THidFieldSearch search; |
|
1019 |
|
1020 THeadsetFinder headsetFinder; |
|
1021 search.SearchL( aReportRoot, &headsetFinder ); |
|
1022 |
|
1023 iSupportedFieldCount = headsetFinder.FieldCount(); |
|
1024 for ( TInt i = 0; i < headsetFinder.FieldCount(); i++ ) |
|
1025 { |
|
1026 User::LeaveIfError( iFieldList.Append( headsetFinder.GetFieldAtIndex( |
|
1027 i ) ) ); |
|
1028 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::CanHandleReportL, field \ |
|
1029 pointer: 0x%08x"), iFieldList[i])); |
|
1030 } |
|
1031 |
|
1032 TInt valid = KErrHidUnrecognised; |
|
1033 |
|
1034 if ( headsetFinder.Found() ) |
|
1035 { |
|
1036 valid = KErrNone; |
|
1037 } |
|
1038 // empty finder's field list before going out of scope. |
|
1039 headsetFinder.EmptyList(); |
|
1040 |
|
1041 TRACE_INFO((_L("[HID]\tCHidHeadsetDriver::CanHandleReport() returning \ |
|
1042 %d"), valid)); |
|
1043 return valid; |
|
1044 } |
|
1045 |
|
1046 // --------------------------------------------------------------------------- |
|
1047 // From class CHidDriver |
|
1048 // SupportedFieldCount |
|
1049 // --------------------------------------------------------------------------- |
|
1050 // |
|
1051 TInt CHidHeadsetDriver::SupportedFieldCount() |
|
1052 { |
|
1053 return iSupportedFieldCount; |
|
1054 } |
|
1055 // --------------------------------------------------------------------------- |
|
1056 // From class MTimerNotifier |
|
1057 // TimerExpired() |
|
1058 // --------------------------------------------------------------------------- |
|
1059 // |
|
1060 void CHidHeadsetDriver::TimerExpired( TTimerType aTimerType ) |
|
1061 { |
|
1062 TRACE_FUNC_ENTRY |
|
1063 switch ( aTimerType ) |
|
1064 { |
|
1065 case EDoubleClickTimer: |
|
1066 ExpiredDoubleClickTimer(); |
|
1067 break; |
|
1068 case ELongPressTimer: |
|
1069 ExpiredLongClickTimer(); |
|
1070 break; |
|
1071 case EScanNextPressTimer: |
|
1072 iForwardStatus = EScanLongPress; |
|
1073 RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent, |
|
1074 EFastForwardPressed ); |
|
1075 break; |
|
1076 case EScanPrevPressTimer: |
|
1077 iBackwardStatus = EScanLongPress; |
|
1078 RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent, |
|
1079 ERewindPressed ); |
|
1080 break; |
|
1081 default: |
|
1082 TRACE_INFO(_L("CHidHeadsetDriver::TimerExpired : Not supported")) |
|
1083 ; |
|
1084 } |
|
1085 TRACE_FUNC_EXIT |
|
1086 } |
|
1087 |
|
1088 // --------------------------------------------------------------------------- |
|
1089 // ExpiredDoubleClickTimer() |
|
1090 // --------------------------------------------------------------------------- |
|
1091 // |
|
1092 void CHidHeadsetDriver::ExpiredDoubleClickTimer() |
|
1093 { |
|
1094 TRACE_FUNC_ENTRY |
|
1095 if ( iDoubleClicktimer ) |
|
1096 { |
|
1097 delete iDoubleClicktimer; |
|
1098 iDoubleClicktimer = NULL; |
|
1099 |
|
1100 if ( iIncomingCallStatus ) |
|
1101 { |
|
1102 iIncomingCallStatus = EFalse; |
|
1103 iOnHookPressed = ETrue; |
|
1104 ReleaseHookKey(); |
|
1105 } |
|
1106 if ( iAlarmStatus ) |
|
1107 { |
|
1108 RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, |
|
1109 EAlarmUIStopAlarm ); |
|
1110 iAlarmStatus = EFalse; |
|
1111 } |
|
1112 if ( iPlayingStatus ) |
|
1113 { |
|
1114 RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent, |
|
1115 EForwardClicked ); |
|
1116 iPlayingStatus = EFalse; |
|
1117 } |
|
1118 } |
|
1119 TRACE_FUNC_EXIT |
|
1120 } |
|
1121 |
|
1122 // --------------------------------------------------------------------------- |
|
1123 // ExpiredLongClickTimer() |
|
1124 // --------------------------------------------------------------------------- |
|
1125 // |
|
1126 void CHidHeadsetDriver::ExpiredLongClickTimer() |
|
1127 { |
|
1128 TRACE_FUNC_ENTRY |
|
1129 if ( iLongClicktimer ) |
|
1130 { |
|
1131 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::TimerExpired long click")); |
|
1132 delete iLongClicktimer; |
|
1133 iLongClicktimer = NULL; |
|
1134 iLongPress = ETrue; |
|
1135 ReleaseHookKey(); |
|
1136 } |
|
1137 TRACE_FUNC_EXIT |
|
1138 } |
|
1139 |
|
1140 // --------------------------------------------------------------------------- |
|
1141 // AlarmStatus() |
|
1142 // --------------------------------------------------------------------------- |
|
1143 // |
|
1144 TBool CHidHeadsetDriver::AlarmStatus() |
|
1145 { |
|
1146 TRACE_FUNC_ENTRY |
|
1147 TInt activealarmcount = 0; |
|
1148 TBool retVal = EFalse; |
|
1149 activealarmcount = iAlarmServerSession.AlarmCountByState( |
|
1150 EAlarmStateNotifying ); |
|
1151 if ( activealarmcount > 0 ) |
|
1152 { |
|
1153 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::AlarmStatus active alarms")); |
|
1154 retVal = ETrue; |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::AlarmStatus no active \ |
|
1159 alarms")); |
|
1160 retVal = EFalse; |
|
1161 } |
|
1162 TRACE_FUNC_EXIT |
|
1163 return retVal; |
|
1164 } |
|
1165 |
|
1166 // --------------------------------------------------------------------------- |
|
1167 // AlarmStatus() |
|
1168 // --------------------------------------------------------------------------- |
|
1169 // |
|
1170 TBool CHidHeadsetDriver::MusicPlayingStatus() |
|
1171 { |
|
1172 TRACE_FUNC_ENTRY |
|
1173 TBool retVal = EFalse; |
|
1174 TMPXPlaybackState state = EPbStateNotInitialised; |
|
1175 TRAPD( err, state = iMusicPlayer->StateL() ); |
|
1176 if ( state == EPbStatePlaying && err == KErrNone ) |
|
1177 { |
|
1178 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver::MusicPlayingStatus play \ |
|
1179 active")); |
|
1180 retVal = ETrue; |
|
1181 } |
|
1182 TRACE_FUNC_EXIT |
|
1183 return retVal; |
|
1184 } |
|
1185 |
|
1186 // --------------------------------------------------------------------------- |
|
1187 // HandlePlaybackMessage |
|
1188 // --------------------------------------------------------------------------- |
|
1189 // |
|
1190 void CHidHeadsetDriver::HandlePlaybackMessage( CMPXMessage* aMsg, TInt /*aErr*/) |
|
1191 { |
|
1192 TRACE_FUNC_ENTRY |
|
1193 |
|
1194 TMPXMessageId id( aMsg->ValueTObjectL<TMPXMessageId> ( |
|
1195 KMPXMessageGeneralId ) ); |
|
1196 // send nect track whit double hook click when track is changed |
|
1197 if ( id == KMPXMessagePbMediaChanged && iDoubleNextClick ) |
|
1198 { |
|
1199 TRACE_INFO(_L("[HID]\tHandlePlaybackMessage: PbMediaChangeg")); |
|
1200 RProperty::Set( KPSUidHidEventNotifier, KHidControlKeyEvent, |
|
1201 EForwardClicked ); |
|
1202 iDoubleNextClick = EFalse; |
|
1203 } |
|
1204 TRACE_FUNC_EXIT |
|
1205 } |
|
1206 |
|