Closed gujjwal00 closed 2 years ago
Good question. I've got no good answer though since the code has come a long way and passed through several hands. Reminds me of #162 a bit...
You were right! Pointer button handling feels like a deep rabbit hole. I will sidestep other parts, and focus on mouse button for this PR.
Can we require API-23 for full mouse support? Dedicated button press & release actions in MotionEvent are available since 23.
Can we require API-23 for full mouse support? Dedicated button press & release actions in MotionEvent are available since 23.
I guess so. If it's not too hard, you might want to add extra cases for SDK level 23 in the code, but if this gets too messy, let's bump the requiremt up to 23 (which is reasonably old IMO).
I guess so. If it's not too hard, you might want to add extra cases for SDK level 23 in the code, but if this gets too messy, let's bump the requiremt up to 23 (which is reasonably old IMO).
I was referring only to full mouse support. Existing logic (without middle button support) will continue to work on API <23. On API 23 and above, all mouse buttons will work correctly, assuming device manufacturers don't mess with events. We could probably make middle button work on API 21, but as you said, I doubt anyone will benefit from the effort.
This is ready for review/testing.
Summary:
Instead of going through processPointerEvent()
and messing with MotionEvent, different mouse actions are now directly handled in onGenericMotionEvent()
and converted to corresponding VNC actions. These actions are then passed to a new method processMouseEvent()
, which updates the button mask and sends the event to server.
Thanks, will have a look ASAP!
Finally found some time to revisit this again. I'll get a three-button Bluetooth mouse and test.
@gujjwal00 Finally could test this and while the middle mouse button works well, dragging (at least w/ button 1) is now broken. Any quick idea from your side on why this may happen?
Fixed the drag issue. I missed the ACTION_MOVE
handling in original patch.
One interesting thing to note here is that ACTION_MOVE
events from mouse are reported via onTouchEvent()
instead of onGenericMotionEvent()
.
Fixed the drag issue. I missed the
ACTION_MOVE
handling in original patch.One interesting thing to note here is that
ACTION_MOVE
events from mouse are reported viaonTouchEvent()
instead ofonGenericMotionEvent()
.
Thanks so much! And yes, it really seems Android input handling is a deep rabbit hole :-/
Fixes #189
Middle button is sent to the server, but currently two middle-clicks are sent for single mouse button click. I am about 80% sure this is caused by way GenericMotion events are translated to normal Touch events and processed in
processPointerEvent()
.My question is why are these events handled this way, instead of directly invoking
sendPointerEvent()
like scroll events?