13

Kind of related to this.

On a rooted Android phone, how do I set the position of the mouse from within an app. (The mouse is a bluetooth mouse.)

The other question mentioned it's possible with root or ADB, but not how.

Community
  • 1
  • 1
Jeroen
  • 413
  • 1
  • 4
  • 16

2 Answers2

4

You can use this library to inject events: https://github.com/radhoo/android-event-injector

And add mouse move event method in Events.java, below is a example to send a relative mouse move event:

    public int sendMouseMove(int deltaX, int deltaY) {
        intSendEvent(m_nId, EV_REL, REL_X, deltaX);
        intSendEvent(m_nId, 0, 0, 0);
        intSendEvent(m_nId, EV_REL, REL_Y, deltaY);
        intSendEvent(m_nId, 0, 0, 0);
        return 0;
    }
bladefury
  • 825
  • 6
  • 16
1

A workaround, until android gets fixed, might be to have the app connect to localhost as adb client and issue adb commands.

On the adb shell you can open /dev/input/uevent device to write mouse events include, absolute position

Set mouse position in software

Community
  • 1
  • 1
zproxy
  • 3,509
  • 3
  • 39
  • 45