OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/events/ozone/evdev/key_event_converter_evdev.h" | 5 #include "ui/events/ozone/evdev/key_event_converter_evdev.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <linux/input.h> | 8 #include <linux/input.h> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 12 #include "ui/events/keycodes/dom4/keycode_converter.h" |
12 #include "ui/events/keycodes/keyboard_codes.h" | 13 #include "ui/events/keycodes/keyboard_codes.h" |
13 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 14 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
14 | 15 |
15 namespace ui { | 16 namespace ui { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
| 20 const int kXkbKeycodeOffset = 8; |
| 21 |
19 ui::KeyboardCode KeyboardCodeFromButton(unsigned int code) { | 22 ui::KeyboardCode KeyboardCodeFromButton(unsigned int code) { |
20 static const ui::KeyboardCode kLinuxBaseKeyMap[] = { | 23 static const ui::KeyboardCode kLinuxBaseKeyMap[] = { |
21 ui::VKEY_UNKNOWN, // KEY_RESERVED | 24 ui::VKEY_UNKNOWN, // KEY_RESERVED |
22 ui::VKEY_ESCAPE, // KEY_ESC | 25 ui::VKEY_ESCAPE, // KEY_ESC |
23 ui::VKEY_1, // KEY_1 | 26 ui::VKEY_1, // KEY_1 |
24 ui::VKEY_2, // KEY_2 | 27 ui::VKEY_2, // KEY_2 |
25 ui::VKEY_3, // KEY_3 | 28 ui::VKEY_3, // KEY_3 |
26 ui::VKEY_4, // KEY_4 | 29 ui::VKEY_4, // KEY_4 |
27 ui::VKEY_5, // KEY_5 | 30 ui::VKEY_5, // KEY_5 |
28 ui::VKEY_6, // KEY_6 | 31 ui::VKEY_6, // KEY_6 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Locking modifier keys: CapsLock. | 258 // Locking modifier keys: CapsLock. |
256 modifiers_->UpdateModifierLock(modifier, down); | 259 modifiers_->UpdateModifierLock(modifier, down); |
257 } else { | 260 } else { |
258 // Regular modifier keys: Shift, Ctrl, Alt, etc. | 261 // Regular modifier keys: Shift, Ctrl, Alt, etc. |
259 modifiers_->UpdateModifier(modifier, down); | 262 modifiers_->UpdateModifier(modifier, down); |
260 } | 263 } |
261 } | 264 } |
262 | 265 |
263 int flags = modifiers_->GetModifierFlags(); | 266 int flags = modifiers_->GetModifierFlags(); |
264 | 267 |
265 KeyEvent key_event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags); | 268 KeyEvent key_event( |
| 269 down ? ET_KEY_PRESSED : ET_KEY_RELEASED, |
| 270 code, |
| 271 KeycodeConverter::NativeKeycodeToCode(key + kXkbKeycodeOffset), |
| 272 flags); |
266 DispatchEventToCallback(&key_event); | 273 DispatchEventToCallback(&key_event); |
267 } | 274 } |
268 | 275 |
269 } // namespace ui | 276 } // namespace ui |
OLD | NEW |