Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving mouse pointer on Android screen programmatically

I am developing an Android application where I would like to move the "mouse" pointer/cursor on an Android tablet. I know this is possible because when I connect a mouse (USB or BT) to an Android tablet (Honeycomb+), a cursor appears and I can interact with the tablet using the mouse only. I would like to control that mouse from Java on the Tablet.

I already have a second device that can communicate the tablet and which can stream pointer coordinates to it.

And no I can't use bluetooth. The second device that I'm using has WiFi but no ability to drive BlueTooth. My thought is that there must be a way to move the mouse pointer.

like image 419
Hephaestus Avatar asked Oct 08 '11 06:10

Hephaestus


2 Answers

It is possible to control the mouse pointer in Android programmatically via the AccessibilityService API.

Here is an example app in the play store: EVA Facial Mouse app

Here is a github repository for controlling the mouse pointer via WiFi (API level 21): chetbox/android-mouse-cursor

I have forked and updated the latter repo to API level 27: Ra-Na/android-mouse-cursor

like image 71
Rainer Glüge Avatar answered Sep 19 '22 15:09

Rainer Glüge


I would like to control that mouse from Java on the Tablet.

This is not possible, except via firmware or specialized instrumentation code. Ordinary SDK applications cannot inject input events this way.

like image 38
CommonsWare Avatar answered Sep 18 '22 15:09

CommonsWare