@@ -326,6 +326,63 @@ pub enum Axis {
326326 Generic15 = ffi:: AMOTION_EVENT_AXIS_GENERIC_15 as i32 ,
327327 Generic16 = ffi:: AMOTION_EVENT_AXIS_GENERIC_16 as i32 ,
328328
329+ /// Axis constant: X gesture offset axis of a motion event.
330+ ///
331+ /// - For a touch pad, reports the distance that a swipe gesture has moved in the X axis, as a
332+ /// proportion of the touch pad's size. For example, if a touch pad is `1000` units wide, and
333+ /// a swipe gesture starts at `X = 500` then moves to `X = 400`, this axis would have a value
334+ /// of `-0.1`.
335+ ///
336+ /// These values are relative to the state from the last event, not accumulated, so developers
337+ /// should make sure to process this axis value for all batched historical events.
338+ ///
339+ /// This axis is only set on the first pointer in a motion event.
340+ #[ doc( alias = "AMOTION_EVENT_AXIS_GESTURE_X_OFFSET" ) ]
341+ GestureXOffset = ffi:: AMOTION_EVENT_AXIS_GESTURE_X_OFFSET as i32 ,
342+ /// Axis constant: Y gesture offset axis of a motion event.
343+ ///
344+ /// The same as [`Axis::GestureXOffset`], but for the Y axis.
345+ #[ doc( alias = "AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET" ) ]
346+ GestureYOffset = ffi:: AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET as i32 ,
347+ /// Axis constant: X scroll distance axis of a motion event.
348+ ///
349+ /// - For a touch pad, reports the distance that should be scrolled in the X axis as a result of
350+ /// the user's two-finger scroll gesture, in display pixels.
351+ ///
352+ /// These values are relative to the state from the last event, not accumulated, so developers
353+ /// should make sure to process this axis value for all batched historical events.
354+ ///
355+ /// This axis is only set on the first pointer in a motion event.
356+ #[ doc( alias = "AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE" ) ]
357+ GestureScrollXDistance = ffi:: AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE as i32 ,
358+ /// Axis constant: Y scroll distance axis of a motion event.
359+ ///
360+ /// The same as [`Axis::GestureScrollXDistance`], but for the Y axis.
361+ #[ doc( alias = "AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE" ) ]
362+ GestureScrollYDistance = ffi:: AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE as i32 ,
363+ /// Axis constant: pinch scale factor of a motion event.
364+ ///
365+ /// - For a touch pad, reports the change in distance between the fingers when the user is
366+ /// making a pinch gesture, as a proportion of that distance when the gesture was last
367+ /// reported. For example, if the fingers were `50` units apart and are now `52` units apart,
368+ /// the scale factor would be `1.04`.
369+ ///
370+ /// These values are relative to the state from the last event, not accumulated, so developers
371+ /// should make sure to process this axis value for all batched historical events.
372+ ///
373+ /// This axis is only set on the first pointer in a motion event.
374+ #[ doc( alias = "AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR" ) ]
375+ GesturePinchScaleFactor = ffi:: AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR as i32 ,
376+ /// Axis constant: the number of fingers being used in a multi-finger swipe gesture.
377+ ///
378+ /// - For a touch pad, reports the number of fingers being used in a multi-finger swipe gesture
379+ /// (with [`MotionClassification::MultiFingerSwipe`]).
380+ ///
381+ /// Since [`MotionClassification::MultiFingerSwipe`] is a hidden API, so is this axis. It is
382+ /// only set on the first pointer in a motion event.
383+ #[ doc( alias = "AMOTION_EVENT_AXIS_GESTURE_SWIPE_FINGER_COUNT" ) ]
384+ GestureSwipeFingerCount = ffi:: AMOTION_EVENT_AXIS_GESTURE_SWIPE_FINGER_COUNT as i32 ,
385+
329386 #[ doc( hidden) ]
330387 #[ num_enum( catch_all) ]
331388 __Unknown( i32 ) ,
@@ -573,7 +630,7 @@ impl MotionEvent {
573630 /// docs](https://developer.android.com/ndk/reference/group/input#amotionevent_getmetastate)
574631 #[ inline]
575632 pub fn meta_state ( & self ) -> MetaState {
576- unsafe { MetaState ( ffi:: AMotionEvent_getMetaState ( self . ptr . as_ptr ( ) ) as u32 ) }
633+ MetaState ( unsafe { ffi:: AMotionEvent_getMetaState ( self . ptr . as_ptr ( ) ) } as u32 )
577634 }
578635
579636 /// Returns the button state during this event, as a bitfield.
@@ -582,7 +639,7 @@ impl MotionEvent {
582639 /// docs](https://developer.android.com/ndk/reference/group/input#amotionevent_getbuttonstate)
583640 #[ inline]
584641 pub fn button_state ( & self ) -> ButtonState {
585- unsafe { ButtonState ( ffi:: AMotionEvent_getButtonState ( self . ptr . as_ptr ( ) ) as u32 ) }
642+ ButtonState ( unsafe { ffi:: AMotionEvent_getButtonState ( self . ptr . as_ptr ( ) ) } as u32 )
586643 }
587644
588645 /// Returns the time of the start of this gesture, in the `java.lang.System.nanoTime()` time
@@ -601,7 +658,7 @@ impl MotionEvent {
601658 /// docs](https://developer.android.com/ndk/reference/group/input#amotionevent_getedgeflags)
602659 #[ inline]
603660 pub fn edge_flags ( & self ) -> EdgeFlags {
604- unsafe { EdgeFlags ( ffi:: AMotionEvent_getEdgeFlags ( self . ptr . as_ptr ( ) ) as u32 ) }
661+ EdgeFlags ( unsafe { ffi:: AMotionEvent_getEdgeFlags ( self . ptr . as_ptr ( ) ) } as u32 )
605662 }
606663
607664 /// Returns the time of this event, in the `java.lang.System.nanoTime()` time base
@@ -619,7 +676,7 @@ impl MotionEvent {
619676 /// docs](https://developer.android.com/ndk/reference/group/input#amotionevent_getflags)
620677 #[ inline]
621678 pub fn flags ( & self ) -> MotionEventFlags {
622- unsafe { MotionEventFlags ( ffi:: AMotionEvent_getFlags ( self . ptr . as_ptr ( ) ) as u32 ) }
679+ MotionEventFlags ( unsafe { ffi:: AMotionEvent_getFlags ( self . ptr . as_ptr ( ) ) } as u32 )
623680 }
624681
625682 /// Returns the offset in the x direction between the coordinates and the raw coordinates
@@ -657,6 +714,26 @@ impl MotionEvent {
657714 pub fn y_precision ( & self ) -> f32 {
658715 unsafe { ffi:: AMotionEvent_getYPrecision ( self . ptr . as_ptr ( ) ) }
659716 }
717+
718+ /// Get the action button for the motion event. Returns a valid action button when the event is
719+ /// associated with a button press or button release action. For other actions the return value
720+ /// is undefined.
721+ #[ cfg( feature = "api-level-33" ) ]
722+ #[ doc( alias = "AMotionEvent_getActionButton" ) ]
723+ // TODO: Button enum to signify only one valid value?
724+ pub fn action_button ( & self ) -> ButtonState {
725+ ButtonState ( unsafe { ffi:: AMotionEvent_getActionButton ( self . ptr . as_ptr ( ) ) } as u32 )
726+ }
727+
728+ /// Returns the classification for the current gesture. The classification may change as more
729+ /// events become available for the same gesture.
730+ #[ cfg( feature = "api-level-33" ) ]
731+ #[ doc( alias = "AMotionEvent_getClassification" ) ]
732+ pub fn classification ( & self ) -> MotionClassification {
733+ u32:: try_from ( unsafe { ffi:: AMotionEvent_getClassification ( self . ptr . as_ptr ( ) ) } )
734+ . unwrap ( )
735+ . into ( )
736+ }
660737}
661738
662739/// A view into the data of a specific pointer in a motion event.
0 commit comments