Commit 8124bc7
committed
Add support for
This exposes `MotionEvent` pointer history via a `PointerHistoryIter`, got via
`Pointer::history()`, that yields `HistoricPointer`'s that give access to
sub-sample timestamps and axis values between events.
This adds consistent pointer history support for both the `native-activity` and
`game-activity` backends.
For example, historical pointer samples can be iterated like:
```rust
let num_pointers = motion_event.pointer_count();
for i in 0..num_pointers {
let pointer = motion_event.pointer_at_index(i);
println!(
"Pointer[{i}]: id={}, time={}, x={}, y={}",
pointer.pointer_id(),
motion_event.event_time(),
pointer.x(),
pointer.y(),
);
for sample in pointer.history() {
println!(
" History[{}]: x={}, y={}, time={:?}",
sample.history_index(),
sample.x(),
sample.y(),
sample.event_time()
);
}
}
```
The documentation clarifies that each pointer will have the same number of
historic samples, and the timestamps for corresponding samples will match.
The `PointerHistoryIter` supports forwards and/or backwards iteration and can
be queried for its `.len()`.
Fixes: #207MotionEvent pointer history1 parent c3ed6ba commit 8124bc7
4 files changed
Lines changed: 347 additions & 333 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
0 commit comments