Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: ui/events/ozone/evdev/touch_event_converter.cc

Issue 144233006: evdev: Fix infinite loop when devices are unplugged (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dropped EventConverterEvdev Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/events/ozone/evdev/key_event_converter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/key_event_converter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698