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 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 5 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
6 | 6 |
7 #define XK_3270 // for XK_3270_BackTab | 7 #define XK_3270 // for XK_3270_BackTab |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/Xutil.h> | 10 #include <X11/Xutil.h> |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return VKEY_VOLUME_DOWN; | 358 return VKEY_VOLUME_DOWN; |
359 case XF86XK_AudioRaiseVolume: | 359 case XF86XK_AudioRaiseVolume: |
360 return VKEY_VOLUME_UP; | 360 return VKEY_VOLUME_UP; |
361 case XF86XK_MonBrightnessDown: | 361 case XF86XK_MonBrightnessDown: |
362 return VKEY_BRIGHTNESS_DOWN; | 362 return VKEY_BRIGHTNESS_DOWN; |
363 case XF86XK_MonBrightnessUp: | 363 case XF86XK_MonBrightnessUp: |
364 return VKEY_BRIGHTNESS_UP; | 364 return VKEY_BRIGHTNESS_UP; |
365 | 365 |
366 // TODO(sad): some keycodes are still missing. | 366 // TODO(sad): some keycodes are still missing. |
367 } | 367 } |
368 DLOG(WARNING) << "Unknown keysym: " << StringPrintf("0x%x", keysym); | 368 if (keysym) |
| 369 DLOG(WARNING) << "Unknown keysym: " << StringPrintf("0x%x", keysym); |
369 return VKEY_UNKNOWN; | 370 return VKEY_UNKNOWN; |
370 } | 371 } |
371 | 372 |
372 uint16 GetCharacterFromXEvent(XEvent* xev) { | 373 uint16 GetCharacterFromXEvent(XEvent* xev) { |
373 char buf[6]; | 374 char buf[6]; |
374 int bytes_written = XLookupString(&xev->xkey, buf, 6, NULL, NULL); | 375 int bytes_written = XLookupString(&xev->xkey, buf, 6, NULL, NULL); |
375 DCHECK_LE(bytes_written, 6); | 376 DCHECK_LE(bytes_written, 6); |
376 | 377 |
377 string16 result; | 378 string16 result; |
378 return (bytes_written > 0 && UTF8ToUTF16(buf, bytes_written, &result) && | 379 return (bytes_written > 0 && UTF8ToUTF16(buf, bytes_written, &result) && |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 case VKEY_BRIGHTNESS_UP: | 686 case VKEY_BRIGHTNESS_UP: |
686 return XF86XK_MonBrightnessUp; | 687 return XF86XK_MonBrightnessUp; |
687 | 688 |
688 default: | 689 default: |
689 LOG(WARNING) << "Unknown keycode:" << keycode; | 690 LOG(WARNING) << "Unknown keycode:" << keycode; |
690 return 0; | 691 return 0; |
691 } | 692 } |
692 } | 693 } |
693 | 694 |
694 } // namespace ui | 695 } // namespace ui |
OLD | NEW |