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 13 matching lines...) Expand all Loading... | |
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 "base/trace_event/trace_event.h" |
27 #include "ui/events/devices/device_data_manager.h" | 27 #include "ui/events/devices/device_data_manager.h" |
28 #include "ui/events/devices/device_util_linux.h" | 28 #include "ui/events/devices/device_util_linux.h" |
29 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
30 #include "ui/events/event_constants.h" | 30 #include "ui/events/event_constants.h" |
31 #include "ui/events/event_switches.h" | 31 #include "ui/events/event_switches.h" |
32 #include "ui/events/event_utils.h" | 32 #include "ui/events/event_utils.h" |
33 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 33 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
34 #include "ui/events/ozone/evdev/palm_suppression_filter.h" | |
34 #include "ui/events/ozone/evdev/touch_evdev_types.h" | 35 #include "ui/events/ozone/evdev/touch_evdev_types.h" |
35 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" | 36 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h" |
36 #include "ui/ozone/public/input_controller.h" | 37 #include "ui/ozone/public/input_controller.h" |
37 | 38 |
38 namespace { | 39 namespace { |
39 | 40 |
40 const int kMaxTrackingId = 0xffff; // TRKID_MAX in kernel. | 41 const int kMaxTrackingId = 0xffff; // TRKID_MAX in kernel. |
41 | 42 |
42 struct TouchCalibration { | 43 struct TouchCalibration { |
43 int bezel_left; | 44 int bezel_left; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 int id, | 107 int id, |
107 const EventDeviceInfo& devinfo, | 108 const EventDeviceInfo& devinfo, |
108 DeviceEventDispatcherEvdev* dispatcher) | 109 DeviceEventDispatcherEvdev* dispatcher) |
109 : EventConverterEvdev(fd, | 110 : EventConverterEvdev(fd, |
110 path, | 111 path, |
111 id, | 112 id, |
112 devinfo.device_type(), | 113 devinfo.device_type(), |
113 devinfo.name(), | 114 devinfo.name(), |
114 devinfo.vendor_id(), | 115 devinfo.vendor_id(), |
115 devinfo.product_id()), | 116 devinfo.product_id()), |
116 dispatcher_(dispatcher) { | 117 dispatcher_(dispatcher), |
118 palm_filter_(nullptr) { | |
117 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 119 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
118 switches::kExtraTouchNoiseFiltering)) { | 120 switches::kExtraTouchNoiseFiltering)) { |
119 touch_noise_finder_.reset(new TouchNoiseFinder); | 121 touch_noise_finder_.reset(new TouchNoiseFinder); |
120 } | 122 } |
121 touch_evdev_debug_buffer_.Initialize(devinfo); | 123 touch_evdev_debug_buffer_.Initialize(devinfo); |
122 } | 124 } |
123 | 125 |
124 TouchEventConverterEvdev::~TouchEventConverterEvdev() { | 126 TouchEventConverterEvdev::~TouchEventConverterEvdev() { |
125 } | 127 } |
126 | 128 |
127 void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { | 129 void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { |
128 has_mt_ = info.HasMultitouch(); | 130 has_mt_ = info.HasMultitouch(); |
131 has_pen_ = info.HasKeyEvent(BTN_TOOL_PEN); | |
129 | 132 |
130 if (has_mt_) { | 133 if (has_mt_) { |
131 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE); | 134 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE); |
132 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE); | 135 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE); |
133 x_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_X); | 136 x_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_X); |
134 x_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_X) - x_min_tuxels_ + 1; | 137 x_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_X) - x_min_tuxels_ + 1; |
135 y_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_Y); | 138 y_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_Y); |
136 y_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_Y) - y_min_tuxels_ + 1; | 139 y_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_Y) - y_min_tuxels_ + 1; |
137 touch_points_ = | 140 touch_points_ = |
138 std::min<int>(info.GetAbsMaximum(ABS_MT_SLOT) + 1, kNumTouchEvdevSlots); | 141 std::min<int>(info.GetAbsMaximum(ABS_MT_SLOT) + 1, kNumTouchEvdevSlots); |
142 major_max_ = info.GetAbsMaximum(ABS_MT_TOUCH_MAJOR); | |
139 current_slot_ = info.GetAbsValue(ABS_MT_SLOT); | 143 current_slot_ = info.GetAbsValue(ABS_MT_SLOT); |
140 } else { | 144 } else { |
141 pressure_min_ = info.GetAbsMinimum(ABS_PRESSURE); | 145 pressure_min_ = info.GetAbsMinimum(ABS_PRESSURE); |
142 pressure_max_ = info.GetAbsMaximum(ABS_PRESSURE); | 146 pressure_max_ = info.GetAbsMaximum(ABS_PRESSURE); |
143 x_min_tuxels_ = info.GetAbsMinimum(ABS_X); | 147 x_min_tuxels_ = info.GetAbsMinimum(ABS_X); |
144 x_num_tuxels_ = info.GetAbsMaximum(ABS_X) - x_min_tuxels_ + 1; | 148 x_num_tuxels_ = info.GetAbsMaximum(ABS_X) - x_min_tuxels_ + 1; |
145 y_min_tuxels_ = info.GetAbsMinimum(ABS_Y); | 149 y_min_tuxels_ = info.GetAbsMinimum(ABS_Y); |
146 y_num_tuxels_ = info.GetAbsMaximum(ABS_Y) - y_min_tuxels_ + 1; | 150 y_num_tuxels_ = info.GetAbsMaximum(ABS_Y) - y_min_tuxels_ + 1; |
151 major_max_ = std::numeric_limits<int>::max(); | |
147 touch_points_ = 1; | 152 touch_points_ = 1; |
148 current_slot_ = 0; | 153 current_slot_ = 0; |
149 } | 154 } |
150 | 155 |
151 quirk_left_mouse_button_ = | 156 quirk_left_mouse_button_ = |
152 !has_mt_ && !info.HasKeyEvent(BTN_TOUCH) && info.HasKeyEvent(BTN_LEFT); | 157 !has_mt_ && !info.HasKeyEvent(BTN_TOUCH) && info.HasKeyEvent(BTN_LEFT); |
153 | 158 |
154 // Apply --touch-calibration. | 159 // Apply --touch-calibration. |
155 if (type() == INPUT_DEVICE_INTERNAL) { | 160 if (type() == INPUT_DEVICE_INTERNAL) { |
156 TouchCalibration cal = {}; | 161 TouchCalibration cal = {}; |
(...skipping 21 matching lines...) Expand all Loading... | |
178 ABS_MT_TRACKING_ID, i, kTrackingIdForUnusedSlot); | 183 ABS_MT_TRACKING_ID, i, kTrackingIdForUnusedSlot); |
179 events_[i].touching = (events_[i].tracking_id >= 0); | 184 events_[i].touching = (events_[i].tracking_id >= 0); |
180 events_[i].slot = i; | 185 events_[i].slot = i; |
181 | 186 |
182 // Dirty the slot so we'll update the consumer at the first opportunity. | 187 // Dirty the slot so we'll update the consumer at the first opportunity. |
183 // We can't dispatch here as this is currently called on the worker pool. | 188 // We can't dispatch here as this is currently called on the worker pool. |
184 // TODO(spang): Move initialization off worker pool. | 189 // TODO(spang): Move initialization off worker pool. |
185 events_[i].altered = true; | 190 events_[i].altered = true; |
186 | 191 |
187 // Optional bits. | 192 // Optional bits. |
188 events_[i].radius_x = | 193 int touch_major = |
189 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MAJOR, i, 0) / 2.0f; | 194 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MAJOR, i, 0); |
195 events_[i].radius_x = touch_major / 2.0f; | |
190 events_[i].radius_y = | 196 events_[i].radius_y = |
191 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MINOR, i, 0) / 2.0f; | 197 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MINOR, i, 0) / 2.0f; |
192 events_[i].pressure = ScalePressure( | 198 events_[i].pressure = ScalePressure( |
193 info.GetAbsMtSlotValueWithDefault(ABS_MT_PRESSURE, i, 0)); | 199 info.GetAbsMtSlotValueWithDefault(ABS_MT_PRESSURE, i, 0)); |
200 events_[i].is_palm = (touch_major == major_max_); | |
spang
2016/08/23 23:32:29
Are we confident all MT drivers have the touch maj
denniskempin
2016/08/25 23:27:45
Of course we shouldn't rely on this. I should have
| |
194 } | 201 } |
195 } else { | 202 } else { |
196 // TODO(spang): Add key state to EventDeviceInfo to allow initial contact. | 203 // TODO(spang): Add key state to EventDeviceInfo to allow initial contact. |
197 // (and make sure to take into account quirk_left_mouse_button_) | 204 // (and make sure to take into account quirk_left_mouse_button_) |
198 events_[0].x = 0; | 205 events_[0].x = 0; |
199 events_[0].y = 0; | 206 events_[0].y = 0; |
200 events_[0].tracking_id = kTrackingIdForUnusedSlot; | 207 events_[0].tracking_id = kTrackingIdForUnusedSlot; |
201 events_[0].touching = false; | 208 events_[0].touching = false; |
202 events_[0].slot = 0; | 209 events_[0].slot = 0; |
203 events_[0].radius_x = 0; | 210 events_[0].radius_x = 0; |
204 events_[0].radius_y = 0; | 211 events_[0].radius_y = 0; |
205 events_[0].pressure = 0; | 212 events_[0].pressure = 0; |
206 events_[0].tool_code = 0; | 213 events_[0].tool_code = 0; |
214 events_[0].is_palm = false; | |
207 } | 215 } |
216 | |
217 if (palm_filter_) | |
218 palm_filter_->Reset(); | |
spang
2016/08/23 23:32:29
Why should losing sync cancel suppression? Dropped
denniskempin
2016/08/25 23:27:45
Done.
| |
208 } | 219 } |
209 | 220 |
210 void TouchEventConverterEvdev::Reinitialize() { | 221 void TouchEventConverterEvdev::Reinitialize() { |
211 ReleaseButtons(); | 222 ReleaseButtons(); |
212 | 223 |
213 EventDeviceInfo info; | 224 EventDeviceInfo info; |
214 if (!info.Initialize(fd_, path_)) { | 225 if (!info.Initialize(fd_, path_)) { |
215 LOG(ERROR) << "Failed to synchronize state for touch device: " | 226 LOG(ERROR) << "Failed to synchronize state for touch device: " |
216 << path_.value(); | 227 << path_.value(); |
217 Stop(); | 228 Stop(); |
218 return; | 229 return; |
219 } | 230 } |
220 Initialize(info); | 231 Initialize(info); |
221 } | 232 } |
222 | 233 |
223 bool TouchEventConverterEvdev::HasTouchscreen() const { | 234 bool TouchEventConverterEvdev::HasTouchscreen() const { |
224 return true; | 235 return true; |
225 } | 236 } |
226 | 237 |
238 bool TouchEventConverterEvdev::HasPen() const { | |
239 return has_pen_; | |
240 } | |
241 | |
227 gfx::Size TouchEventConverterEvdev::GetTouchscreenSize() const { | 242 gfx::Size TouchEventConverterEvdev::GetTouchscreenSize() const { |
228 return gfx::Size(x_num_tuxels_, y_num_tuxels_); | 243 return gfx::Size(x_num_tuxels_, y_num_tuxels_); |
229 } | 244 } |
230 | 245 |
231 int TouchEventConverterEvdev::GetTouchPoints() const { | 246 int TouchEventConverterEvdev::GetTouchPoints() const { |
232 return touch_points_; | 247 return touch_points_; |
233 } | 248 } |
234 | 249 |
235 void TouchEventConverterEvdev::OnEnabled() { | 250 void TouchEventConverterEvdev::OnEnabled() { |
236 ReportEvents(EventTimeForNow()); | 251 ReportEvents(EventTimeForNow()); |
237 } | 252 } |
238 | 253 |
239 void TouchEventConverterEvdev::OnDisabled() { | 254 void TouchEventConverterEvdev::OnDisabled() { |
240 ReleaseTouches(); | 255 ReleaseTouches(); |
241 ReleaseButtons(); | 256 ReleaseButtons(); |
257 if (palm_filter_) | |
258 palm_filter_->Reset(); | |
242 } | 259 } |
243 | 260 |
244 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { | 261 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { |
245 TRACE_EVENT1("evdev", | 262 TRACE_EVENT1("evdev", |
246 "TouchEventConverterEvdev::OnFileCanReadWithoutBlocking", "fd", | 263 "TouchEventConverterEvdev::OnFileCanReadWithoutBlocking", "fd", |
247 fd); | 264 fd); |
248 | 265 |
249 input_event inputs[kNumTouchEvdevSlots * 6 + 1]; | 266 input_event inputs[kNumTouchEvdevSlots * 6 + 1]; |
250 ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 267 ssize_t read_size = read(fd, inputs, sizeof(inputs)); |
251 if (read_size < 0) { | 268 if (read_size < 0) { |
(...skipping 22 matching lines...) Expand all Loading... | |
274 } | 291 } |
275 | 292 |
276 void TouchEventConverterEvdev::DumpTouchEventLog(const char* filename) { | 293 void TouchEventConverterEvdev::DumpTouchEventLog(const char* filename) { |
277 touch_evdev_debug_buffer_.DumpLog(filename); | 294 touch_evdev_debug_buffer_.DumpLog(filename); |
278 } | 295 } |
279 | 296 |
280 void TouchEventConverterEvdev::SetTouchEventLoggingEnabled(bool enabled) { | 297 void TouchEventConverterEvdev::SetTouchEventLoggingEnabled(bool enabled) { |
281 touch_logging_enabled_ = enabled; | 298 touch_logging_enabled_ = enabled; |
282 } | 299 } |
283 | 300 |
301 void TouchEventConverterEvdev::SetPalmSuppressionFilter( | |
302 PalmSuppressionFilter* palm_filter) { | |
303 palm_filter_ = palm_filter; | |
304 } | |
305 | |
284 void TouchEventConverterEvdev::ProcessMultitouchEvent( | 306 void TouchEventConverterEvdev::ProcessMultitouchEvent( |
285 const input_event& input) { | 307 const input_event& input) { |
286 if (touch_logging_enabled_) | 308 if (touch_logging_enabled_) |
287 touch_evdev_debug_buffer_.ProcessEvent(current_slot_, &input); | 309 touch_evdev_debug_buffer_.ProcessEvent(current_slot_, &input); |
288 | 310 |
289 if (input.type == EV_SYN) { | 311 if (input.type == EV_SYN) { |
290 ProcessSyn(input); | 312 ProcessSyn(input); |
291 } else if (dropped_events_) { | 313 } else if (dropped_events_) { |
292 // Do nothing. This branch indicates we have lost sync with the driver. | 314 // Do nothing. This branch indicates we have lost sync with the driver. |
293 } else if (input.type == EV_ABS) { | 315 } else if (input.type == EV_ABS) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 // Do not change tool types while touching to prevent inconsistencies | 367 // Do not change tool types while touching to prevent inconsistencies |
346 // from switching between Mouse and TouchEvents. | 368 // from switching between Mouse and TouchEvents. |
347 if (events_[current_slot_].was_touching) | 369 if (events_[current_slot_].was_touching) |
348 break; | 370 break; |
349 | 371 |
350 if (input.value > 0) { | 372 if (input.value > 0) { |
351 events_[current_slot_].tool_code = input.code; | 373 events_[current_slot_].tool_code = input.code; |
352 } else { | 374 } else { |
353 events_[current_slot_].tool_code = 0; | 375 events_[current_slot_].tool_code = 0; |
354 } | 376 } |
377 events_[current_slot_].altered = true; | |
355 break; | 378 break; |
356 default: | 379 default: |
357 NOTIMPLEMENTED() << "invalid code for EV_KEY: " << input.code; | 380 NOTIMPLEMENTED() << "invalid code for EV_KEY: " << input.code; |
358 } | 381 } |
359 } | 382 } |
360 | 383 |
361 void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { | 384 void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { |
362 switch (input.code) { | 385 switch (input.code) { |
363 case ABS_MT_TOUCH_MAJOR: | 386 case ABS_MT_TOUCH_MAJOR: |
364 // TODO(spang): If we have all of major, minor, and orientation, | 387 // TODO(spang): If we have all of major, minor, and orientation, |
365 // we can scale the ellipse correctly. However on the Pixel we get | 388 // we can scale the ellipse correctly. However on the Pixel we get |
366 // neither minor nor orientation, so this is all we can do. | 389 // neither minor nor orientation, so this is all we can do. |
367 events_[current_slot_].radius_x = input.value / 2.0f; | 390 events_[current_slot_].radius_x = input.value / 2.0f; |
391 | |
392 // The MT protocol cannot communicate cancelled touches, so some kernel | |
393 // drivers will identify palms by setting touch major to max. | |
394 events_[current_slot_].is_palm = (input.value == major_max_); | |
368 break; | 395 break; |
369 case ABS_MT_TOUCH_MINOR: | 396 case ABS_MT_TOUCH_MINOR: |
370 events_[current_slot_].radius_y = input.value / 2.0f; | 397 events_[current_slot_].radius_y = input.value / 2.0f; |
371 break; | 398 break; |
372 case ABS_MT_POSITION_X: | 399 case ABS_MT_POSITION_X: |
373 events_[current_slot_].x = input.value; | 400 events_[current_slot_].x = input.value; |
374 break; | 401 break; |
375 case ABS_MT_POSITION_Y: | 402 case ABS_MT_POSITION_Y: |
376 events_[current_slot_].y = input.value; | 403 events_[current_slot_].y = input.value; |
377 break; | 404 break; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 default: | 437 default: |
411 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; | 438 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; |
412 } | 439 } |
413 } | 440 } |
414 | 441 |
415 EventType TouchEventConverterEvdev::GetEventTypeForTouch( | 442 EventType TouchEventConverterEvdev::GetEventTypeForTouch( |
416 const InProgressTouchEvdev& touch) { | 443 const InProgressTouchEvdev& touch) { |
417 if (touch.cancelled) | 444 if (touch.cancelled) |
418 return ET_UNKNOWN; | 445 return ET_UNKNOWN; |
419 | 446 |
447 if (touch.is_palm) { | |
448 if (touch.touching && !touch.was_touching) | |
449 return ET_UNKNOWN; | |
450 return ET_TOUCH_CANCELLED; | |
451 } | |
452 | |
420 if (touch_noise_finder_ && touch_noise_finder_->SlotHasNoise(touch.slot)) { | 453 if (touch_noise_finder_ && touch_noise_finder_->SlotHasNoise(touch.slot)) { |
421 if (touch.touching && !touch.was_touching) | 454 if (touch.touching && !touch.was_touching) |
422 return ET_UNKNOWN; | 455 return ET_UNKNOWN; |
423 return ET_TOUCH_CANCELLED; | 456 return ET_TOUCH_CANCELLED; |
424 } | 457 } |
425 | 458 |
426 if (touch.touching) | 459 if (touch.touching) |
427 return touch.was_touching ? ET_TOUCH_MOVED : ET_TOUCH_PRESSED; | 460 return touch.was_touching ? ET_TOUCH_MOVED : ET_TOUCH_PRESSED; |
428 return touch.was_touching ? ET_TOUCH_RELEASED : ET_UNKNOWN; | 461 return touch.was_touching ? ET_TOUCH_RELEASED : ET_UNKNOWN; |
429 } | 462 } |
430 | 463 |
431 void TouchEventConverterEvdev::ReportTouchEvent( | 464 void TouchEventConverterEvdev::ReportTouchEvent( |
432 const InProgressTouchEvdev& event, | 465 const InProgressTouchEvdev& event, |
433 EventType event_type, | 466 EventType event_type, |
434 base::TimeTicks timestamp) { | 467 base::TimeTicks timestamp) { |
435 dispatcher_->DispatchTouchEvent(TouchEventParams( | 468 TouchEventParams params(input_device_.id, event.slot, event_type, |
436 input_device_.id, event.slot, event_type, gfx::PointF(event.x, event.y), | 469 gfx::PointF(event.x, event.y), |
437 GetEventPointerDetails(event), timestamp)); | 470 GetEventPointerDetails(event), timestamp); |
471 if (!palm_filter_ || palm_filter_->FilterTouch(params)) | |
spang
2016/08/23 23:32:29
I'm nervous about putting filtering this late beca
| |
472 dispatcher_->DispatchTouchEvent(params); | |
438 } | 473 } |
439 | 474 |
440 void TouchEventConverterEvdev::ReportStylusEvent( | 475 void TouchEventConverterEvdev::ReportStylusEvent( |
441 const InProgressTouchEvdev& event, | 476 const InProgressTouchEvdev& event, |
442 base::TimeTicks timestamp) { | 477 base::TimeTicks timestamp) { |
443 if (event.btn_left.changed) | 478 if (event.btn_left.changed) |
444 ReportButton(BTN_LEFT, event.btn_left.down, event, timestamp); | 479 ReportButton(BTN_LEFT, event.btn_left.down, event, timestamp); |
445 if (event.btn_right.changed) | 480 if (event.btn_right.changed) |
446 ReportButton(BTN_RIGHT, event.btn_right.down, event, timestamp); | 481 ReportButton(BTN_RIGHT, event.btn_right.down, event, timestamp); |
447 if (event.btn_middle.changed) | 482 if (event.btn_middle.changed) |
(...skipping 20 matching lines...) Expand all Loading... | |
468 } | 503 } |
469 | 504 |
470 if (touch_noise_finder_) | 505 if (touch_noise_finder_) |
471 touch_noise_finder_->HandleTouches(events_, timestamp); | 506 touch_noise_finder_->HandleTouches(events_, timestamp); |
472 | 507 |
473 for (size_t i = 0; i < events_.size(); i++) { | 508 for (size_t i = 0; i < events_.size(); i++) { |
474 InProgressTouchEvdev* event = &events_[i]; | 509 InProgressTouchEvdev* event = &events_[i]; |
475 if (!event->altered) | 510 if (!event->altered) |
476 continue; | 511 continue; |
477 | 512 |
513 if (has_pen_ && palm_filter_) { | |
514 palm_filter_->EnableSuppression(event->tool_code > 0, timestamp); | |
515 } | |
516 | |
478 if (event->tool_code > 0) { | 517 if (event->tool_code > 0) { |
479 ReportStylusEvent(*event, timestamp); | 518 ReportStylusEvent(*event, timestamp); |
480 } else { | 519 } else { |
481 EventType event_type = GetEventTypeForTouch(*event); | 520 EventType event_type = GetEventTypeForTouch(*event); |
482 if (event_type == ET_UNKNOWN || event_type == ET_TOUCH_CANCELLED) | 521 if (event_type == ET_UNKNOWN || event_type == ET_TOUCH_CANCELLED) |
483 event->cancelled = true; | 522 event->cancelled = true; |
484 | 523 |
485 if (event_type != ET_UNKNOWN) | 524 if (event_type != ET_UNKNOWN) |
486 ReportTouchEvent(*event, event_type, timestamp); | 525 ReportTouchEvent(*event, event_type, timestamp); |
487 } | 526 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 if (pressure_max_ - pressure_min_) | 580 if (pressure_max_ - pressure_min_) |
542 pressure /= pressure_max_ - pressure_min_; | 581 pressure /= pressure_max_ - pressure_min_; |
543 return pressure; | 582 return pressure; |
544 } | 583 } |
545 | 584 |
546 int TouchEventConverterEvdev::NextTrackingId() { | 585 int TouchEventConverterEvdev::NextTrackingId() { |
547 return next_tracking_id_++ & kMaxTrackingId; | 586 return next_tracking_id_++ & kMaxTrackingId; |
548 } | 587 } |
549 | 588 |
550 } // namespace ui | 589 } // namespace ui |
OLD | NEW |