1

我想让我的耳机按钮通过 USB-C 适配器工作,因为我的手机非常时髦和现代,它没有 3.5 毫米插孔。

按钮工作:使用应用程序“KeyEvent Display”,我发现

  • Vol+触发“linux key code number”114
  • Vol- 触发“linux key code number”259
  • Play/Pause 触发“linux key code number”226

通过更改/system/usr/keylayout/Generic.kl

key 114 VOLUME_UP
key 226 HEADSETHOOK
key 259 VOLUME_DOWN

我得到了耳机按钮的预期行为,但它干扰了手机上的常规按钮。这就是为什么我要创建一个特定于设备的配置文件。为此,我需要设备名称或供应商和产品 ID。(如android 文档中所述。)

我怎样才能做到这一点?

PS:“USB 设备信息”应用程序没有显示任何连接的设备。在这里您可以找到 的输出cat /proc/bus/input/devices。应用程序“Under the Hood”的相关输出:pastebin.com/kDeBNS0H

PPS:解决这个问题会给你额外的业力,因为解决方案会被输入到 LineageOS 中,为很多人解决问题!

4

1 回答 1

1

使用keytest应用程序,我发现耳机 (2) 的设备 ID 与常规音量按钮 (7 和 3) 的设备 ID 不同。现在,我只需要找出与设备 ID 对应的设备名称。这是我使用终端模拟器完成的:

$ 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"

根据文档,除 ,0-9和之外的所有字符都替换为. 因此,我创建了一个新文件:具有以下内容:a-zA-Z-_/system/usr/keylayout/msm8976-skun-snd-card_Button_Jack.kl

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

重新启动后,我得到了预期的行为!

于 2017-10-02T02:47:22.460 回答