| 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> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 "ui/events/devices/device_data_manager.h" | 26 #include "ui/events/devices/device_data_manager.h" |
| 27 #include "ui/events/devices/device_util_linux.h" | 27 #include "ui/events/devices/device_util_linux.h" |
| 28 #include "ui/events/event.h" | 28 #include "ui/events/event.h" |
| 29 #include "ui/events/event_constants.h" | 29 #include "ui/events/event_constants.h" |
| 30 #include "ui/events/event_switches.h" | 30 #include "ui/events/event_switches.h" |
| 31 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 struct TouchCalibration { | 35 struct TouchCalibration { |
| 35 int bezel_left; | 36 int bezel_left; |
| 36 int bezel_right; | 37 int bezel_right; |
| 37 int bezel_top; | 38 int bezel_top; |
| 38 int bezel_bottom; | 39 int bezel_bottom; |
| 39 }; | 40 }; |
| 40 | 41 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 67 radius_x_(0), | 68 radius_x_(0), |
| 68 radius_y_(0), | 69 radius_y_(0), |
| 69 pressure_(0) { | 70 pressure_(0) { |
| 70 } | 71 } |
| 71 | 72 |
| 72 TouchEventConverterEvdev::TouchEventConverterEvdev( | 73 TouchEventConverterEvdev::TouchEventConverterEvdev( |
| 73 int fd, | 74 int fd, |
| 74 base::FilePath path, | 75 base::FilePath path, |
| 75 int id, | 76 int id, |
| 76 InputDeviceType type, | 77 InputDeviceType type, |
| 77 const TouchEventDispatchCallback& touch_callback) | 78 DeviceEventDispatcherEvdev* dispatcher) |
| 78 : EventConverterEvdev(fd, path, id, type), | 79 : EventConverterEvdev(fd, path, id, type), |
| 79 touch_callback_(touch_callback), | 80 dispatcher_(dispatcher), |
| 80 syn_dropped_(false), | 81 syn_dropped_(false), |
| 81 is_type_a_(false), | 82 is_type_a_(false), |
| 82 current_slot_(0) { | 83 current_slot_(0) { |
| 83 } | 84 } |
| 84 | 85 |
| 85 TouchEventConverterEvdev::~TouchEventConverterEvdev() { | 86 TouchEventConverterEvdev::~TouchEventConverterEvdev() { |
| 86 Stop(); | 87 Stop(); |
| 87 close(fd_); | 88 close(fd_); |
| 88 } | 89 } |
| 89 | 90 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 syn_dropped_ = true; | 266 syn_dropped_ = true; |
| 266 break; | 267 break; |
| 267 default: | 268 default: |
| 268 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; | 269 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; |
| 269 } | 270 } |
| 270 } | 271 } |
| 271 | 272 |
| 272 void TouchEventConverterEvdev::ReportEvent(int touch_id, | 273 void TouchEventConverterEvdev::ReportEvent(int touch_id, |
| 273 const InProgressEvents& event, | 274 const InProgressEvents& event, |
| 274 const base::TimeDelta& timestamp) { | 275 const base::TimeDelta& timestamp) { |
| 275 touch_callback_.Run(TouchEventParams( | 276 dispatcher_->DispatchTouchEvent(TouchEventParams( |
| 276 id_, touch_id, event.type_, gfx::PointF(event.x_, event.y_), | 277 id_, touch_id, event.type_, gfx::PointF(event.x_, event.y_), |
| 277 gfx::Vector2dF(event.radius_x_, event.radius_y_), event.pressure_, | 278 gfx::Vector2dF(event.radius_x_, event.radius_y_), event.pressure_, |
| 278 timestamp)); | 279 timestamp)); |
| 279 } | 280 } |
| 280 | 281 |
| 281 void TouchEventConverterEvdev::ReportEvents(base::TimeDelta delta) { | 282 void TouchEventConverterEvdev::ReportEvents(base::TimeDelta delta) { |
| 282 for (int i = 0; i < MAX_FINGERS; i++) { | 283 for (int i = 0; i < MAX_FINGERS; i++) { |
| 283 if (altered_slots_[i]) { | 284 if (altered_slots_[i]) { |
| 284 ReportEvent(i, events_[i], delta); | 285 ReportEvent(i, events_[i], delta); |
| 285 | 286 |
| 286 // Subsequent events for this finger will be touch-move until it | 287 // Subsequent events for this finger will be touch-move until it |
| 287 // is released. | 288 // is released. |
| 288 events_[i].type_ = ET_TOUCH_MOVED; | 289 events_[i].type_ = ET_TOUCH_MOVED; |
| 289 } | 290 } |
| 290 } | 291 } |
| 291 altered_slots_.reset(); | 292 altered_slots_.reset(); |
| 292 } | 293 } |
| 293 | 294 |
| 294 } // namespace ui | 295 } // namespace ui |
| OLD | NEW |