| 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/keyboard_evdev.h" | 5 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
| 6 | 6 |
| 7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
| 8 #include "ui/events/event_constants.h" | 8 #include "ui/events/event_constants.h" |
| 9 #include "ui/events/keycodes/dom4/keycode_converter.h" | 9 #include "ui/events/keycodes/dom4/keycode_converter.h" |
| 10 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 10 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
| 11 #include "ui/events/ozone/evdev/keyboard_util_evdev.h" |
| 11 #include "ui/events/ozone/layout/keyboard_layout_engine.h" | 12 #include "ui/events/ozone/layout/keyboard_layout_engine.h" |
| 12 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 13 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 13 #include "ui/events/ozone/layout/layout_util.h" | 14 #include "ui/events/ozone/layout/layout_util.h" |
| 14 | 15 |
| 15 namespace ui { | 16 namespace ui { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const int kXkbKeycodeOffset = 8; | |
| 20 | |
| 21 const int kRepeatDelayMs = 500; | 20 const int kRepeatDelayMs = 500; |
| 22 const int kRepeatIntervalMs = 50; | 21 const int kRepeatIntervalMs = 50; |
| 23 | 22 |
| 24 int EventFlagToEvdevModifier(int flag) { | 23 int EventFlagToEvdevModifier(int flag) { |
| 25 switch (flag) { | 24 switch (flag) { |
| 26 case EF_CAPS_LOCK_DOWN: | 25 case EF_CAPS_LOCK_DOWN: |
| 27 return EVDEV_MODIFIER_CAPS_LOCK; | 26 return EVDEV_MODIFIER_CAPS_LOCK; |
| 28 case EF_SHIFT_DOWN: | 27 case EF_SHIFT_DOWN: |
| 29 return EVDEV_MODIFIER_SHIFT; | 28 return EVDEV_MODIFIER_SHIFT; |
| 30 case EF_CONTROL_DOWN: | 29 case EF_CONTROL_DOWN: |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 UpdateModifier(ModifierDomKeyToEventFlag(dom_key), down); | 173 UpdateModifier(ModifierDomKeyToEventFlag(dom_key), down); |
| 175 | 174 |
| 176 KeyEvent* event = | 175 KeyEvent* event = |
| 177 new KeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code, dom_code, | 176 new KeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code, dom_code, |
| 178 modifiers_->GetModifierFlags(), dom_key, character); | 177 modifiers_->GetModifierFlags(), dom_key, character); |
| 179 if (platform_keycode) | 178 if (platform_keycode) |
| 180 event->set_platform_keycode(platform_keycode); | 179 event->set_platform_keycode(platform_keycode); |
| 181 callback_.Run(make_scoped_ptr(event)); | 180 callback_.Run(make_scoped_ptr(event)); |
| 182 } | 181 } |
| 183 | 182 |
| 184 // static | |
| 185 int KeyboardEvdev::NativeCodeToEvdevCode(int native_code) { | |
| 186 if (native_code == KeycodeConverter::InvalidNativeKeycode()) { | |
| 187 return KEY_RESERVED; | |
| 188 } | |
| 189 return native_code - kXkbKeycodeOffset; | |
| 190 } | |
| 191 | |
| 192 // static | |
| 193 int KeyboardEvdev::EvdevCodeToNativeCode(int evdev_code) { | |
| 194 if (evdev_code == KEY_RESERVED) | |
| 195 return KeycodeConverter::InvalidNativeKeycode(); | |
| 196 return evdev_code + kXkbKeycodeOffset; | |
| 197 } | |
| 198 | |
| 199 } // namespace ui | 183 } // namespace ui |
| OLD | NEW |