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". |
54 #include "debug.h" |
54 #include "debug.h" |
55 |
55 |
56 const TInt KHidUndefinedKeyCode = 0; |
56 const TInt KHidUndefinedKeyCode = 0; |
57 const TInt KHidNotSetKeyValue = 0; |
57 const TInt KHidNotSetKeyValue = 0; |
58 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds |
58 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds |
|
59 const TInt KDoubleClickTimeoutRing = 500000; // 0,5 seconds |
59 const TInt KScanClickTimeout = 500000; // 0,5 seconds |
60 const TInt KScanClickTimeout = 500000; // 0,5 seconds |
60 const TInt KLongClickTimeout = 3000000; // 3 seconds |
61 const TInt KLongClickTimeout = 3000000; // 3 seconds |
61 |
62 |
62 // ======== MEMBER FUNCTIONS ======== |
63 // ======== MEMBER FUNCTIONS ======== |
63 |
64 |
748 if ( aStatus ) |
749 if ( aStatus ) |
749 { |
750 { |
750 switch ( hookStatus ) |
751 switch ( hookStatus ) |
751 { |
752 { |
752 case EOnHook: |
753 case EOnHook: |
753 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook On Pressed")); |
754 if ( !iIncomingCallStatus ) |
754 iOnHookPressed = ETrue; |
755 { |
755 break; |
756 // For the first click, trigger the timer |
|
757 // single click is handled in ExpiredDoubleClickTimer |
|
758 if ( iDoubleClicktimer ) |
|
759 { |
|
760 delete iDoubleClicktimer; |
|
761 iDoubleClicktimer = NULL; |
|
762 } |
|
763 TRAP_IGNORE( iDoubleClicktimer = CKeyPressTimer::NewL( this, |
|
764 TTimeIntervalMicroSeconds32( KDoubleClickTimeoutRing ), |
|
765 EDoubleClickTimer ) ); |
|
766 if ( iDoubleClicktimer ) |
|
767 { |
|
768 iIncomingCallStatus = ETrue; |
|
769 } |
|
770 else // If fail to create timer, handle as single click, |
|
771 // for double click case, the next click will hang off |
|
772 { |
|
773 iIncomingCallStatus = EFalse; |
|
774 iOnHookPressed = ETrue; |
|
775 } |
|
776 break; // switch |
|
777 } |
|
778 else |
|
779 { |
|
780 iIncomingCallStatus = EFalse; |
|
781 if ( iDoubleClicktimer ) |
|
782 { |
|
783 delete iDoubleClicktimer; |
|
784 iDoubleClicktimer = NULL; |
|
785 } |
|
786 // This is the double click case, handle as EOffHook |
|
787 } |
|
788 // No break here |
756 case EOffHook: |
789 case EOffHook: |
757 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed")); |
790 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed")); |
758 iOffHookPressed = ETrue; |
791 iOffHookPressed = ETrue; |
759 break; |
792 break; |
760 case ENoHook: |
793 case ENoHook: |
761 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); |
794 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); |
762 TRAP_IGNORE( HandleNoneHookPressL() ); |
795 TRAP_IGNORE( HandleNoneHookPressL() ); |
763 break; |
796 break; |
764 default: |
797 default: |
765 TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \ |
798 TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \ |
766 supported")); |
799 supported")); |
1044 { |
1077 { |
1045 TRACE_FUNC_ENTRY |
1078 TRACE_FUNC_ENTRY |
1046 switch ( aTimerType ) |
1079 switch ( aTimerType ) |
1047 { |
1080 { |
1048 case EDoubleClickTimer: |
1081 case EDoubleClickTimer: |
1049 ExpiredDubleClickTimer(); |
1082 ExpiredDoubleClickTimer(); |
1050 break; |
1083 break; |
1051 case ELongPressTimer: |
1084 case ELongPressTimer: |
1052 ExpiredLongClickTimer(); |
1085 ExpiredLongClickTimer(); |
1053 break; |
1086 break; |
1054 case EScanNextPressTimer: |
1087 case EScanNextPressTimer: |
1067 } |
1100 } |
1068 TRACE_FUNC_EXIT |
1101 TRACE_FUNC_EXIT |
1069 } |
1102 } |
1070 |
1103 |
1071 // --------------------------------------------------------------------------- |
1104 // --------------------------------------------------------------------------- |
1072 // ExpiredDubleClickTimer() |
1105 // ExpiredDoubleClickTimer() |
1073 // --------------------------------------------------------------------------- |
1106 // --------------------------------------------------------------------------- |
1074 // |
1107 // |
1075 void CHidHeadsetDriver::ExpiredDubleClickTimer() |
1108 void CHidHeadsetDriver::ExpiredDoubleClickTimer() |
1076 { |
1109 { |
1077 TRACE_FUNC_ENTRY |
1110 TRACE_FUNC_ENTRY |
1078 if ( iDoubleClicktimer ) |
1111 if ( iDoubleClicktimer ) |
1079 { |
1112 { |
1080 delete iDoubleClicktimer; |
1113 delete iDoubleClicktimer; |
1081 iDoubleClicktimer = NULL; |
1114 iDoubleClicktimer = NULL; |
|
1115 |
|
1116 if ( iIncomingCallStatus ) |
|
1117 { |
|
1118 iIncomingCallStatus = EFalse; |
|
1119 iOnHookPressed = ETrue; |
|
1120 ReleaseHookKey(); |
|
1121 } |
1082 if ( iAlarmStatus ) |
1122 if ( iAlarmStatus ) |
1083 { |
1123 { |
1084 RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, |
1124 RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey, |
1085 EAlarmUIStopAlarm ); |
1125 EAlarmUIStopAlarm ); |
1086 iAlarmStatus = EFalse; |
1126 iAlarmStatus = EFalse; |