| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 ui::PointerDetails GetEventPointerDetails( | 81 ui::PointerDetails GetEventPointerDetails( |
| 82 const ui::InProgressTouchEvdev& event) { | 82 const ui::InProgressTouchEvdev& event) { |
| 83 ui::EventPointerType type; | 83 ui::EventPointerType type; |
| 84 switch (event.tool_code) { | 84 switch (event.tool_code) { |
| 85 case BTN_TOOL_PEN: | 85 case BTN_TOOL_PEN: |
| 86 type = ui::EventPointerType::POINTER_TYPE_PEN; | 86 type = ui::EventPointerType::POINTER_TYPE_PEN; |
| 87 break; | 87 break; |
| 88 case BTN_TOOL_RUBBER: | |
| 89 type = ui::EventPointerType::POINTER_TYPE_ERASER; | |
| 90 break; | |
| 91 default: | 88 default: |
| 92 type = ui::EventPointerType::POINTER_TYPE_TOUCH; | 89 type = ui::EventPointerType::POINTER_TYPE_TOUCH; |
| 93 } | 90 } |
| 94 return ui::PointerDetails(type, event.radius_x, event.radius_y, | 91 return ui::PointerDetails(type, event.radius_x, event.radius_y, |
| 95 event.pressure, | 92 event.pressure, |
| 96 /* tilt_x */ 0.0f, | 93 /* tilt_x */ 0.0f, |
| 97 /* tilt_y */ 0.0f); | 94 /* tilt_y */ 0.0f); |
| 98 } | 95 } |
| 99 | 96 |
| 100 const int kTrackingIdForUnusedSlot = -1; | 97 const int kTrackingIdForUnusedSlot = -1; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 event.value ? NextTrackingId() : kTrackingIdForUnusedSlot; | 323 event.value ? NextTrackingId() : kTrackingIdForUnusedSlot; |
| 327 ProcessMultitouchEvent(emulated_event); | 324 ProcessMultitouchEvent(emulated_event); |
| 328 } | 325 } |
| 329 } | 326 } |
| 330 } | 327 } |
| 331 | 328 |
| 332 void TouchEventConverterEvdev::ProcessKey(const input_event& input) { | 329 void TouchEventConverterEvdev::ProcessKey(const input_event& input) { |
| 333 switch (input.code) { | 330 switch (input.code) { |
| 334 case BTN_TOUCH: | 331 case BTN_TOUCH: |
| 335 case BTN_LEFT: | 332 case BTN_LEFT: |
| 336 case BTN_0: | |
| 337 events_[current_slot_].btn_left.down = input.value; | 333 events_[current_slot_].btn_left.down = input.value; |
| 338 events_[current_slot_].btn_left.changed = true; | 334 events_[current_slot_].btn_left.changed = true; |
| 339 break; | 335 break; |
| 340 case BTN_STYLUS: | 336 case BTN_STYLUS: |
| 341 events_[current_slot_].btn_right.down = input.value; | 337 events_[current_slot_].btn_right.down = input.value; |
| 342 events_[current_slot_].btn_right.changed = true; | 338 events_[current_slot_].btn_right.changed = true; |
| 343 break; | 339 break; |
| 344 case BTN_STYLUS2: | 340 case BTN_STYLUS2: |
| 345 events_[current_slot_].btn_middle.down = input.value; | 341 events_[current_slot_].btn_middle.down = input.value; |
| 346 events_[current_slot_].btn_middle.changed = true; | 342 events_[current_slot_].btn_middle.changed = true; |
| 347 break; | 343 break; |
| 348 case BTN_TOOL_PEN: | 344 case BTN_TOOL_PEN: |
| 349 case BTN_TOOL_RUBBER: | |
| 350 // Do not change tool types while touching to prevent inconsistencies | 345 // Do not change tool types while touching to prevent inconsistencies |
| 351 // from switching between Mouse and TouchEvents. | 346 // from switching between Mouse and TouchEvents. |
| 352 if (events_[current_slot_].was_touching) | 347 if (events_[current_slot_].was_touching) |
| 353 break; | 348 break; |
| 354 | 349 |
| 355 if (input.value > 0) { | 350 if (input.value > 0) { |
| 356 events_[current_slot_].tool_code = input.code; | 351 events_[current_slot_].tool_code = input.code; |
| 357 } else { | 352 } else { |
| 358 events_[current_slot_].tool_code = 0; | 353 events_[current_slot_].tool_code = 0; |
| 359 } | 354 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 if (pressure_max_ - pressure_min_) | 541 if (pressure_max_ - pressure_min_) |
| 547 pressure /= pressure_max_ - pressure_min_; | 542 pressure /= pressure_max_ - pressure_min_; |
| 548 return pressure; | 543 return pressure; |
| 549 } | 544 } |
| 550 | 545 |
| 551 int TouchEventConverterEvdev::NextTrackingId() { | 546 int TouchEventConverterEvdev::NextTrackingId() { |
| 552 return next_tracking_id_++ & kMaxTrackingId; | 547 return next_tracking_id_++ & kMaxTrackingId; |
| 553 } | 548 } |
| 554 | 549 |
| 555 } // namespace ui | 550 } // namespace ui |
| OLD | NEW |