| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.h" | 5 #include "ui/events/ozone/evdev/key_event_converter.h" | 
| 6 | 6 | 
|  | 7 #include <errno.h> | 
| 7 #include <linux/input.h> | 8 #include <linux/input.h> | 
| 8 | 9 | 
| 9 #include "base/message_loop/message_pump_ozone.h" | 10 #include "base/message_loop/message_pump_ozone.h" | 
| 10 #include "ui/events/event.h" | 11 #include "ui/events/event.h" | 
| 11 #include "ui/events/keycodes/keyboard_codes.h" | 12 #include "ui/events/keycodes/keyboard_codes.h" | 
| 12 #include "ui/events/ozone/evdev/event_modifiers.h" | 13 #include "ui/events/ozone/evdev/event_modifiers.h" | 
| 13 | 14 | 
| 14 namespace ui { | 15 namespace ui { | 
| 15 | 16 | 
| 16 namespace { | 17 namespace { | 
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 203       fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this); | 204       fd_, true, base::MessagePumpLibevent::WATCH_READ, &controller_, this); | 
| 204 } | 205 } | 
| 205 | 206 | 
| 206 void KeyEventConverterEvdev::Stop() { | 207 void KeyEventConverterEvdev::Stop() { | 
| 207   controller_.StopWatchingFileDescriptor(); | 208   controller_.StopWatchingFileDescriptor(); | 
| 208 } | 209 } | 
| 209 | 210 | 
| 210 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 211 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 
| 211   input_event inputs[4]; | 212   input_event inputs[4]; | 
| 212   ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 213   ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 
| 213   if (read_size <= 0) | 214   if (read_size < 0) { | 
|  | 215     if (errno == EINTR || errno == EAGAIN) | 
|  | 216       return; | 
|  | 217     PLOG(ERROR) << "error reading device " << path_.value(); | 
|  | 218     Stop(); | 
| 214     return; | 219     return; | 
|  | 220   } | 
| 215 | 221 | 
| 216   CHECK_EQ(read_size % sizeof(*inputs), 0u); | 222   CHECK_EQ(read_size % sizeof(*inputs), 0u); | 
| 217   ProcessEvents(inputs, read_size / sizeof(*inputs)); | 223   ProcessEvents(inputs, read_size / sizeof(*inputs)); | 
| 218 } | 224 } | 
| 219 | 225 | 
| 220 void KeyEventConverterEvdev::OnFileCanWriteWithoutBlocking(int fd) { | 226 void KeyEventConverterEvdev::OnFileCanWriteWithoutBlocking(int fd) { | 
| 221   NOTREACHED(); | 227   NOTREACHED(); | 
| 222 } | 228 } | 
| 223 | 229 | 
| 224 void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs, | 230 void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs, | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 250   } | 256   } | 
| 251 | 257 | 
| 252   int flags = modifiers_->GetModifierFlags(); | 258   int flags = modifiers_->GetModifierFlags(); | 
| 253 | 259 | 
| 254   scoped_ptr<KeyEvent> key_event( | 260   scoped_ptr<KeyEvent> key_event( | 
| 255       new KeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true)); | 261       new KeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true)); | 
| 256   DispatchEvent(key_event.PassAs<ui::Event>()); | 262   DispatchEvent(key_event.PassAs<ui::Event>()); | 
| 257 } | 263 } | 
| 258 | 264 | 
| 259 }  // namespace ui | 265 }  // namespace ui | 
| OLD | NEW | 
|---|