2017-09-30 48 views
-1

我想让我的耳机按钮通过USB-C适配器工作,因为我的手机非常时髦,而且没有3.5mm插孔。Android:带USB-C适配器的耳机按钮

的按钮工作:使用的应用程序 “的KeyEvent显示”,我想通了

  • Vol+触发器的 “linux键码号码” 114
  • Vol-触发器的 “linux键码号码” 259
  • Play/Pause触发器 “Linux的关键码” 226

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

key 114 VOLUME_UP 
key 226 HEADSETHOOK 
key 259 VOLUME_DOWN 

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

我该怎么做?

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

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

+0

我尝试了以下文件名(每次重新启动):'Vendor_0000_Product_0003.kl','Vendor_0000_Product_0000.kl','Vendor_0001_Product_0001.kl',但没有任何工作。 – FatTony

+2

Stack Overflow是编程和开发问题的网站。这个问题似乎与题目无关,因为它不涉及编程或开发。请参阅帮助中心的[我可以询问哪些主题](http://stackoverflow.com/help/on-topic)。也许[超级用户](http://superuser.com/)或[Unix&Linux堆栈交换](http://unix.stackexchange.com/)会是一个更好的地方。 – jww

+0

@jww:你说得对。尽管如此,我已经找到了答案,而我只是为了记录而发布它。 – FatTony

回答

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

按照documentation,比0-9a-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 

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