Assuming that I am using a generic mouse, is it possible to track the X and Y coordinates of the mouse pointer in android?
Pointer capture is a feature available in Android 8.0 (API level 26) and later that provides such control by delivering all mouse events to a focused view in your app.
You need a OnGenericMotionListener
:
OnGenericMotion(...., MotionEvent me) {
if (me.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
}
api 14+
needed
[confirmed] Found me a tablet with usb mouse and can confirm this works for mouse movement. You WILL get flooded with messages, so simple operations or sleeping should be considered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With