| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 210 ssize_t read_size = read(fd, inputs, sizeof(inputs)); |
| 211 if (read_size < 0) { | 211 if (read_size < 0) { |
| 212 if (errno == EINTR || errno == EAGAIN) | 212 if (errno == EINTR || errno == EAGAIN) |
| 213 return; | 213 return; |
| 214 if (errno != ENODEV) | 214 if (errno != ENODEV) |
| 215 PLOG(ERROR) << "error reading device " << path_.value(); | 215 PLOG(ERROR) << "error reading device " << path_.value(); |
| 216 Stop(); | 216 Stop(); |
| 217 return; | 217 return; |
| 218 } | 218 } |
| 219 | 219 |
| 220 CHECK_EQ(read_size % sizeof(*inputs), 0u); | 220 DCHECK_EQ(read_size % sizeof(*inputs), 0u); |
| 221 ProcessEvents(inputs, read_size / sizeof(*inputs)); | 221 ProcessEvents(inputs, read_size / sizeof(*inputs)); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs, | 224 void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs, |
| 225 int count) { | 225 int count) { |
| 226 for (int i = 0; i < count; ++i) { | 226 for (int i = 0; i < count; ++i) { |
| 227 const input_event& input = inputs[i]; | 227 const input_event& input = inputs[i]; |
| 228 if (input.type == EV_KEY) { | 228 if (input.type == EV_KEY) { |
| 229 ConvertKeyEvent(input.code, input.value); | 229 ConvertKeyEvent(input.code, input.value); |
| 230 } else if (input.type == EV_SYN) { | 230 } else if (input.type == EV_SYN) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 253 | 253 |
| 254 KeyEvent key_event( | 254 KeyEvent key_event( |
| 255 down ? ET_KEY_PRESSED : ET_KEY_RELEASED, | 255 down ? ET_KEY_PRESSED : ET_KEY_RELEASED, |
| 256 code, | 256 code, |
| 257 KeycodeConverter::NativeKeycodeToCode(key + kXkbKeycodeOffset), | 257 KeycodeConverter::NativeKeycodeToCode(key + kXkbKeycodeOffset), |
| 258 flags); | 258 flags); |
| 259 callback_.Run(&key_event); | 259 callback_.Run(&key_event); |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace ui | 262 } // namespace ui |
| OLD | NEW |