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 "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: Key capture controller |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __LOCKAPPKEYCAPTURECONTROLLER_H__ |
|
20 #define __LOCKAPPKEYCAPTURECONTROLLER_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <e32keys.h> |
|
25 |
|
26 // enumerated type for captured key events |
|
27 enum TPhoneKeyCaptureType |
|
28 { |
|
29 EKeyCaptureEvent, |
|
30 EKeyCaptureUpAndDownEvents, |
|
31 EKeyCaptureAllEvents |
|
32 }; |
|
33 |
|
34 // Key capture data structure |
|
35 class TPhoneKeyCapture |
|
36 { |
|
37 public: |
|
38 TStdScanCode iKey; // primary identifier |
|
39 TKeyCode iKeyCode; |
|
40 TPhoneKeyCaptureType iType; |
|
41 TInt32 iHandle; |
|
42 TInt32 iHandleForUpAndDown; |
|
43 }; |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 class RWindowGroup; |
|
47 |
|
48 /** |
|
49 * CLockAppKeyCaptureController class is a simple key capture utily that |
|
50 * provides a way to capture/release keys for the current window group. |
|
51 * |
|
52 * @lib lockapp |
|
53 * @since 5.0 |
|
54 * @author Joona Petrell |
|
55 * @author Tamas Koteles |
|
56 */ |
|
57 class CLockAppKeyCaptureController : public CBase |
|
58 { |
|
59 public: |
|
60 |
|
61 /** |
|
62 * Initialize the utility |
|
63 */ |
|
64 static CLockAppKeyCaptureController* InitL( RWindowGroup& aWindowGroup ); |
|
65 |
|
66 /** |
|
67 * Destroy the utility |
|
68 */ |
|
69 static void Destroy( ); |
|
70 |
|
71 /** |
|
72 * Set key to be captured |
|
73 */ |
|
74 static void CaptureKey( TUint32 aKey, TUint32 aKeyCode, TPhoneKeyCaptureType aType ); |
|
75 |
|
76 /** |
|
77 * Set key to be released |
|
78 */ |
|
79 static void ReleaseKey( TUint32 aKey ); |
|
80 |
|
81 private: |
|
82 |
|
83 /** |
|
84 * C++ default constructor. |
|
85 */ |
|
86 CLockAppKeyCaptureController( RWindowGroup& aWindowGroup ); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 virtual ~CLockAppKeyCaptureController( ); |
|
92 |
|
93 private: |
|
94 |
|
95 /** |
|
96 * Set key to be captured |
|
97 */ |
|
98 void StartCapturingKey( TUint32 aKey, TUint32 aKeyCode, TPhoneKeyCaptureType aType ); |
|
99 |
|
100 /** |
|
101 * Set key not to be captured |
|
102 */ |
|
103 void StopCapturingKey( TUint32 aKey ); |
|
104 |
|
105 /** |
|
106 * May be used to ask whether a key has been set to be captured or not |
|
107 * @param aKey is the iScanCode of the key |
|
108 * @return ETrue if the key is currently captured via this mechanism |
|
109 */ |
|
110 TBool IsKeyCaptured( TUint32 aKey ) const; |
|
111 |
|
112 /** |
|
113 * Set key not to be captured |
|
114 * @param aKeyCapture is the key not to be captured |
|
115 */ |
|
116 void StopKeyCapture( TPhoneKeyCapture aKeyCapture ); |
|
117 |
|
118 private: |
|
119 |
|
120 /** |
|
121 * Private instance of the utility |
|
122 */ |
|
123 static CLockAppKeyCaptureController* instance; |
|
124 |
|
125 /** |
|
126 * Array of keycodes currently captured which includes the window |
|
127 * server handles for the captured keys. |
|
128 */ |
|
129 RArray<TPhoneKeyCapture> iCapturedKeys; |
|
130 |
|
131 /** |
|
132 * application's window group |
|
133 */ |
|
134 RWindowGroup& iWindowGroup; |
|
135 |
|
136 }; |
|
137 |
|
138 #endif // LOCKAPPKEYCAPTURECONTROLLER_H |
|
139 |
|
140 // End of File |
|