From: http://blog.sina.com.cn/s/blog_6e15a6010100mafz.html
Android does not support the mouse by default, but the Android system will be applied to many other places, such as tablets and TVs, which often require the mouse support.
Support principle: There are native touch events in Android, and various mouse events can be converted to various touch events, and the mouse event can be implemented by following the path related to the touch event. Note that after the screen is rotated, the mouse coordinates and other information must be processed by a program to be correct.
Overview of modifying files:
C ++ file:
Frameworks/base/include/UI/eventhub. h
Frameworks/base/libs/UI/eventhub. cpp
Java file:
Frameworks/base/CORE/Java/Android/View/rawinputevent. Java
Frameworks/base/services/Java/COM/Android/Server/inputdevice. Java
Frameworks/base/services/Java/COM/Android/Server/keyinputqueue. Java
Frameworks/base/services/Java/COM/Android/Server/windowmanagerservice. Java
File Function Description
Eventhub. h
Add mouse device Definition
Eventhub. cpp
Add the mouse type to the function open_device (const char * devicename)
Rawinputevent. Java
Add a mouse Device
Inputdevice. Java
Adds a mouse connection status flag.
Add the method generatemousemotion () in motionstate to convert the original mouse time
Motionevent event
Keyinputqueue. Java
Determine the mouse device in the event rawinputevent. ev_device_added, and add
In the event rawinputevent. ev_device_removed, dynamically determine the mouse to delete
In eV. type = rawinputevent. ev_key, right-click the left column
Add the mouse coordinate changes and wheel handling in Ev. type = rawinputevent. ev_rel.
Add mouse-related cleanup in recycleevent ()
Windowmanagerservice. Java
Draw and move the mouse on the interface.