Tracing Input/Event Flow from Driver to APP
I am creating a driver for a custom piece of input hardware that will attempt to pass data to the kernel as an input, which the kernel will then pass up through the OS and expose to the app level via MotionEvent. Looking at some other device drivers, it looks like setting input events via some of the functions exposed in input.h of the Android 2.2 kernel (2.6.32) might do the trick, but I'd love to confirm this. Before starting down this path I am trying to get a better understanding of how existing inputs, be it from the screen, trackball, etc are passed up through the OS. The ultimate goal is to ensure that we can pass data from device to App-level before investing too much time going down this path.
Input header of linux kernel 2.6.32
http://lxr.free-electrons.com/source/include/linux/input.h?v=2.6.32
I've browsed through the Android class sources, but not sure where to l开发者_运维技巧ook to see how the OS instatiates the MotionEvent class that can be accessed via the onTouchEvent() method of the View class. Can anyone point me in the right direction in terms of how MotionEvent is populated by the OS and how the OS gets that data from the kernel?
Thanks,
Paul
The first place I would look at in in frameworks/base/libs/ui/EventHub.cpp, it will go through /dev/input to find the different input devices on your platform and what "kind" of input those are.
More...
Next step is in frameworks/base/services/jni/com_android_server_KeyInputQueue.cpp and frameworks/base/services/java/com/android/server/KeyInputQueue.java.
If all you are doing is implementing the input interface for a new piece of hardware, I don't think you need to do any further than that...
精彩评论