@@ -192,23 +192,23 @@ public boolean onGenericMotionEvent(@NonNull MotionEvent event) {
192192 boolean isMovementEvent =
193193 (event .getActionMasked () == MotionEvent .ACTION_HOVER_MOVE
194194 || event .getActionMasked () == MotionEvent .ACTION_SCROLL );
195- if (!isPointerEvent || !isMovementEvent ) {
196- return false ;
197- }
198-
199- int pointerChange = getPointerChangeForAction (event .getActionMasked ());
200- ByteBuffer packet =
201- ByteBuffer .allocateDirect (
202- event .getPointerCount () * POINTER_DATA_FIELD_COUNT * BYTES_PER_FIELD );
203- packet .order (ByteOrder .LITTLE_ENDIAN );
204195
205- // ACTION_HOVER_MOVE always applies to a single pointer only.
206- addPointerForIndex (event , event .getActionIndex (), pointerChange , 0 , IDENTITY_TRANSFORM , packet );
207- if (packet .position () % (POINTER_DATA_FIELD_COUNT * BYTES_PER_FIELD ) != 0 ) {
208- throw new AssertionError ("Packet position is not on field boundary." );
196+ if (isPointerEvent || isMovementEvent ) {
197+ int pointerChange = getPointerChangeForAction (event .getActionMasked ());
198+ ByteBuffer packet =
199+ ByteBuffer .allocateDirect (
200+ event .getPointerCount () * POINTER_DATA_FIELD_COUNT * BYTES_PER_FIELD );
201+ packet .order (ByteOrder .LITTLE_ENDIAN );
202+
203+ // ACTION_HOVER_MOVE always applies to a single pointer only.
204+ addPointerForIndex (event , event .getActionIndex (), pointerChange , 0 , IDENTITY_TRANSFORM , packet );
205+ if (packet .position () % (POINTER_DATA_FIELD_COUNT * BYTES_PER_FIELD ) != 0 ) {
206+ throw new AssertionError ("Packet position is not on field boundary." );
207+ }
208+ renderer .dispatchPointerDataPacket (packet , packet .position ());
209+ return true ;
209210 }
210- renderer .dispatchPointerDataPacket (packet , packet .position ());
211- return true ;
211+ return false ;
212212 }
213213
214214 // TODO(mattcarroll): consider creating a PointerPacket class instead of using a procedure that
@@ -252,6 +252,7 @@ private void addPointerForIndex(
252252 buttons = 0 ;
253253 }
254254
255+ int panZoomType = -1 ;
255256 boolean isTrackpadPan = ongoingPans .containsKey (event .getPointerId (pointerIndex ));
256257
257258 int signalKind =
@@ -264,7 +265,8 @@ private void addPointerForIndex(
264265 packet .putLong (motionEventId ); // motionEventId
265266 packet .putLong (timeStamp ); // time_stamp
266267 if (isTrackpadPan ) {
267- packet .putLong (getPointerChangeForPanZoom (pointerChange )); // change
268+ panZoomType = getPointerChangeForPanZoom (pointerChange );
269+ packet .putLong (panZoomType ); // change
268270 packet .putLong (PointerDeviceKind .TRACKPAD ); // kind
269271 } else {
270272 packet .putLong (pointerChange ); // change
@@ -355,7 +357,7 @@ private void addPointerForIndex(
355357 packet .putDouble (1.0 ); // scale
356358 packet .putDouble (0.0 ); // rotation
357359
358- if (isTrackpadPan && getPointerChangeForPanZoom ( pointerChange ) == PointerChange .PAN_ZOOM_END ) {
360+ if (isTrackpadPan && ( panZoomType == PointerChange .PAN_ZOOM_END ) ) {
359361 ongoingPans .remove (event .getPointerId (pointerIndex ));
360362 }
361363 }
@@ -396,12 +398,12 @@ private int getPointerChangeForAction(int maskedAction) {
396398 private int getPointerChangeForPanZoom (int pointerChange ) {
397399 if (pointerChange == PointerChange .DOWN ) {
398400 return PointerChange .PAN_ZOOM_START ;
399- } else if (pointerChange == PointerChange .MOVE ) {
401+ } else if (pointerChange == PointerChange .MOVE || pointerChange == PointerChange . HOVER ) {
400402 return PointerChange .PAN_ZOOM_UPDATE ;
401403 } else if (pointerChange == PointerChange .UP || pointerChange == PointerChange .CANCEL ) {
402404 return PointerChange .PAN_ZOOM_END ;
403405 }
404- throw new AssertionError ( "Unexpected pointer change" ) ;
406+ return - 1 ;
405407 }
406408
407409 @ PointerDeviceKind
0 commit comments