| 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_pump_ozone.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/keyboard_codes.h" | 12 #include "ui/events/keycodes/keyboard_codes.h" |
| 13 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 13 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
| 14 #include "ui/events/ozone/event_factory_ozone.h" | 14 #include "ui/events/ozone/event_factory_ozone.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 ui::KeyboardCode KeyboardCodeFromButton(unsigned int code) { | 20 ui::KeyboardCode KeyboardCodeFromButton(unsigned int code) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 : fd_(fd), path_(path), modifiers_(modifiers) { | 193 : fd_(fd), path_(path), modifiers_(modifiers) { |
| 194 // TODO(spang): Initialize modifiers using EVIOCGKEY. | 194 // TODO(spang): Initialize modifiers using EVIOCGKEY. |
| 195 } | 195 } |
| 196 | 196 |
| 197 KeyEventConverterEvdev::~KeyEventConverterEvdev() { | 197 KeyEventConverterEvdev::~KeyEventConverterEvdev() { |
| 198 Stop(); | 198 Stop(); |
| 199 close(fd_); | 199 close(fd_); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void KeyEventConverterEvdev::Start() { | 202 void KeyEventConverterEvdev::Start() { |
| 203 base::MessagePumpOzone::Current()->WatchFileDescriptor( | 203 base::MessageLoopForUI::current()->WatchFileDescriptor( |
| 204 fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this); | 204 fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void KeyEventConverterEvdev::Stop() { | 207 void KeyEventConverterEvdev::Stop() { |
| 208 controller_.StopWatchingFileDescriptor(); | 208 controller_.StopWatchingFileDescriptor(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 211 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { |
| 212 input_event inputs[4]; | 212 input_event inputs[4]; |
| 213 ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 213 ssize_t read_size = read(fd, inputs, sizeof(inputs)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 int flags = modifiers_->GetModifierFlags(); | 259 int flags = modifiers_->GetModifierFlags(); |
| 260 | 260 |
| 261 KeyEvent key_event( | 261 KeyEvent key_event( |
| 262 down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true); | 262 down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true); |
| 263 DispatchEventToCallback(&key_event); | 263 DispatchEventToCallback(&key_event); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace ui | 266 } // namespace ui |
| OLD | NEW |