| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #include "ui/events/ozone/evdev/event_converter.h" | 
|  | 6 | 
|  | 7 #include <errno.h> | 
|  | 8 #include <linux/input.h> | 
|  | 9 | 
|  | 10 #include "ui/events/ozone/evdev/event_modifiers.h" | 
|  | 11 | 
|  | 12 namespace ui { | 
|  | 13 | 
|  | 14 // Number of events to read at a time. | 
|  | 15 const int kEvdevBufferSize = 64; | 
|  | 16 | 
|  | 17 EventConverterEvdev::EventConverterEvdev(int fd, | 
|  | 18                                          base::FilePath path, | 
|  | 19                                          EventModifiersEvdev* modifiers) | 
|  | 20     : fd_(fd), path_(path), modifiers_(modifiers) {} | 
|  | 21 | 
|  | 22 EventConverterEvdev::~EventConverterEvdev() { close(fd_); } | 
|  | 23 | 
|  | 24 void EventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 
|  | 25   input_event inputs[kEvdevBufferSize]; | 
|  | 26   ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 
|  | 27   if (read_size <= 0) { | 
|  | 28     if (errno == EINTR || errno == EAGAIN) | 
|  | 29       return; | 
|  | 30     PLOG(ERROR) << "error reading device " << path_.value(); | 
|  | 31     return; | 
|  | 32   } | 
|  | 33 | 
|  | 34   CHECK_EQ(read_size % sizeof(*inputs), 0u); | 
|  | 35   ProcessEvents(inputs, read_size / sizeof(*inputs)); | 
|  | 36 } | 
|  | 37 | 
|  | 38 void EventConverterEvdev::OnFileCanWriteWithoutBlocking(int fd) { | 
|  | 39   NOTREACHED(); | 
|  | 40 } | 
|  | 41 | 
|  | 42 }  // namespace ui | 
| OLD | NEW | 
|---|