|
1 /* |
|
2 * Copyright (c) 2008 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: Declares main application class. |
|
15 * |
|
16 */ |
|
17 |
|
18 /*! |
|
19 \file |
|
20 Keyboard layout manager interface, public header. |
|
21 */ |
|
22 #ifndef __LAYOUTMGR_H |
|
23 #define __LAYOUTMGR_H |
|
24 #include <e32std.h> |
|
25 #include <e32svr.h> |
|
26 #include "genericclient.h" |
|
27 #include "hidlayoutids.h" |
|
28 // CONSTANTS |
|
29 /*! |
|
30 Layout server sessions are created indirectly using this server name. |
|
31 */ |
|
32 _LIT(KLayoutServerName,"LayoutServer"); |
|
33 /*! |
|
34 Name of the semaphore used to confirm server startup. Semaphores |
|
35 are globally accessible kernel objects and are referenced by name. |
|
36 */ |
|
37 _LIT(KLayoutServerSemaphoreName, "LayoutServerSemaphore"); |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class TDecodedKeyInfo; |
|
41 class TLockKeys; |
|
42 class TTranslatedKey; |
|
43 |
|
44 /*! |
|
45 Handle class representing a session with the keyboard layout |
|
46 manager server. |
|
47 */ |
|
48 |
|
49 // CLASS DECLARATION |
|
50 |
|
51 class RLayoutManager : public RGenericSession |
|
52 { |
|
53 public: |
|
54 IMPORT_C RLayoutManager(); |
|
55 |
|
56 /*! |
|
57 Connect to the keyboard layout manager server and create a new session. |
|
58 |
|
59 @result KErrNone if successful; otherwise another of the standard |
|
60 Symbian system-wide error codes. |
|
61 */ |
|
62 IMPORT_C TInt Connect(); |
|
63 |
|
64 // ------------------------------------------ |
|
65 // API intended for use by keyboard driver: |
|
66 // ------------------------------------------ |
|
67 |
|
68 /*! |
|
69 Notify the layout server of a key-down or key-up event. Every |
|
70 key down event must be followed by a corresponding key up event; |
|
71 the two events do not have to be consecutive. |
|
72 |
|
73 @param aIsKeyDown ETrue for a key down event, EFalse for a key up event. |
|
74 @param aHidKey HID usage ID for the key causing this event |
|
75 @param aUsagePage HID usage page for the key causing this event |
|
76 @param aModifiers Current modifier state |
|
77 @param aLockKeys Current lock key state |
|
78 @param aDecodedKeys The results of the key decoding |
|
79 |
|
80 @result KErrNone if successful; otherwise another of the standard |
|
81 Symbian system-wide error codes. |
|
82 */ |
|
83 |
|
84 IMPORT_C TInt KeyEvent(TBool aIsKeyDown, TInt aHidKey, TInt aUsagePage, |
|
85 TInt aModifiers, const TLockKeys& aLockKeys, |
|
86 TDecodedKeyInfo& aDecodedKeys) const; |
|
87 |
|
88 /*! Convenience function, equivalent to #KeyEvent(ETrue, ...) */ |
|
89 inline TInt KeyDownEvent(TInt aHidKey, TInt aUsagePage, TInt aModifiers, |
|
90 const TLockKeys& aLockKeys, TDecodedKeyInfo& aDecodedKeys) const; |
|
91 |
|
92 /*! Convenience function, equivalent to #KeyEvent(EFalse, ...) */ |
|
93 inline TInt KeyUpEvent(TInt aHidKey, TInt aUsagePage, TInt aModifiers, |
|
94 const TLockKeys& aLockKeys, TDecodedKeyInfo& aDecodedKeys) const; |
|
95 |
|
96 /*! |
|
97 Reset the state of keyboard layout decoder object associated |
|
98 with this session. |
|
99 |
|
100 @result KErrNone if successful; otherwise another of the standard |
|
101 Symbian system-wide error codes. |
|
102 */ |
|
103 IMPORT_C TInt Reset() const; |
|
104 |
|
105 /*! |
|
106 %SetInitialLayout() causes the layout manager to select the most |
|
107 appropriate keyboard layout given the country, vendor and |
|
108 product parameters read from a keyboard device. The server will |
|
109 choose the layout DLL (<b>reword here</b>) in the following |
|
110 order: |
|
111 |
|
112 -# By keyboard vendor and product code |
|
113 -# By keyboard country code |
|
114 -# By current phone language setting |
|
115 |
|
116 If no appropriate layout can be found, the server will attempt |
|
117 to load the default US layout (EUnitedStates). |
|
118 |
|
119 As the layout server only maintains a single keyboard layout, |
|
120 this setting will affect all other RLayoutManager sessions. |
|
121 |
|
122 @param aCountry HID country ID code for the keyboard device |
|
123 (refer to bCountryCode in "Device Class Definition for Human |
|
124 Interface Devices", USB Implementers' Forum, Version 1.11, |
|
125 2001, Section 6.2.1, "HID descriptor".) |
|
126 |
|
127 @param aVendor HID manufacturer ID code for the keyboard device, |
|
128 as supplied by the USB Implementers' Forum, http://www.usb.org/. |
|
129 |
|
130 @param aProduct Vendor specific product code for the keyboard |
|
131 device. |
|
132 |
|
133 @result KErrNone if successful; otherwise another of the standard |
|
134 Symbian system-wide error codes. |
|
135 */ |
|
136 IMPORT_C TInt |
|
137 SetInitialLayout(TInt aCountry, TInt aVendor, TInt aProduct) const; |
|
138 |
|
139 /*! |
|
140 As SetInitialLayout() but will Leave() if there is an error. |
|
141 */ |
|
142 inline void |
|
143 SetInitialLayoutL(TInt aCountry, TInt aVendor, TInt aProduct) const; |
|
144 |
|
145 // ------------------------------------------ |
|
146 // API intended for use by applications: |
|
147 // ------------------------------------------ |
|
148 |
|
149 /*! |
|
150 Query the current HID system keyboard layout |
|
151 |
|
152 @param aLayoutId Keyboard layout ID code |
|
153 |
|
154 @result KErrNone if successful; otherwise another of the standard |
|
155 Symbian system-wide error codes. |
|
156 */ |
|
157 IMPORT_C TInt GetLayout(TInt& aLayoutId) const; |
|
158 |
|
159 /*! |
|
160 As GetLayout() but will Leave() if there is an error. |
|
161 |
|
162 @result Keyboard layout ID code |
|
163 */ |
|
164 inline TInt GetLayoutL() const; |
|
165 |
|
166 /*! |
|
167 Query the initial layout chosen for the current keyboard. |
|
168 This is the result of the last call to SetInitialLayoutL(). |
|
169 |
|
170 @param aLayoutId Keyboard layout ID code |
|
171 |
|
172 @result KErrNone if successful; otherwise another of the standard |
|
173 Symbian system-wide error codes. |
|
174 */ |
|
175 IMPORT_C TInt GetInitialLayout(TInt& aLayoutId) const; |
|
176 |
|
177 /*! |
|
178 As GetInitialLayout() but will Leave() if there is an error. |
|
179 |
|
180 @result Keyboard layout ID code |
|
181 */ |
|
182 inline TInt GetInitialLayoutL() const; |
|
183 |
|
184 /*! |
|
185 Set the HID system keyboard layout by ID. If the server can't |
|
186 find a keyboard layout DLL containing the given layout ID, then |
|
187 the layout will remain unchanged. |
|
188 |
|
189 @param aLayoutId Keyboard layout ID code |
|
190 |
|
191 @result KErrNone if successful; otherwise another of the standard |
|
192 Symbian system-wide error codes. |
|
193 */ |
|
194 IMPORT_C TInt SetLayout(TInt aLayoutId) const; |
|
195 |
|
196 /*! |
|
197 As SetLayout() but will Leave() if there is an error. |
|
198 */ |
|
199 inline void SetLayoutL(TInt aLayoutId) const; |
|
200 |
|
201 /*! |
|
202 Return information about the attached keyboard |
|
203 |
|
204 @param aIsNokiaSu8 ETrue if the keyboard is a Nokia SU-8 |
|
205 |
|
206 @param aFoundLayout ETrue if the keyboard returned a valid |
|
207 country code and a matching keyboard layout ID exists. |
|
208 |
|
209 @result KErrNone if successful; otherwise another of the standard |
|
210 Symbian system-wide error codes. |
|
211 */ |
|
212 IMPORT_C TInt GetDeviceInfo(TBool& aIsNokiaSu8, TBool& aFoundLayout) const; |
|
213 }; |
|
214 |
|
215 // ---------------------------------------------------------------------- |
|
216 |
|
217 inline TInt RLayoutManager::KeyDownEvent(TInt aHidKey, TInt aUsagePage, |
|
218 TInt aModifiers, const TLockKeys& aLockKeys, |
|
219 TDecodedKeyInfo& aDecodedKeys) const |
|
220 { |
|
221 return KeyEvent(ETrue, aHidKey, aUsagePage, aModifiers, aLockKeys, |
|
222 aDecodedKeys); |
|
223 } |
|
224 |
|
225 inline TInt RLayoutManager::KeyUpEvent(TInt aHidKey, TInt aUsagePage, |
|
226 TInt aModifiers, const TLockKeys& aLockKeys, |
|
227 TDecodedKeyInfo& aDecodedKeys) const |
|
228 { |
|
229 return KeyEvent(EFalse, aHidKey, aUsagePage, aModifiers, aLockKeys, |
|
230 aDecodedKeys); |
|
231 } |
|
232 |
|
233 // ---------------------------------------------------------------------- |
|
234 |
|
235 inline void RLayoutManager::SetInitialLayoutL(TInt aCountry, TInt aVendor, |
|
236 TInt aProduct) const |
|
237 { |
|
238 User::LeaveIfError(SetInitialLayout(aCountry, aVendor, aProduct)); |
|
239 } |
|
240 |
|
241 inline void RLayoutManager::SetLayoutL(TInt aLayoutId) const |
|
242 { |
|
243 User::LeaveIfError(SetLayout(aLayoutId)); |
|
244 } |
|
245 |
|
246 inline TInt RLayoutManager::GetLayoutL() const |
|
247 { |
|
248 TInt layout; |
|
249 User::LeaveIfError(GetLayout(layout)); |
|
250 return layout; |
|
251 } |
|
252 |
|
253 inline TInt RLayoutManager::GetInitialLayoutL() const |
|
254 { |
|
255 TInt layout; |
|
256 User::LeaveIfError(GetInitialLayout(layout)); |
|
257 return layout; |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------- |
|
261 |
|
262 #endif |