Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Tracking mouse pointer movement

Assuming that I am using a generic mouse, is it possible to track the X and Y coordinates of the mouse pointer in android?

like image 922
John Erick Avatar asked Mar 28 '11 03:03

John Erick


People also ask

What is pointer in Mobile?

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.


1 Answers

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.

like image 182
Janus Kjempff Avatar answered Sep 27 '22 16:09

Janus Kjempff