| 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/touch_event_converter.h" | 5 #include "ui/events/ozone/evdev/touch_event_converter.h" | 
| 6 | 6 | 
|  | 7 #include <errno.h> | 
| 7 #include <fcntl.h> | 8 #include <fcntl.h> | 
| 8 #include <linux/input.h> | 9 #include <linux/input.h> | 
| 9 #include <poll.h> | 10 #include <poll.h> | 
| 10 #include <stdio.h> | 11 #include <stdio.h> | 
| 11 #include <unistd.h> | 12 #include <unistd.h> | 
| 12 | 13 | 
| 13 #include <cmath> | 14 #include <cmath> | 
| 14 #include <limits> | 15 #include <limits> | 
| 15 | 16 | 
| 16 #include "base/bind.h" | 17 #include "base/bind.h" | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 109 } | 110 } | 
| 110 | 111 | 
| 111 void TouchEventConverterEvdev::OnFileCanWriteWithoutBlocking(int /* fd */) { | 112 void TouchEventConverterEvdev::OnFileCanWriteWithoutBlocking(int /* fd */) { | 
| 112   // Read-only file-descriptors. | 113   // Read-only file-descriptors. | 
| 113   NOTREACHED(); | 114   NOTREACHED(); | 
| 114 } | 115 } | 
| 115 | 116 | 
| 116 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 117 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 
| 117   input_event inputs[MAX_FINGERS * 6 + 1]; | 118   input_event inputs[MAX_FINGERS * 6 + 1]; | 
| 118   ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 119   ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 
| 119   if (read_size <= 0) | 120   if (read_size < 0) { | 
|  | 121     if (errno == EINTR || errno == EAGAIN) | 
|  | 122       return; | 
|  | 123     PLOG(ERROR) << "error reading device " << path_.value(); | 
|  | 124     Stop(); | 
| 120     return; | 125     return; | 
|  | 126   } | 
| 121 | 127 | 
| 122   for (unsigned i = 0; i < read_size / sizeof(*inputs); i++) { | 128   for (unsigned i = 0; i < read_size / sizeof(*inputs); i++) { | 
| 123     const input_event& input = inputs[i]; | 129     const input_event& input = inputs[i]; | 
| 124     if (input.type == EV_ABS) { | 130     if (input.type == EV_ABS) { | 
| 125       switch (input.code) { | 131       switch (input.code) { | 
| 126         case ABS_MT_TOUCH_MAJOR: | 132         case ABS_MT_TOUCH_MAJOR: | 
| 127           altered_slots_.set(current_slot_); | 133           altered_slots_.set(current_slot_); | 
| 128           events_[current_slot_].major_ = input.value; | 134           events_[current_slot_].major_ = input.value; | 
| 129           break; | 135           break; | 
| 130         case ABS_X: | 136         case ABS_X: | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 199         default: | 205         default: | 
| 200           NOTREACHED() << "invalid code for EV_KEY: " << input.code; | 206           NOTREACHED() << "invalid code for EV_KEY: " << input.code; | 
| 201       } | 207       } | 
| 202     } else { | 208     } else { | 
| 203       NOTREACHED() << "invalid type: " << input.type; | 209       NOTREACHED() << "invalid type: " << input.type; | 
| 204     } | 210     } | 
| 205   } | 211   } | 
| 206 } | 212 } | 
| 207 | 213 | 
| 208 }  // namespace ui | 214 }  // namespace ui | 
| OLD | NEW | 
|---|