Added mouse support for Android

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.