|
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: This is the implementation of application class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "su8finnishswedish.h" |
|
20 #include "hiddebug.h" |
|
21 #include "hidlayoutids.h" |
|
22 |
|
23 // CONSTANTS |
|
24 |
|
25 // Look-up tables to translate HID keyboard usage codes (usage page 7) |
|
26 // to the corresponding Symbian "TKeyCode" (Unicode) values: |
|
27 |
|
28 const TInt CSu8FinnishSwedishLayout::KColumnMap[] = |
|
29 { |
|
30 THidModifier::EUnmodified, |
|
31 THidModifier::EShift, |
|
32 THidModifier::EAltCtrl |
|
33 }; |
|
34 |
|
35 const TUint16 CSu8FinnishSwedishLayout::KKeyCodes[] = |
|
36 { |
|
37 //---- ---S -AC- // Hex Dec |
|
38 0, 0, 0, // 0x00 0 |
|
39 0, 0, 0, // 0x01 1 |
|
40 0, 0, 0, // 0x02 2 |
|
41 0, 0, 0, // 0x03 3 |
|
42 'a', 'A', 0, // 0x04 4 |
|
43 'b', 'B', 0, // 0x05 5 |
|
44 'c', 'C', 0, // 0x06 6 |
|
45 'd', 'D', 0, // 0x07 7 |
|
46 'e', 'E', 0x20ac, // 0x08 8 |
|
47 'f', 'F', 0, // 0x09 9 |
|
48 'g', 'G', 0, // 0x0a 10 |
|
49 'h', 'H', 0, // 0x0b 11 |
|
50 'i', 'I', '[', // 0x0c 12 //was: } |
|
51 'j', 'J', 0, // 0x0d 13 |
|
52 'k', 'K', 0, // 0x0e 14 |
|
53 'l', 'L', 0, // 0x0f 15 |
|
54 'm', 'M', 0, // 0x10 16 |
|
55 'n', 'N', 0, // 0x11 17 |
|
56 'o', 'O', ']', // 0x12 18 was: [ |
|
57 'p', 'P', '}', // 0x13 19 was: ] |
|
58 'q', 'Q', 0x005e, // 0x14 20 |
|
59 'r', 'R', '$', // 0x15 21 |
|
60 's', 'S', 0, // 0x16 22 |
|
61 't', 'T', 0x00a3, // 0x17 23 |
|
62 'u', 'U', '{', // 0x18 24 |
|
63 'v', 'V', 0, // 0x19 25 |
|
64 'w', 'W', '@', // 0x1a 26 |
|
65 'x', 'X', 0, // 0x1b 27 |
|
66 'y', 'Y', 0, // 0x1c 28 |
|
67 'z', 'Z', 0, // 0x1d 29 |
|
68 '1', '!', 0x005e, // 0x1e 30 |
|
69 '2', '"', '@', // 0x1f 31 |
|
70 '3', '#', 0x20ac, // 0x20 32 |
|
71 '4', 0x00a4, '$', // 0x21 33 |
|
72 '5', '%', 0x00a3, // 0x22 34 |
|
73 '6', '&', 0, // 0x23 35 |
|
74 '7', '/', '{', // 0x24 36 |
|
75 '8', '(', '[', // 0x25 37 was: } |
|
76 '9', ')', ']', // 0x26 38 was: [ |
|
77 '0', '=', '}', // 0x27 39 was: ] |
|
78 0x000d, 0xf845, 0, // 0x28 40 |
|
79 0x001b, 0x001b, 0, // 0x29 41 |
|
80 0x0008, 0x0008, 0, // 0x2a 42 |
|
81 0x0009, 0x0009, 0, // 0x2b 43 |
|
82 ' ', ' ', 0, // 0x2c 44 |
|
83 '+', '?', 0, // 0x2d 45 |
|
84 0x00b4, 0x0060, '\\', // 0x2e 46 |
|
85 0x00e5, 0x00c5, 0, // 0x2f 47 |
|
86 0x00df, 0x00df, '\\', // 0x30 48 |
|
87 0x00e4, 0x00c4, 0, // 0x31 49 |
|
88 0, 0, 0, // 0x32 50 |
|
89 0x00f6, 0x00d6, 0, // 0x33 51 |
|
90 0x00e4, 0x00c4, 0, // 0x34 52 |
|
91 0x0027, 0x002a, 0x007e, // 0x35 53 |
|
92 ',', ';', '<', // 0x36 54 |
|
93 '.', ':', '>', // 0x37 55 |
|
94 '-', '_', 0x00a8 // 0x38 56 |
|
95 }; |
|
96 |
|
97 // ---------------------------------------------------------------------- |
|
98 // Keys 0x33 and 0x34 change for the Danish/Norwegian layout: |
|
99 |
|
100 const CStandardKeyboardLayout::TSpecialKey |
|
101 CSu8FinnishSwedishLayout::KDanishKeyCodes[] = |
|
102 { |
|
103 { 0x33, THidModifier::EUnmodified, 0x00f8 }, |
|
104 { 0x33, THidModifier::EShift, 0x00d8 }, |
|
105 { 0x34, THidModifier::EUnmodified, 0x00e6 }, |
|
106 { 0x34, THidModifier::EShift, 0x00c6 }, |
|
107 // |
|
108 { 0x00 } // end of table |
|
109 }; |
|
110 |
|
111 // ---------------------------------------------------------------------- |
|
112 // Other codes not included in the KKeyCodes table: |
|
113 |
|
114 const CStandardKeyboardLayout::TSpecialKey |
|
115 CSu8FinnishSwedishLayout::KSpecialCases[] = |
|
116 { |
|
117 // HID usage, modifiers, Unicode |
|
118 { 0x28, THidModifier::ECtrl, 0xf845 }, // Ctrl-enter (Return) |
|
119 { 0x2c, THidModifier::ECtrl, 0x0020 }, // Ctrl-spacebar |
|
120 { 0x2b, THidModifier::EAlt, 0xf852 }, // Alt-tab |
|
121 { 0x4c, THidModifier::EUnmodified, 0x007f }, // Delete |
|
122 { 0x4c, THidModifier::EShift, 0x007f }, // Shift-Delete |
|
123 { 0x4c, THidModifier::EAltCtrl, 0xf844 }, // Alt-ctrl-delete |
|
124 { 0x4f, THidModifier::EUnmodified, 0xf808 }, // Right arrow |
|
125 { 0x4f, THidModifier::EShift, 0xf808 }, // Shift-right arrow |
|
126 { 0x50, THidModifier::EUnmodified, 0xf807 }, // Left arrow |
|
127 { 0x50, THidModifier::EShift, 0xf807 }, // Shift-left arrow |
|
128 { 0x51, THidModifier::EUnmodified, 0xf80a }, // Down arrow |
|
129 { 0x51, THidModifier::EShift, 0xf80a }, // Shift-down arrow |
|
130 { 0x52, THidModifier::EUnmodified, 0xf809 }, // Up arrow |
|
131 { 0x52, THidModifier::EShift, 0xf809 }, // Shift-up arrow |
|
132 { 0xe3, THidModifier::EFunc, 0xf842 }, // Left GUI key |
|
133 { 0xe7, THidModifier::EFunc, 0xf843 }, // Right GUI key |
|
134 { 0xe3, THidModifier::EFuncShift, 0xf862 }, // Left GUI key |
|
135 { 0xe7, THidModifier::EFuncShift, 0xf863 }, // Right GUI key |
|
136 { 0x76, THidModifier::EUnmodified, 0xf852 }, // App switch to App0 |
|
137 { 0x76, THidModifier::EShift, 0xf852 }, // Shift-App switch to App0 |
|
138 { 0x77, THidModifier::EUnmodified, 0xf845 }, // MSK to OK |
|
139 { 0x77, THidModifier::EShift, 0xf845 }, // Shift-MSK to OK |
|
140 // |
|
141 { 0x00 } // end of table |
|
142 }; |
|
143 |
|
144 // ---------------------------------------------------------------------- |
|
145 |
|
146 // 0x00b4 (Acute accent) |
|
147 // |
|
148 const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyAcute[] = |
|
149 { |
|
150 { 0x0020, 0x00b4 }, // space |
|
151 { 0x0041, 0x00c1 }, // A |
|
152 { 0x0045, 0x00c9 }, // E |
|
153 { 0x0049, 0x00cd }, // I |
|
154 { 0x004f, 0x00d3 }, // O |
|
155 { 0x0055, 0x00da }, // U |
|
156 { 0x0059, 0x00dd }, // Y |
|
157 { 0x0061, 0x00e1 }, // a |
|
158 { 0x0065, 0x00e9 }, // e |
|
159 { 0x0069, 0x00ed }, // i |
|
160 { 0x006f, 0x00f3 }, // o |
|
161 { 0x0075, 0x00fa }, // u |
|
162 { 0x0079, 0x00fd }, // y |
|
163 { 0x0000 } // end of table |
|
164 }; |
|
165 |
|
166 // 0x0060 (Grave accent) |
|
167 // |
|
168 const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyGrave[] = |
|
169 { |
|
170 { 0x0020, 0x0060 }, // space |
|
171 { 0x0041, 0x00c0 }, // A |
|
172 { 0x0045, 0x00c8 }, // E |
|
173 { 0x0049, 0x00cc }, // I |
|
174 { 0x004f, 0x00d2 }, // O |
|
175 { 0x0055, 0x00d9 }, // U |
|
176 { 0x0061, 0x00e0 }, // a |
|
177 { 0x0065, 0x00e8 }, // e |
|
178 { 0x0069, 0x00ec }, // i |
|
179 { 0x006f, 0x00f2 }, // o |
|
180 { 0x0075, 0x00f9 }, // u |
|
181 { 0x0000 } // end of table |
|
182 }; |
|
183 |
|
184 // 0x00a8 (Diaeresis) |
|
185 // |
|
186 const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyDiaeresis[] = |
|
187 { |
|
188 { 0x0020, 0x00a8 }, // space |
|
189 { 0x0041, 0x00c4 }, // A |
|
190 { 0x0045, 0x00cb }, // E |
|
191 { 0x0049, 0x00cf }, // I |
|
192 { 0x004f, 0x00d6 }, // O |
|
193 { 0x0055, 0x00dc }, // U |
|
194 { 0x0061, 0x00e4 }, // a |
|
195 { 0x0065, 0x00eb }, // e |
|
196 { 0x0069, 0x00ef }, // i |
|
197 { 0x006f, 0x00f6 }, // o |
|
198 { 0x0075, 0x00fc }, // u |
|
199 { 0x0079, 0x00ff }, // y |
|
200 { 0x0000 } // end of table |
|
201 }; |
|
202 |
|
203 // 0x005e (Circumflex accent) |
|
204 // |
|
205 const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyCircumflex[] = |
|
206 { |
|
207 { 0x0020, 0x005e }, // space |
|
208 { 0x0041, 0x00c2 }, // A |
|
209 { 0x0045, 0x00ca }, // E |
|
210 { 0x0049, 0x00ce }, // I |
|
211 { 0x004f, 0x00d4 }, // O |
|
212 { 0x0055, 0x00db }, // U |
|
213 { 0x0061, 0x00e2 }, // a |
|
214 { 0x0065, 0x00ea }, // e |
|
215 { 0x0069, 0x00ee }, // i |
|
216 { 0x006f, 0x00f4 }, // o |
|
217 { 0x0075, 0x00fb }, // u |
|
218 { 0x0000 } // end of table |
|
219 }; |
|
220 |
|
221 // 0x007e (Tilde) |
|
222 // |
|
223 const CDeadKeyLayout::TKeyPair CSu8FinnishSwedishLayout::KDeadKeyTilde[] = |
|
224 { |
|
225 { 0x0020, 0x007e }, // space |
|
226 { 0x0041, 0x00c3 }, // A |
|
227 { 0x004e, 0x00d1 }, // N |
|
228 { 0x004f, 0x00d5 }, // O |
|
229 { 0x0061, 0x00e3 }, // a |
|
230 { 0x006e, 0x00f1 }, // n |
|
231 { 0x006f, 0x00f5 }, // o |
|
232 { 0x0000 } // end of table |
|
233 }; |
|
234 |
|
235 // ---------------------------------------------------------------------- |
|
236 |
|
237 const CDeadKeyLayout::TIndexPair CSu8FinnishSwedishLayout::KDeadKeyIndex[] = |
|
238 { |
|
239 { 0x00b4, KDeadKeyAcute }, |
|
240 { 0x0060, KDeadKeyGrave }, |
|
241 { 0x00a8, KDeadKeyDiaeresis }, |
|
242 { 0x005e, KDeadKeyCircumflex }, |
|
243 { 0x007e, KDeadKeyTilde }, |
|
244 { 0x0000 } // end of table |
|
245 }; |
|
246 |
|
247 // ---------------------------------------------------------------------- |
|
248 |
|
249 CSu8FinnishSwedishLayout::CSu8FinnishSwedishLayout() |
|
250 : CDeadKeyLayout(KColumnMap, sizeof (KColumnMap), |
|
251 KKeyCodes, sizeof (KKeyCodes), KSpecialCases, KDeadKeyIndex) |
|
252 { |
|
253 // nothing else to do |
|
254 } |
|
255 |
|
256 TBool CSu8FinnishSwedishLayout::ChangesWithCapsLock(TInt aHidKey, |
|
257 THidModifier aModifiers) const |
|
258 { |
|
259 if (aModifiers.None() || aModifiers.ShiftOnly()) |
|
260 { |
|
261 // Additional keys that should behave as if shift is pressed |
|
262 // whenever caps lock is active: |
|
263 // |
|
264 TBool isExtraCapsKey = |
|
265 (aHidKey == 0x2f) || |
|
266 (aHidKey == 0x31) || |
|
267 (aHidKey == 0x33) || |
|
268 (aHidKey == 0x34); |
|
269 |
|
270 if (isExtraCapsKey) |
|
271 return ETrue; |
|
272 } |
|
273 |
|
274 return CDeadKeyLayout::ChangesWithCapsLock(aHidKey, aModifiers); |
|
275 } |
|
276 |
|
277 TInt CSu8FinnishSwedishLayout::RawScanCode(TInt aHidKey, |
|
278 TInt aUsagePage, THidModifier aModifiers) const |
|
279 { |
|
280 TInt result = EStdKeyNull; |
|
281 |
|
282 const TInt KKeyboardUsagePage = 0x07; |
|
283 if (aUsagePage == KKeyboardUsagePage) |
|
284 { |
|
285 // Application switch key is HID "Keyboard Menu" usage: |
|
286 // |
|
287 const TInt KHidKeyboardMenu = 0x76; |
|
288 if (aHidKey == KHidKeyboardMenu) |
|
289 { |
|
290 result = EStdKeyApplication0; |
|
291 } |
|
292 |
|
293 // Middle soft key is HID "Keyboard Select" usage: |
|
294 // |
|
295 const TInt KHidKeyboardSelect = 0x77; |
|
296 if (aHidKey == KHidKeyboardSelect) |
|
297 { |
|
298 result = EStdKeyDevice3; |
|
299 } |
|
300 } |
|
301 |
|
302 if (result == EStdKeyNull) |
|
303 { |
|
304 result = CDeadKeyLayout::RawScanCode(aHidKey, |
|
305 aUsagePage, aModifiers); |
|
306 } |
|
307 |
|
308 return result; |
|
309 } |
|
310 |
|
311 TInt CSu8FinnishSwedishLayout::LayoutId() const |
|
312 { |
|
313 DBG(RDebug::Print(_L("[HID]\tCSu8FinnishSwedishLayout::LayoutId()"))); |
|
314 return ESu8FinnishSwedish; |
|
315 } |
|
316 |
|
317 CKeyboardLayout* CSu8FinnishSwedishLayout::NewL() |
|
318 { |
|
319 DBG(RDebug::Print(_L("[HID]\tCSu8FinnishSwedishLayout::NewL()"))); |
|
320 CKeyboardLayout* layout = new (ELeave) CSu8FinnishSwedishLayout; |
|
321 return layout; |
|
322 } |
|
323 |
|
324 // End of file |
|
325 |