Hexdump/dev/hidraw0 can see the bare stream that the Usbhid device is transmitting.
such as: Press the input key
003ae60 0000 0096 8000 006b 0000 0000 0000 0000*003aea0 0000 0086 8000 0000 0000 0000 0000 0000*
The previous estimate is the bitstream Head (003AE60), and press (0096), release (8000) and other information, the identification key valid information is (006B)
006B is actually the index value, the following table will look for key values sent to Android, such as: 6b corresponding to 186
drivers/hid/hid-input.cstatic const unsigned char hid_keyboard[256] = {0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 , 28, 1, 14, 15, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106, 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71, 72 , 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190, 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113, 115,114,unk,unk,unk,121,unk, 89, 93,124, 92, 94, 95 , Unk,unk,unk, 122,123, 85,unk,unk,unk,unk,unk,unk,unk,111,unk,unk,unk, Unk,unk,unk,unk,unk,unk,unk,unk,unk, Unk,unk,unk,unk,unk,unk,unk, Unk,unk,unk,unk,unk,unk,179,180,unk,unk,unk,unk,unk,unk,unk,unk, Unk,unk,unk,unk, Unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk, Unk,unk,unk,unk,unk,unk,unk,unk,111,unk, Unk,unk,unk,unk,unk,unk, 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113, 150,158,159,128,136,177,1 78,176,142,152,173,140,unk,unk,unk,unk};
Messages received on the Android layer can be obtained via getevent
/dev/input/event2:0004 0004 0007006b/dev/input/event2:0001 00ba 00000001/dev/input/event2:0000 0000 00000000/dev/ input/event2:0004 0004 0007006b/dev/input/event2:0001 00ba 00000000/dev/input/event2:0000 0000 00000000
Can see 006b this is the HID device sent over the code value, BA is 186, the Linux layer to get the key value
After Android obtains the key value through the Event2, the next step is the standard Android key mapping process.
The first is to view the device information and mapping table of the/DEV/INPUT/EVENT2 device file.
Dumpsys Input 2: Haier Smart TV RF Receiver classes:0x80000023 Path:/dev/input/event2 descriptor:4c674c2e6733e157d6ab300ee6f2c3dc1245e649 location:usb-rtk-3/input4 controllernumber:0 UniqueId: identifier:bus=0x0003, vendor=0x1a1d, product=0x00e0, version=0x0100 keylayoutfile:/system/usr/ KEYLAYOUT/VENDOR_1A1D_PRODUCT_00E0.KL keycharactermapfile:/system/usr/keychars/generic.kcm ConfigurationFile: havekeyboardlayoutoverlay:false
Device information is: VENDOR=0X1A1D, product=0x00e0
So according to our previous key mapping process analysis, we will first find out if there is a VENDOR_[VENDOR]_PRODUCT_[PRODUCT].KL
Here get/system/usr/keylayout/vendor_1a1d_product_00e0.kl, source directory in Frameworks/base/data/keyboards/vendor_1a1d_product_ 00e0.kl
View the mapping table file and discover
Key 186 Tv_input
That will eventually send Keycode_tv_input to the APK.
The last thing to note is that if tv_input is not defined in Keycodelabel, it will be an error parsing vendor_1a1d_product_00e0.kl this mapping table file, resulting in Event2 GENERIC.KL
Therefore, there must be tv_input in the Keycodelabel:
{"Tv_input", 178},
[Android] HID device Key Flow Brief