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" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 base::Bind(&KeyboardEvdev::OnRepeatIntervalTimeout, | 149 base::Bind(&KeyboardEvdev::OnRepeatIntervalTimeout, |
150 base::Unretained(this))); | 150 base::Unretained(this))); |
151 } | 151 } |
152 | 152 |
153 void KeyboardEvdev::OnRepeatIntervalTimeout() { | 153 void KeyboardEvdev::OnRepeatIntervalTimeout() { |
154 DispatchKey(repeat_key_, true /* down */, true /* repeat */); | 154 DispatchKey(repeat_key_, true /* down */, true /* repeat */); |
155 } | 155 } |
156 | 156 |
157 void KeyboardEvdev::DispatchKey(unsigned int key, bool down, bool repeat) { | 157 void KeyboardEvdev::DispatchKey(unsigned int key, bool down, bool repeat) { |
158 DomCode dom_code = | 158 DomCode dom_code = |
159 KeycodeConverter::NativeKeycodeToDomCode(key + kXkbKeycodeOffset); | 159 KeycodeConverter::NativeKeycodeToDomCode(EvdevCodeToNativeCode(key)); |
160 // DomCode constants are not included here because of conflicts with | 160 // DomCode constants are not included here because of conflicts with |
161 // evdev preprocessor macros. | 161 // evdev preprocessor macros. |
162 if (!static_cast<int>(dom_code)) | 162 if (!static_cast<int>(dom_code)) |
163 return; | 163 return; |
164 int flags = modifiers_->GetModifierFlags(); | 164 int flags = modifiers_->GetModifierFlags(); |
165 DomKey dom_key; | 165 DomKey dom_key; |
166 KeyboardCode key_code; | 166 KeyboardCode key_code; |
167 uint16 character; | 167 uint16 character; |
168 uint32 platform_keycode = 0; | 168 uint32 platform_keycode = 0; |
169 if (!keyboard_layout_engine_->Lookup(dom_code, flags, &dom_key, &character, | 169 if (!keyboard_layout_engine_->Lookup(dom_code, flags, &dom_key, &character, |
(...skipping 12 matching lines...) Expand all Loading... |
182 } | 182 } |
183 | 183 |
184 // static | 184 // static |
185 int KeyboardEvdev::NativeCodeToEvdevCode(int native_code) { | 185 int KeyboardEvdev::NativeCodeToEvdevCode(int native_code) { |
186 if (native_code == KeycodeConverter::InvalidNativeKeycode()) { | 186 if (native_code == KeycodeConverter::InvalidNativeKeycode()) { |
187 return KEY_RESERVED; | 187 return KEY_RESERVED; |
188 } | 188 } |
189 return native_code - kXkbKeycodeOffset; | 189 return native_code - kXkbKeycodeOffset; |
190 } | 190 } |
191 | 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 |
192 } // namespace ui | 199 } // namespace ui |
OLD | NEW |