OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 5 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #import <Carbon/Carbon.h> | 9 #import <Carbon/Carbon.h> |
10 | 10 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 { VKEY_PLAY /* 0xFA */, -1, 0 }, | 196 { VKEY_PLAY /* 0xFA */, -1, 0 }, |
197 { VKEY_ZOOM /* 0xFB */, -1, 0 }, | 197 { VKEY_ZOOM /* 0xFB */, -1, 0 }, |
198 { VKEY_NONAME /* 0xFC */, -1, 0 }, | 198 { VKEY_NONAME /* 0xFC */, -1, 0 }, |
199 { VKEY_PA1 /* 0xFD */, -1, 0 }, | 199 { VKEY_PA1 /* 0xFD */, -1, 0 }, |
200 { VKEY_OEM_CLEAR /* 0xFE */, kVK_ANSI_KeypadClear, kClearCharCode } | 200 { VKEY_OEM_CLEAR /* 0xFE */, kVK_ANSI_KeypadClear, kClearCharCode } |
201 }; | 201 }; |
202 | 202 |
203 // A convenient array for getting symbol characters on the number keys. | 203 // A convenient array for getting symbol characters on the number keys. |
204 const char kShiftCharsForNumberKeys[] = ")!@#$%^&*("; | 204 const char kShiftCharsForNumberKeys[] = ")!@#$%^&*("; |
205 | 205 |
| 206 } // namespace |
| 207 |
206 // Translates from character code to keyboard code. | 208 // Translates from character code to keyboard code. |
207 KeyboardCode KeyboardCodeFromCharCode(unichar charCode) { | 209 KeyboardCode KeyboardCodeFromCharCode(unichar charCode) { |
208 switch (charCode) { | 210 switch (charCode) { |
209 case 8: case 0x7F: return VKEY_BACK; | 211 case 8: case 0x7F: return VKEY_BACK; |
210 case 9: return VKEY_TAB; | 212 case 9: return VKEY_TAB; |
211 case 0xD: case 3: return VKEY_RETURN; | 213 case 0xD: case 3: return VKEY_RETURN; |
212 case 0x1B: return VKEY_ESCAPE; | 214 case 0x1B: return VKEY_ESCAPE; |
213 case ' ': return VKEY_SPACE; | 215 case ' ': return VKEY_SPACE; |
214 case NSHomeFunctionKey: return VKEY_HOME; | 216 case NSHomeFunctionKey: return VKEY_HOME; |
215 case NSEndFunctionKey: return VKEY_END; | 217 case NSEndFunctionKey: return VKEY_END; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 case '`': case '~': return VKEY_OEM_3; | 306 case '`': case '~': return VKEY_OEM_3; |
305 case '[': case '{': return VKEY_OEM_4; | 307 case '[': case '{': return VKEY_OEM_4; |
306 case '\\': case '|': return VKEY_OEM_5; | 308 case '\\': case '|': return VKEY_OEM_5; |
307 case ']': case '}': return VKEY_OEM_6; | 309 case ']': case '}': return VKEY_OEM_6; |
308 case '\'': case '"': return VKEY_OEM_7; | 310 case '\'': case '"': return VKEY_OEM_7; |
309 } | 311 } |
310 | 312 |
311 return VKEY_UNKNOWN; | 313 return VKEY_UNKNOWN; |
312 } | 314 } |
313 | 315 |
| 316 namespace { |
| 317 |
314 KeyboardCode KeyboardCodeFromKeyCode(unsigned short keyCode) { | 318 KeyboardCode KeyboardCodeFromKeyCode(unsigned short keyCode) { |
315 static const KeyboardCode kKeyboardCodes[] = { | 319 static const KeyboardCode kKeyboardCodes[] = { |
316 /* 0 */ VKEY_A, | 320 /* 0 */ VKEY_A, |
317 /* 1 */ VKEY_S, | 321 /* 1 */ VKEY_S, |
318 /* 2 */ VKEY_D, | 322 /* 2 */ VKEY_D, |
319 /* 3 */ VKEY_F, | 323 /* 3 */ VKEY_F, |
320 /* 4 */ VKEY_H, | 324 /* 4 */ VKEY_H, |
321 /* 5 */ VKEY_G, | 325 /* 5 */ VKEY_G, |
322 /* 6 */ VKEY_Z, | 326 /* 6 */ VKEY_Z, |
323 /* 7 */ VKEY_X, | 327 /* 7 */ VKEY_X, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 return code; | 546 return code; |
543 } | 547 } |
544 return KeyboardCodeFromKeyCode([event keyCode]); | 548 return KeyboardCodeFromKeyCode([event keyCode]); |
545 } | 549 } |
546 | 550 |
547 DomCode CodeFromNSEvent(NSEvent* event) { | 551 DomCode CodeFromNSEvent(NSEvent* event) { |
548 return ui::KeycodeConverter::NativeKeycodeToDomCode([event keyCode]); | 552 return ui::KeycodeConverter::NativeKeycodeToDomCode([event keyCode]); |
549 } | 553 } |
550 | 554 |
551 } // namespace ui | 555 } // namespace ui |
OLD | NEW |