View MotionEvent and KeyEvent events, for developers
It will print events from joystick or gamepad axes and buttons, mouse hover events, and touchpad events, if you have such device.
It will also dump all events to logcat.
You may attach almost any mouse/keyboard/gamepad to your phone, if you have a proper cable, or connect Bluetooth mouse/keyboard, Android OS will recognize it.
Sources are at https://github.com/pelya/AndroidInputEventsLogger