1

I want to make my headphone buttons work through an USB-C adapter because my phone is so hip and modern that it doesn't have a 3.5mm jack.

The buttons work: 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

By changing /system/usr/keylayout/Generic.kl to

key 114 VOLUME_UP
key 226 HEADSETHOOK
key 259 VOLUME_DOWN

I got the expected behaviour of the headset buttons, but it interfered with the regular buttons on the 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.)

How can I do this?

PS: The app "USB Device Info" didn't show any connected devices. Here you can find the output of cat /proc/bus/input/devices. Relevant output of the app "Under the Hood": pastebin.com/kDeBNS0H

PPS: Solving this problem will give you extra karma, because the solution will be fed into LineageOS, solving the problem for many people!

MrTomRod
  • 345
  • 2
  • 16
  • I tried the following file names (rebooting every time): `Vendor_0000_Product_0003.kl`, `Vendor_0000_Product_0000.kl`, `Vendor_0001_Product_0001.kl`, but none worked. – MrTomRod Sep 30 '17 at 11:45
  • 2
    Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Sep 30 '17 at 14:21
  • @jww: you're right. i've found an answer, though, and i'm posting it just for the record. – MrTomRod Oct 02 '17 at 02:24
  • How does one downvote a comment? :) – tink Oct 02 '17 at 02:55
  • which comment? jww's is legitimate. (why) did you downvote my question and my solution? – MrTomRod Oct 02 '17 at 03:19

1 Answers1

1

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!

MrTomRod
  • 345
  • 2
  • 16