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 11 matching lines...) Expand all Loading... | |
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 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
32 #include "ui/events/ozone/evdev/touch_noise/touch_noise_remover.h" | |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 struct TouchCalibration { | 36 struct TouchCalibration { |
36 int bezel_left; | 37 int bezel_left; |
37 int bezel_right; | 38 int bezel_right; |
38 int bezel_top; | 39 int bezel_top; |
39 int bezel_bottom; | 40 int bezel_bottom; |
40 }; | 41 }; |
41 | 42 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 base::FilePath path, | 77 base::FilePath path, |
77 int id, | 78 int id, |
78 InputDeviceType type, | 79 InputDeviceType type, |
79 DeviceEventDispatcherEvdev* dispatcher) | 80 DeviceEventDispatcherEvdev* dispatcher) |
80 : EventConverterEvdev(fd, path, id, type), | 81 : EventConverterEvdev(fd, path, id, type), |
81 dispatcher_(dispatcher), | 82 dispatcher_(dispatcher), |
82 syn_dropped_(false), | 83 syn_dropped_(false), |
83 is_type_a_(false), | 84 is_type_a_(false), |
84 touch_points_(0), | 85 touch_points_(0), |
85 current_slot_(0) { | 86 current_slot_(0) { |
87 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
88 switches::kExtraTouchNoiseFiltering)) { | |
89 touch_noise_remover_.reset(new TouchNoiseRemover); | |
90 } | |
86 } | 91 } |
87 | 92 |
88 TouchEventConverterEvdev::~TouchEventConverterEvdev() { | 93 TouchEventConverterEvdev::~TouchEventConverterEvdev() { |
89 Stop(); | 94 Stop(); |
90 close(fd_); | 95 close(fd_); |
91 } | 96 } |
92 | 97 |
93 void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { | 98 void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { |
94 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE); | 99 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE); |
95 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE); | 100 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 case SYN_DROPPED: | 274 case SYN_DROPPED: |
270 // Some buffer has overrun. We ignore all events up to and | 275 // Some buffer has overrun. We ignore all events up to and |
271 // including the next SYN_REPORT. | 276 // including the next SYN_REPORT. |
272 syn_dropped_ = true; | 277 syn_dropped_ = true; |
273 break; | 278 break; |
274 default: | 279 default: |
275 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; | 280 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; |
276 } | 281 } |
277 } | 282 } |
278 | 283 |
279 void TouchEventConverterEvdev::ReportEvent(int touch_id, | |
280 const InProgressEvents& event, | |
281 const base::TimeDelta& timestamp) { | |
282 dispatcher_->DispatchTouchEvent(TouchEventParams( | |
283 id_, touch_id, event.type_, gfx::PointF(event.x_, event.y_), | |
284 gfx::Vector2dF(event.radius_x_, event.radius_y_), event.pressure_, | |
285 timestamp)); | |
286 } | |
287 | |
288 void TouchEventConverterEvdev::ReportEvents(base::TimeDelta delta) { | 284 void TouchEventConverterEvdev::ReportEvents(base::TimeDelta delta) { |
285 std::vector<TouchEventParams> to_dispatch; | |
flackr
2015/03/10 05:23:40
If I understand correctly, we construct and copy c
pkotwicz
2015/03/13 03:53:16
I have refactored this as you requested
flackr
2015/03/13 15:08:35
Thanks!
| |
289 for (size_t i = 0; i < events_.size(); i++) { | 286 for (size_t i = 0; i < events_.size(); i++) { |
290 if (events_[i].altered_) { | 287 if (events_[i].altered_) { |
291 ReportEvent(i, events_[i], delta); | 288 const InProgressEvents& event = events_[i]; |
289 to_dispatch.push_back( | |
290 TouchEventParams(id_, i, event.finger_, event.type_, | |
291 gfx::PointF(event.x_, event.y_), | |
292 gfx::Vector2dF(event.radius_x_, event.radius_y_), | |
293 event.pressure_, delta)); | |
292 | 294 |
293 // Subsequent events for this finger will be touch-move until it | 295 // Subsequent events for this finger will be touch-move until it |
294 // is released. | 296 // is released. |
295 events_[i].type_ = ET_TOUCH_MOVED; | 297 events_[i].type_ = ET_TOUCH_MOVED; |
flackr
2015/03/10 05:23:39
Since we change the event type to MOVED regardless
| |
296 events_[i].altered_ = false; | 298 events_[i].altered_ = false; |
297 } | 299 } |
298 } | 300 } |
301 | |
302 if (touch_noise_remover_) | |
303 touch_noise_remover_->RemoveNoise(&to_dispatch, delta); | |
flackr
2015/03/10 05:23:39
Can't just remove updates for noisy touches and no
pkotwicz
2015/03/13 03:53:16
I have changed the code to dispatch ET_TOUCH_CANCE
flackr
2015/03/13 15:08:35
Thanks. That's very strange that we used to keep t
| |
304 | |
305 for (const TouchEventParams& params : to_dispatch) | |
306 dispatcher_->DispatchTouchEvent(params); | |
299 } | 307 } |
300 | 308 |
301 } // namespace ui | 309 } // namespace ui |
OLD | NEW |