| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 default: | 365 default: |
| 366 DVLOG(5) << "unhandled code for EV_ABS: " << input.code; | 366 DVLOG(5) << "unhandled code for EV_ABS: " << input.code; |
| 367 return; | 367 return; |
| 368 } | 368 } |
| 369 events_[current_slot_].altered = true; | 369 events_[current_slot_].altered = true; |
| 370 } | 370 } |
| 371 | 371 |
| 372 void TouchEventConverterEvdev::ProcessSyn(const input_event& input) { | 372 void TouchEventConverterEvdev::ProcessSyn(const input_event& input) { |
| 373 switch (input.code) { | 373 switch (input.code) { |
| 374 case SYN_REPORT: | 374 case SYN_REPORT: |
| 375 ReportEvents(EventConverterEvdev::TimeDeltaFromInputEvent(input)); | 375 ReportEvents(EventConverterEvdev::TimeTicksFromInputEvent(input)); |
| 376 break; | 376 break; |
| 377 case SYN_DROPPED: | 377 case SYN_DROPPED: |
| 378 // Some buffer has overrun. We ignore all events up to and | 378 // Some buffer has overrun. We ignore all events up to and |
| 379 // including the next SYN_REPORT. | 379 // including the next SYN_REPORT. |
| 380 dropped_events_ = true; | 380 dropped_events_ = true; |
| 381 break; | 381 break; |
| 382 default: | 382 default: |
| 383 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; | 383 NOTIMPLEMENTED() << "invalid code for EV_SYN: " << input.code; |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 EventType TouchEventConverterEvdev::GetEventTypeForTouch( | 387 EventType TouchEventConverterEvdev::GetEventTypeForTouch( |
| 388 const InProgressTouchEvdev& touch) { | 388 const InProgressTouchEvdev& touch) { |
| 389 if (touch.cancelled) | 389 if (touch.cancelled) |
| 390 return ET_UNKNOWN; | 390 return ET_UNKNOWN; |
| 391 | 391 |
| 392 if (touch_noise_finder_ && touch_noise_finder_->SlotHasNoise(touch.slot)) { | 392 if (touch_noise_finder_ && touch_noise_finder_->SlotHasNoise(touch.slot)) { |
| 393 if (touch.touching && !touch.was_touching) | 393 if (touch.touching && !touch.was_touching) |
| 394 return ET_UNKNOWN; | 394 return ET_UNKNOWN; |
| 395 return ET_TOUCH_CANCELLED; | 395 return ET_TOUCH_CANCELLED; |
| 396 } | 396 } |
| 397 | 397 |
| 398 if (touch.touching) | 398 if (touch.touching) |
| 399 return touch.was_touching ? ET_TOUCH_MOVED : ET_TOUCH_PRESSED; | 399 return touch.was_touching ? ET_TOUCH_MOVED : ET_TOUCH_PRESSED; |
| 400 return touch.was_touching ? ET_TOUCH_RELEASED : ET_UNKNOWN; | 400 return touch.was_touching ? ET_TOUCH_RELEASED : ET_UNKNOWN; |
| 401 } | 401 } |
| 402 | 402 |
| 403 void TouchEventConverterEvdev::ReportEvent(const InProgressTouchEvdev& event, | 403 void TouchEventConverterEvdev::ReportEvent(const InProgressTouchEvdev& event, |
| 404 EventType event_type, | 404 EventType event_type, |
| 405 const base::TimeDelta& timestamp) { | 405 base::TimeTicks timestamp) { |
| 406 PointerDetails details(GetPointerTypeFromEvent(event), event.radius_x, | 406 PointerDetails details(GetPointerTypeFromEvent(event), event.radius_x, |
| 407 event.radius_y, event.pressure, | 407 event.radius_y, event.pressure, |
| 408 /* tilt_x */ 0.0f, | 408 /* tilt_x */ 0.0f, |
| 409 /* tilt_y */ 0.0f); | 409 /* tilt_y */ 0.0f); |
| 410 dispatcher_->DispatchTouchEvent( | 410 dispatcher_->DispatchTouchEvent( |
| 411 TouchEventParams(input_device_.id, event.slot, event_type, | 411 TouchEventParams(input_device_.id, event.slot, event_type, |
| 412 gfx::PointF(event.x, event.y), details, timestamp)); | 412 gfx::PointF(event.x, event.y), details, timestamp)); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void TouchEventConverterEvdev::ReportEvents(base::TimeDelta delta) { | 415 void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { |
| 416 if (dropped_events_) { | 416 if (dropped_events_) { |
| 417 Reinitialize(); | 417 Reinitialize(); |
| 418 dropped_events_ = false; | 418 dropped_events_ = false; |
| 419 } | 419 } |
| 420 | 420 |
| 421 if (touch_noise_finder_) | 421 if (touch_noise_finder_) |
| 422 touch_noise_finder_->HandleTouches(events_, delta); | 422 touch_noise_finder_->HandleTouches(events_, timestamp); |
| 423 | 423 |
| 424 for (size_t i = 0; i < events_.size(); i++) { | 424 for (size_t i = 0; i < events_.size(); i++) { |
| 425 InProgressTouchEvdev* event = &events_[i]; | 425 InProgressTouchEvdev* event = &events_[i]; |
| 426 if (!event->altered) | 426 if (!event->altered) |
| 427 continue; | 427 continue; |
| 428 | 428 |
| 429 EventType event_type = GetEventTypeForTouch(*event); | 429 EventType event_type = GetEventTypeForTouch(*event); |
| 430 if (event_type == ET_UNKNOWN || event_type == ET_TOUCH_CANCELLED) | 430 if (event_type == ET_UNKNOWN || event_type == ET_TOUCH_CANCELLED) |
| 431 event->cancelled = true; | 431 event->cancelled = true; |
| 432 | 432 |
| 433 if (event_type != ET_UNKNOWN) | 433 if (event_type != ET_UNKNOWN) |
| 434 ReportEvent(*event, event_type, delta); | 434 ReportEvent(*event, event_type, timestamp); |
| 435 | 435 |
| 436 event->was_touching = event->touching; | 436 event->was_touching = event->touching; |
| 437 event->altered = false; | 437 event->altered = false; |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 | 440 |
| 441 void TouchEventConverterEvdev::UpdateTrackingId(int slot, int tracking_id) { | 441 void TouchEventConverterEvdev::UpdateTrackingId(int slot, int tracking_id) { |
| 442 InProgressTouchEvdev* event = &events_[slot]; | 442 InProgressTouchEvdev* event = &events_[slot]; |
| 443 | 443 |
| 444 if (event->tracking_id == tracking_id) | 444 if (event->tracking_id == tracking_id) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 464 if (pressure_max_ - pressure_min_) | 464 if (pressure_max_ - pressure_min_) |
| 465 pressure /= pressure_max_ - pressure_min_; | 465 pressure /= pressure_max_ - pressure_min_; |
| 466 return pressure; | 466 return pressure; |
| 467 } | 467 } |
| 468 | 468 |
| 469 int TouchEventConverterEvdev::NextTrackingId() { | 469 int TouchEventConverterEvdev::NextTrackingId() { |
| 470 return next_tracking_id_++ & kMaxTrackingId; | 470 return next_tracking_id_++ & kMaxTrackingId; |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace ui | 473 } // namespace ui |
| OLD | NEW |