Skip to content

Commit 8124bc7

Browse files
committed
Add support for MotionEvent pointer history
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: #207
1 parent c3ed6ba commit 8124bc7

File tree

4 files changed

+347
-333
lines changed

4 files changed

+347
-333
lines changed

android-activity/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ fn android_on_create(state: &OnCreateState) {
5050
}
5151
```
5252

53+
- Support for `MotionEvent` history, providing higher fidelity input data for things like stylus input (`native-activity` + `game-activity` backends). ([#218](https://github.com/rust-mobile/android-activity/pull/218))
54+
55+
5356
### Changed
5457

5558
- rust-version bumped to 1.85.0 ([#193](https://github.com/rust-mobile/android-activity/pull/193), [#219](https://github.com/rust-mobile/android-activity/pull/219))

0 commit comments

Comments
 (0)