Skip to content

Commit

Permalink
Android: Improved multi-touch (#1783)
Browse files Browse the repository at this point in the history
* Improved multi-touch

* Update feature matrix

* Generate cancelled events for all pointers

* Changed back features matrix layout

* Reduced code duplication

* Updated changelog

* Revert changelog update
  • Loading branch information
MarnixKuijs committed Dec 2, 2020
1 parent 6ddee9a commit 8fb7aa5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion FEATURES.md
Expand Up @@ -202,7 +202,7 @@ Legend:
|Cursor icon |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|✔️ |
|Touch events |✔️ ||✔️ |✔️ |✔️ |✔️ ||
|Touch pressure |✔️ |||||✔️ ||
|Multitouch |✔️ ||✔️ |✔️ | |✔️ ||
|Multitouch |✔️ ||✔️ |✔️ |✔️ |✔️ ||
|Keyboard events |✔️ |✔️ |✔️ |✔️ |||✔️ |
|Drag & Drop |[#720] |[#720] |[#720] |[#306] |**N/A**|**N/A**||
|Raw Device Events |[#750] |[#750] |[#750] |||||
Expand Down
19 changes: 16 additions & 3 deletions src/platform_impl/android/mod.rs
Expand Up @@ -193,14 +193,27 @@ impl<T: 'static> EventLoop<T> {
}
_ => None, // TODO mouse events
};

if let Some(phase) = phase {
for pointer in motion_event.pointers() {
let pointers: Box<
dyn Iterator<Item = ndk::event::Pointer<'_>>,
> = match phase {
event::TouchPhase::Started
| event::TouchPhase::Ended => Box::new(
std::iter::once(motion_event.pointer_at_index(
motion_event.pointer_index(),
)),
),
event::TouchPhase::Moved
| event::TouchPhase::Cancelled => {
Box::new(motion_event.pointers())
}
};

for pointer in pointers {
let location = PhysicalPosition {
x: pointer.x() as _,
y: pointer.y() as _,
};

let event = event::Event::WindowEvent {
window_id,
event: event::WindowEvent::Touch(
Expand Down

0 comments on commit 8fb7aa5

Please sign in to comment.