1 /* |
1 /* |
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
38 #include "debug.h" |
38 #include "debug.h" |
39 |
39 |
40 const TInt KHidUndefinedKeyCode = 0; |
40 const TInt KHidUndefinedKeyCode = 0; |
41 const TInt KHidNotSetKeyValue = 0; |
41 const TInt KHidNotSetKeyValue = 0; |
42 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds |
42 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds |
|
43 const TInt KDoubleClickTimeoutRing = 500000; // 0,5 seconds |
43 const TInt KScanClickTimeout = 500000; // 0,5 seconds |
44 const TInt KScanClickTimeout = 500000; // 0,5 seconds |
44 const TInt KLongClickTimeout = 3000000; // 3 seconds |
45 const TInt KLongClickTimeout = 3000000; // 3 seconds |
45 |
46 |
46 // ======== MEMBER FUNCTIONS ======== |
47 // ======== MEMBER FUNCTIONS ======== |
47 |
48 |
732 if ( aStatus ) |
733 if ( aStatus ) |
733 { |
734 { |
734 switch ( hookStatus ) |
735 switch ( hookStatus ) |
735 { |
736 { |
736 case EOnHook: |
737 case EOnHook: |
737 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook On Pressed")); |
738 if ( !iIncomingCallStatus ) |
738 iOnHookPressed = ETrue; |
739 { |
739 break; |
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 |
740 case EOffHook: |
773 case EOffHook: |
741 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed")); |
774 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed")); |
742 iOffHookPressed = ETrue; |
775 iOffHookPressed = ETrue; |
743 break; |
776 break; |
744 case ENoHook: |
777 case ENoHook: |
745 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); |
778 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); |
746 TRAP_IGNORE( HandleNoneHookPressL() ); |
779 TRAP_IGNORE( HandleNoneHookPressL() ); |
747 break; |
780 break; |
748 default: |
781 default: |
749 TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \ |
782 TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \ |
750 supported")); |
783 supported")); |
1028 { |
1061 { |
1029 TRACE_FUNC_ENTRY |
1062 TRACE_FUNC_ENTRY |
1030 switch ( aTimerType ) |
1063 switch ( aTimerType ) |
1031 { |
1064 { |
1032 case EDoubleClickTimer: |
1065 case EDoubleClickTimer: |
1033 ExpiredDubleClickTimer(); |
1066 ExpiredDoubleClickTimer(); |
1034 break; |
1067 break; |
1035 case ELongPressTimer: |
1068 case ELongPressTimer: |
1036 ExpiredLongClickTimer(); |
1069 ExpiredLongClickTimer(); |
1037 break; |
1070 break; |
1038 case EScanNextPressTimer: |
1071 case EScanNextPressTimer: |
1051 } |
1084 } |
1052 TRACE_FUNC_EXIT |
1085 TRACE_FUNC_EXIT |
1053 } |
1086 } |
1054 |
1087 |
1055 // --------------------------------------------------------------------------- |
1088 // --------------------------------------------------------------------------- |
1056 // ExpiredDubleClickTimer() |
1089 // ExpiredDoubleClickTimer() |
1057 // --------------------------------------------------------------------------- |
1090 // --------------------------------------------------------------------------- |
1058 // |
1091 // |
1059 void CHidHeadsetDriver::ExpiredDubleClickTimer() |
1092 void CHidHeadsetDriver::ExpiredDoubleClickTimer() |
1060 { |
1093 { |
1061 TRACE_FUNC_ENTRY |
1094 TRACE_FUNC_ENTRY |
1062 if ( iDoubleClicktimer ) |
1095 if ( iDoubleClicktimer ) |
1063 { |
1096 { |
1064 delete iDoubleClicktimer; |
1097 delete iDoubleClicktimer; |
1065 iDoubleClicktimer = NULL; |
1098 iDoubleClicktimer = NULL; |
|
1099 |
|
1100 if ( iIncomingCallStatus ) |
|
1101 { |
|
1102 iIncomingCallStatus = EFalse; |
|
1103 iOnHookPressed = ETrue; |
|
1104 ReleaseHookKey(); |
|
1105 } |
1066 if ( iAlarmStatus ) |
1106 if ( iAlarmStatus ) |
1067 { |
1107 { |
1068 RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, |
1108 RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, |
1069 EAlarmUIStopAlarm ); |
1109 EAlarmUIStopAlarm ); |
1070 iAlarmStatus = EFalse; |
1110 iAlarmStatus = EFalse; |