Android Bluetooth keyboard debugging record

Source: Internet
Author: User

Situation:
The Android tablet can be connected to a Bluetooth keyboard and can input text. Most buttons can respond normally. However, a few buttons do not respond, such as ESC, lock screen, and search key.

Debugging steps:
1. Open the debugging information entered by the keyboard to obtain the scan code for the key:
Frameworks/base/services/input/inputreader. cpp

# Define debug_raw_events 1 // 0 is changed to 1. Open the debugging information.

In method inputdevice: Process (), you can see the following print information:

#if DEBUG_RAW_EVENTS        LOGD("Input event: device=%d type=0x%04x scancode=0x%04x "                "keycode=0x%04x value=0x%08x flags=0x%08x",                rawEvent->deviceId, rawEvent->type, rawEvent->scanCode, rawEvent->keyCode,                rawEvent->value, rawEvent->flags);#endif

 

2. compile the system source code, upgrade the firmware, connect to the Bluetooth keyboard, click the ESC key, and observe the scancode value in the printed message. The corresponding scancode is 0x000000ac, that is, 172, in this way, the scan code is obtained.

3. view the input device information in the ADB shell:
Shell @ Android:/$ CAT/proc/bus/input/devices

There is information about the Bluetooth keyboard:

I: Bus = 0005 vendor = 05ac Product = 0239 version = 0001n: Name = "Bluetooth 3.0 keyboard"... (omitted)

Here, we will focus on vendor = 05ac Product = 0239 according to the corresponding rules:
Vendor _ <vendor> _ product _ <product>. KL
The file vendor_05ac_product_0239.kl should be available in/system/usr/keylayout,
Check whether the file exists:

shell@android:/ $ ls /system/usr/keylayoutls /system/usr/keylayoutACCDET.klAVRCP.klGeneric.klVendor_045e_Product_028e.klVendor_046d_Product_c216.klVendor_046d_Product_c294.klVendor_046d_Product_c299.klVendor_046d_Product_c532.klVendor_054c_Product_0268.klVendor_05ac_Product_0239.klVendor_22b8_Product_093d.klmtk-kpd.klqwerty.kl

There are many key- ing configuration files for input devices. vendor_05ac_product_0239.kl is the conversion table for the Bluetooth keyboard.

4. Because the ESC response is required to be a back key, find the definition of the back key in generic. KL:

shell@android:/ $ cat /system/usr/keylayout/Generic.kl | busybox grep BACKcat /system/usr/keylayout/Generic.kl | busybox grep "BACK "key 158   BACK              WAKE_DROPPED

5. First extract the file vendor_05ac_product_0239.kl to your computer:

e:\android\doc\bluetooth keyboard\keylayout>adb pull /system/usr/keylayoutpull: building file list...pull: /system/usr/keylayout/qwerty.kl -> ./qwerty.klpull: /system/usr/keylayout/mtk-kpd.kl -> ./mtk-kpd.klpull: /system/usr/keylayout/Vendor_22b8_Product_093d.kl -> ./Vendor_22b8_Product_093d.klpull: /system/usr/keylayout/Vendor_05ac_Product_0239.kl -> ./Vendor_05ac_Product_0239.klpull: /system/usr/keylayout/Vendor_054c_Product_0268.kl -> ./Vendor_054c_Product_0268.klpull: /system/usr/keylayout/Vendor_046d_Product_c532.kl -> ./Vendor_046d_Product_c532.klpull: /system/usr/keylayout/Vendor_046d_Product_c299.kl -> ./Vendor_046d_Product_c299.klpull: /system/usr/keylayout/Vendor_046d_Product_c294.kl -> ./Vendor_046d_Product_c294.klpull: /system/usr/keylayout/Vendor_046d_Product_c216.kl -> ./Vendor_046d_Product_c216.klpull: /system/usr/keylayout/Vendor_045e_Product_028e.kl -> ./Vendor_045e_Product_028e.klpull: /system/usr/keylayout/Generic.kl -> ./Generic.klpull: /system/usr/keylayout/AVRCP.kl -> ./AVRCP.klpull: /system/usr/keylayout/ACCDET.kl -> ./ACCDET.kl13 files pulled. 0 files skipped.262 KB/s (27925 bytes in 0.104s)

In vendor_05ac_product_0239.kl, add one line:

key 172   BACK              WAKE_DROPPED

6. After the modification is complete, Remount the system partition to read/write, push the file to the machine, restart the machine, and check whether the modification is successful:

e:\android\doc\bluetooth keyboard\keylayout>adb remounte:\android\doc\bluetooth keyboard\keylayout>adb push Vendor_05ac_Product_0239.kl /system/usr/keylayout/e:\android\doc\bluetooth keyboard\keylayout>adb reboot

7. In the same way, after adding the lock screen key and search key and verifying the key, you can add the modification to the source code, re-compile it, and upgrade the firmware Verification:

frameworks/base/data/keyboards/Vendor_05ac_Product_0239.kl

Do not forget to remove debugging information after verification.

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.