Reputation:
I'm using bluetooth mouse for operating Android device, and I want to get the amount of movement of mouse. if the cursor goes out of screen, Android-OS Automatically changes cursor-coordinates into inside of screen. So I have problem.
When I using my PC, I move cursor-coordinates into a center of PC screen, and move mouse(by using hand), and (After x - Before x) is the amount of movement. it repeats at every frame. But the method of moving-cursor is not usable in not-Rooted Android(security problem).
Now, I get the amount of movements by this method. Mouse(connected PC) -> (bluetooth) -> PC -> (UDP) -> smartphone. But this is not speedy(Max about 3000ms latency)... And, bluetooth mouse is too small to solder(hack)... By using NDK, AMOTION_getRawX() is just return the coordinates on the screen...
So I want to get the amount of movement of mouse by Android application. Please help me.
Upvotes: 1
Views: 437
Reputation:
I solved it!!
I used "Android Terminal Emulator" app (to start ADB), and ADB command adb shell getevent -lt /dev/input/event5
.
event5
maybe change in your device, so check yours use adb shell getevent -i
It tells all event log contains REL_X
and REL_Y
.(real time)
There are amount of movement of mouse.
If the cursor is edge, no problem.
I converted this hexadecimal String value to int.
int d = (int)Long.parseLong(hexValue, 16);
Upvotes: 1