Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: trunk/src/ui/base/keycodes/usb_keycode_map.h

Issue 23451030: Revert 222168 "Add a CodeToNativeKeycode helper that converts UI..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Data in this file was created by referencing: 5 // Data in this file was created by referencing:
6 // USB HID Usage Tables (v1.11) 27 June 2001 6 // USB HID Usage Tables (v1.11) 27 June 2001
7 // HIToolbox/Events.h (Mac) 7 // HIToolbox/Events.h (Mac)
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { 392 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) {
393 if (usb_keycode_map[i].native_keycode == native_keycode) { 393 if (usb_keycode_map[i].native_keycode == native_keycode) {
394 if (usb_keycode_map[i].code != NULL) 394 if (usb_keycode_map[i].code != NULL)
395 return usb_keycode_map[i].code; 395 return usb_keycode_map[i].code;
396 break; 396 break;
397 } 397 }
398 } 398 }
399 return InvalidKeyboardEventCode(); 399 return InvalidKeyboardEventCode();
400 } 400 }
401 401
402 inline uint16_t CodeToNativeKeycode(const char* code) {
403 if (!code ||
404 strcmp(code, InvalidKeyboardEventCode()) == 0) {
405 return InvalidNativeKeycode();
406 }
407
408 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) {
409 if (usb_keycode_map[i].code &&
410 strcmp(usb_keycode_map[i].code, code) == 0) {
411 return usb_keycode_map[i].native_keycode;
412 }
413 }
414 return InvalidNativeKeycode();
415 }
416
417 // USB keycodes 402 // USB keycodes
418 // Note that USB keycodes are not part of any web standard. 403 // Note that USB keycodes are not part of any web standard.
419 // Please don't use USB keycodes in new code. 404 // Please don't use USB keycodes in new code.
420 405
421 inline uint16_t InvalidUsbKeycode() { 406 inline uint16_t InvalidUsbKeycode() {
422 return usb_keycode_map[0].usb_keycode; 407 return usb_keycode_map[0].usb_keycode;
423 } 408 }
424 409
425 inline uint16_t UsbKeycodeToNativeKeycode(uint32_t usb_keycode) { 410 inline uint16_t UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
426 // Deal with some special-cases that don't fit the 1:1 mapping. 411 // Deal with some special-cases that don't fit the 1:1 mapping.
(...skipping 19 matching lines...) Expand all
446 return InvalidUsbKeycode(); 431 return InvalidUsbKeycode();
447 } 432 }
448 433
449 inline const char* UsbKeycodeToCode(uint32_t usb_keycode) { 434 inline const char* UsbKeycodeToCode(uint32_t usb_keycode) {
450 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) { 435 for (size_t i = 0; i < arraysize(usb_keycode_map); ++i) {
451 if (usb_keycode_map[i].usb_keycode == usb_keycode) 436 if (usb_keycode_map[i].usb_keycode == usb_keycode)
452 return usb_keycode_map[i].code; 437 return usb_keycode_map[i].code;
453 } 438 }
454 return InvalidKeyboardEventCode(); 439 return InvalidKeyboardEventCode();
455 } 440 }
OLDNEW
« no previous file with comments | « trunk/src/remoting/test/remote_desktop_browsertest.cc ('k') | trunk/src/ui/base/keycodes/usb_keycode_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698