Getting started with android4.0 multi-point touch screen

Source: Internet
Author: User
Document directory
  • 3.1 Kernel
1 Preface

First, let's talk nonsense. Csdn has been registered for a while, but has never published a blog on it. previous articles published on other blogs cannot be retrieved because the password has been forgotten. OK. Start to enter the topic.
I am also a beginner, and soon after the entry. Therefore, it should be more suitable for beginners to learn.

2. Overall View

We divide Android into three parts: kernel, framework, and app. Because the software runs on the basis of hardware, the touch screen on the hardware must support multi-point touch. In theory, software can support a maximum of 256 fingers, but the hardware restrictions, even if you want to report more fingers than the number of hardware, we can only ignore the upper layer. For the framework, Google itself supports multi-touch, but due to patent problems, there may be many hide APIs. However, because Android is an open platform, we can develop it on this basis.
My previous study was conducted in 2.3, and there was a period of stagnation due to the company's work tasks. Now let's try again and find eventhub. CPP and inputreader. CPP has changed a lot. Looking at the software, I still felt a little flustered. Who made me do this? I quickly changed my mind into a battle.
Since we have a general understanding of the above, we have taken a general view of the global, and the rest of the task is to break through each other. We can't lag behind when the CPUs are all multi-core. Let's operate on multiple threads. Read the Framework Code when you are tired of checking the kernel knowledge. If you are tired of reading the code, you can see how the application is implemented.

3. Details: 3.1 Kernel

For touch screen drivers, we simply divide them into two main parts: registration and reporting.

3.1.1 Registration

The single touch information is carried by ABS and sent in a certain order, such as btn_touch, abs_x, abs_y, and sync. The multi-point touch information is carried by abs_mt and sent in a certain order, such as abs_mt_position_x and abs_mt_position_y. Then, a syn_mt_report event is generated by calling input_mt_sync () to mark the end of a vertex, tell the recipient to receive the information of the current finger and prepare to receive the touch information of other fingers. Finally, call the input_sync () function to report the start action of the touch information and tell the receiver to start receiving a series of multi-touch information.

3.1.2 Report

The Protocol defines a series of abs_mt events. These events are divided into several categories, allowing only one part to be applied, and a centralized package of the minimum multi-touch event

Include abs_mt_touch_major, abs_mt_position_x, and abs_mt_position_y to implement multi-point touch. If the device supports the abs_mt_width_major event, this event can provide the contact area for finger touch. Information such as the touch direction can be provided by abs_mt_touch_minor, abs_mt_width_minor and abs_mt_orientation. Abs_mt_tool_type indicates the type of a touch device, such as a hand, pen, or other device. Finally, some devices may support abs_mt_tracking_id, which is used to support hardware tracking of Multi-Point information, that is, the line to which the point belongs.

3.2 framework

In Android 4.0, the event input status has been improved. in adroid2.3.5, it is under frameworks/base/libs/UI, and under android4.0, it is under frameworks/base/services/input, and it has its own position, as in the kernel, you have your own portal.
In this folder, two files are studied: eventhub. cpp and inputreader. cpp. Eventhub. cpp is used to scan and identify devices. Inputreader. cpp processes the raw data reported by the device.
For app developers, the main data is obtained through motionevent and Java. Motionevent. Java communicates with the underlying layer through the JNI mechanism.
Frameworks/base/CORE/Java/Android/View/motionevent. Java --- JNI --> frameworks/base/CORE/JNI/android_view_motionevent.cpp
This part can refer to blog: http://blog.csdn.net/myarrow/article/details/7091061

3.3 app

I have not implemented this part yet. Refer to the Code touchexample. Java & touchexampleactivity. Java

Since the experiment has not yet been conducted, many studies are not very in-depth. I will add real notes for the experiment process in the future. I have the habit of handwriting, and Chinese people can leave the experiment at any time!

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.