Headphone Buttons and USB-C Adapters I owe a which doesn't have a 3.5mm headphone jack. Instead, it use my headphones with a USB-C to 3.5mm adapter. While the speakers and the mic work, the buttons don't. They're assigned incorrect functions. Play/Pause works, but Vol+ decreases the volume and Vol- selects things on the screen.

I wanna change this behaviour. Using the app "KeyEvent Display", I figured out that


Vol+ triggers "linux key code number" 114
Vol-  triggers "linux key code number" 259
Play/Pause  triggers "linux key code number" 226


Using the android documentation, I figured out that the buttons are all managed by /system/usr/keylayout/Generic.kl. I could get the expected behaviour by changing the following lines:

key 114 VOLUME_UP
key 226 HEADSETHOOK
key 259 VOLUME_DOWN


However, this interfered with the function of other buttons of my phone!

That's why I want to create a device-specific config file. For this, I need either the device name or the vendor and product IDs. (As explained in the android documentation.) However, I don't know to get those. The app "USB Device Info" didn't show any connected device. This is the shortened output of cat /proc/bus/input/devices:

I: Bus=0000 Vendor=0000 Product=0003 Version=2061
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
I: Bus=0000 Vendor=0000 Product=0000 Version=0000


Full output: here.

Relevant output of "Under the Hood": pastebin.com/kDeBNS0H

I made a file containing the above code and tried giving it the following file names (rebooting every time): Vendor_0000_Product_0003.kl, Vendor_0000_Product_0000.kl, Vendor_0001_Product_0001.kl, but nothing worked.

Can anyone help me?
Using the keytest app, I found out that the device ID of the headphones     (2) differed from the device ID of the regular volume buttons (7 and 3).
Now, I only had to find out the device name corresponding to the device ID. This I did using a terminal emulator:

$ su
$ getevent
add device 1: /dev/input/event7
name: "msm8976-skun-snd-card Headset Jack"
add device 2: /dev/input/event6
name: "msm8976-skun-snd-card Button Jack"
add device 3: /dev/input/event4
name: "qpnp_pon"
add device 4: /dev/input/event3
name: "qwerty"
could not get driver version for /dev/input/mouse1, Not a typewriter
add device 5: /dev/input/event2
name: "hbtp_vm"
add device 6: /dev/input/event1
name: "input_mt_wrapper"
could not get driver version for /dev/input/mice, Not a typewriter
add device 7: /dev/input/event5
name: "gpio-keys"
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 8: /dev/input/event0
name: "synaptics_dsx_s2"


According to the documentation, all characters other than 0-9, a-z, A-Z and - are replaced by _. Thus, I created a new file: /system/usr/keylayout/msm8976-skun-snd-card_Button_Jack.kl with the following content:

# Configuration file for LeEco Le 2 headphone buttons
key 114 VOLUME_UP
key 226 HEADSETHOOK
key 259 VOLUME_DOWN


After a reboot, I got the expected behaviour!