| 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/touch_event_converter_evdev.h" | 5 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <linux/input.h> | 9 #include <linux/input.h> |
| 10 #include <poll.h> | 10 #include <poll.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 | 13 |
| 14 #include <cmath> | 14 #include <cmath> |
| 15 #include <limits> | 15 #include <limits> |
| 16 | 16 |
| 17 #include "base/bind.h" | 17 #include "base/bind.h" |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
| 22 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 26 #include "base/trace_event/trace_event.h" |
| 26 #include "ui/events/devices/device_data_manager.h" | 27 #include "ui/events/devices/device_data_manager.h" |
| 27 #include "ui/events/devices/device_util_linux.h" | 28 #include "ui/events/devices/device_util_linux.h" |
| 28 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
| 29 #include "ui/events/event_constants.h" | 30 #include "ui/events/event_constants.h" |
| 30 #include "ui/events/event_switches.h" | 31 #include "ui/events/event_switches.h" |
| 31 #include "ui/events/event_utils.h" | 32 #include "ui/events/event_utils.h" |
| 32 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 33 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 33 #include "ui/events/ozone/evdev/touch_evdev_types.h" | 34 #include "ui/events/ozone/evdev/touch_evdev_types.h" |
| 34 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" | 35 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" |
| 35 | 36 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 208 |
| 208 int TouchEventConverterEvdev::GetTouchPoints() const { | 209 int TouchEventConverterEvdev::GetTouchPoints() const { |
| 209 return touch_points_; | 210 return touch_points_; |
| 210 } | 211 } |
| 211 | 212 |
| 212 void TouchEventConverterEvdev::OnStopped() { | 213 void TouchEventConverterEvdev::OnStopped() { |
| 213 ReleaseTouches(); | 214 ReleaseTouches(); |
| 214 } | 215 } |
| 215 | 216 |
| 216 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 217 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { |
| 218 TRACE_EVENT1("evdev", |
| 219 "TouchEventConverterEvdev::OnFileCanReadWithoutBlocking", "fd", |
| 220 fd); |
| 221 |
| 217 input_event inputs[kNumTouchEvdevSlots * 6 + 1]; | 222 input_event inputs[kNumTouchEvdevSlots * 6 + 1]; |
| 218 ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 223 ssize_t read_size = read(fd, inputs, sizeof(inputs)); |
| 219 if (read_size < 0) { | 224 if (read_size < 0) { |
| 220 if (errno == EINTR || errno == EAGAIN) | 225 if (errno == EINTR || errno == EAGAIN) |
| 221 return; | 226 return; |
| 222 if (errno != ENODEV) | 227 if (errno != ENODEV) |
| 223 PLOG(ERROR) << "error reading device " << path_.value(); | 228 PLOG(ERROR) << "error reading device " << path_.value(); |
| 224 Stop(); | 229 Stop(); |
| 225 return; | 230 return; |
| 226 } | 231 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 if (pressure_max_ - pressure_min_) | 425 if (pressure_max_ - pressure_min_) |
| 421 pressure /= pressure_max_ - pressure_min_; | 426 pressure /= pressure_max_ - pressure_min_; |
| 422 return pressure; | 427 return pressure; |
| 423 } | 428 } |
| 424 | 429 |
| 425 int TouchEventConverterEvdev::NextTrackingId() { | 430 int TouchEventConverterEvdev::NextTrackingId() { |
| 426 return next_tracking_id_++ & kMaxTrackingId; | 431 return next_tracking_id_++ & kMaxTrackingId; |
| 427 } | 432 } |
| 428 | 433 |
| 429 } // namespace ui | 434 } // namespace ui |
| OLD | NEW |