As a hobby and to learn, whether this is possible, I'm trying to implement a simple first-person shooter for Android. Unfortunately, I ran into a dead end when dealing with mouse event processing.
I already have an onGenericMotion()
-Listener, which processes MotionEvent
objects generated by the system framework. The problem is, that MotionEvent
objects, generated by a mouse merely contain absolute coordinates, which tend to get "stuck", once the cursor reaches an edge or a corner of the screen. So I'm thinking relative mouse coordinates. While I found no feature on MotionEvent
that could deliver relative movements, using
adb shell su -- getevent -lt /dev/input/event3
and examining its output revealed that the kernel generates distinct relative motion events when one tries to move the cursor, even when it is stuck in a corner of the screen. So, given that my shooter has su access, I could obtain relative movements.
And now the question: A little bit of Google-fu revealed, that in many first-person shooters, the typical mouse movement is achieved by
- using relative mouse coordinates and
- by re-positioning the mouse cursor in the center of the screen.
So, the question really is two-folded:
- Is it possible to re-position the mouse cursor in the center of the screen on Android? and
- If not, can the typical "first-person-shooter" mouse movement be realised by using relative mouse movement information alone?