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" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 return EVDEV_MODIFIER_COMMAND; | 180 return EVDEV_MODIFIER_COMMAND; |
181 default: | 181 default: |
182 return EVDEV_MODIFIER_NONE; | 182 return EVDEV_MODIFIER_NONE; |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 bool IsLockButton(unsigned int code) { return code == KEY_CAPSLOCK; } | 186 bool IsLockButton(unsigned int code) { return code == KEY_CAPSLOCK; } |
187 | 187 |
188 } // namespace | 188 } // namespace |
189 | 189 |
190 KeyEventConverterEvdev::KeyEventConverterEvdev(int fd, | 190 KeyEventConverterEvdev::KeyEventConverterEvdev( |
191 base::FilePath path, | 191 int fd, |
192 EventModifiersEvdev* modifiers) | 192 base::FilePath path, |
193 : fd_(fd), path_(path), modifiers_(modifiers) { | 193 EventModifiersEvdev* modifiers, |
| 194 const EventDispatchCallback& callback) |
| 195 : EventConverterEvdev(callback), |
| 196 fd_(fd), |
| 197 path_(path), |
| 198 modifiers_(modifiers) { |
194 // TODO(spang): Initialize modifiers using EVIOCGKEY. | 199 // TODO(spang): Initialize modifiers using EVIOCGKEY. |
195 } | 200 } |
196 | 201 |
197 KeyEventConverterEvdev::~KeyEventConverterEvdev() { | 202 KeyEventConverterEvdev::~KeyEventConverterEvdev() { |
198 Stop(); | 203 Stop(); |
199 close(fd_); | 204 close(fd_); |
200 } | 205 } |
201 | 206 |
202 void KeyEventConverterEvdev::Start() { | 207 void KeyEventConverterEvdev::Start() { |
203 base::MessageLoopForUI::current()->WatchFileDescriptor( | 208 base::MessageLoopForUI::current()->WatchFileDescriptor( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 262 } |
258 | 263 |
259 int flags = modifiers_->GetModifierFlags(); | 264 int flags = modifiers_->GetModifierFlags(); |
260 | 265 |
261 KeyEvent key_event( | 266 KeyEvent key_event( |
262 down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true); | 267 down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true); |
263 DispatchEventToCallback(&key_event); | 268 DispatchEventToCallback(&key_event); |
264 } | 269 } |
265 | 270 |
266 } // namespace ui | 271 } // namespace ui |
OLD | NEW |