Learning android4.0.3 source code with cainiao: Infrared Remote Control adaptation

Source: Internet
Author: User

In fact, this is the first task for the Linux driver in the company. It should be put on the Linux, but there are many infrared remote controls in Linux, however, there is no information on the Internet about the infrared remote control in Android. Just write it down to help you learn new things.
Here, I have debugged the IR driver in Linux. At first, it was registered as a char device. However, in Android, basically all the drivers are input devices, this is because the device node in the/dev/input/directory is enabled in eventhub. Therefore, if the remote control is used as the input device, it is not better. In fact, the input device also belongs to the char device, but she has implemented many mechanisms and only needs to report the data, simple and Convenient. Here is an assumption that we want to map the key codes of IR to the keyboard of Android. Can this be done directly? With this problem, we tested the infrared drive of the prepared IR. You can add power, volume, numbers, home, return, menu, and so on.
Unexpectedly, after the driver layer is well adapted, the android upper layer can be implemented. As a result, we have not gone into depth and implemented the functions. The following describes the implementation process.
The first step is to register as an input device. There are many online devices, followed by remote control decoding. The specific decoding process has been well implemented. After the interruption, because the decoding process is time-consuming, it will be placed in the lower half of the interruption to work, that is, in the work queue. Then, report the key value according to the implemented code. For example, if you press the power key

input_report_key(ir_dev, KEY_POWER, 1);input_report_key(ir_dev, KEY_POWER, 0);input_sync(ir_dev);

In this case, the android upper layer will know that this is the power key. If it is the volume plus key, it will be reported.

input_report_key(ir_dev, KEY_VOLUMEUP, 1);input_report_key(ir_dev, KEY_VOLUMEUP, 0);input_sync(ir_dev);

You can also control the volume when playing music.
The specific key_power, key_volumeup, and so on can be found in Linux/Linux. h in Linux. Basically, all operations are defined. All functions can be mapped to the android keyboard. At this point, you can use the remote control to control various Android functions.

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.