8,460
个编辑
更改
→24pin扩展板上的2个LRADC按键的使用方法
<li><p>24pin扩展板上有两个LRADC按键,位置如下图所示:</p>
<p>[[File:media/image106.png]]</p></li>
<li><p>在Linux系统中,KEY1和KEY2默认设置的键值为</p></li></ol>
{| class="wikitable" style="width:800px;text-align: center;"
|-
| '''Linux内核'''
| '''KEY_ENTER,即回车键'''
|}
</ol>
<ol start="3" style="list-style-type: decimal;">
<li><p>通过'''evtest'''命令我们可以查看下KEY1和KEY2按下后上报的键值</p>
<ol style="list-style-type: lower-alpha;">
<li><p>linux5.4</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepizero2w:~$ '''evtest'''</p>
<p>No device specified, trying to scan all of /dev/input/event*</p>
<p>Not running as root, no devices may be available.</p>
<p>Available devices:</p>
<p>'''/dev/input/event0event<span style="color: #FF0000">0</span>: <span style="color:#FF0000">sunxi-keyboard</span>'''</p>
<p>/dev/input/event1: sunxi-ir</p>
<p>/dev/input/event2: axp2101-pek</p>
<p>/dev/input/event6: PixArt USB Optical Mouse</p>
<p>/dev/input/event7: BRLTTY 6.3 Linux Screen Driver Keyboard</p>
<p>Select the device event number [0-7]: '''<span style="color:#FF0000">0 </span> #需要输入sunxi-keyboard对应的序号'''</p>
<p>Input driver version is 1.0.1</p>
<p>Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100</p>
<p>Input device name: "sunxi-keyboard"</p>
<p>Supported events:</p>
:<p>Event type 0 (EV_SYN)</p>:<p>Event type 1 (EV_KEY)</p>::<p>Event code 2 (KEY_1)</p>::<p>Event code 28 (KEY_ENTER)</p>
<p>Properties:</p>
<p>Testing ... (interrupt to exit)</p>
<p>'''#下面是按下KEY1和KEY2后上报的键值'''</p>
<p>Event: time 1693555298.132314, type 1 (EV_KEY), code 2 (KEY_1), value 1</p>
<p>Event: time 1693555298.132314, -------------- SYN_REPORT ------------</p>
<p>Event: time 1693555298.601042, -------------- SYN_REPORT ------------</p>
<p>Event: time 1693555298.710415, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0</p>
<p>Event: time 1693555298.710415, -------------- SYN_REPORT ------------</p>|}</li>
<li><p>linux6.1</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepizero2w:~$ evtest</p>
<p>No device specified, trying to scan all of /dev/input/event*</p>
<p>Available devices:</p>
<p>/dev/input/event0: axp20x-pek</p>
<p>'''/dev/input/event1event<span style="color: #FF0000">1</span>: <span style="color:#FF0000">5070800.lradc</span>'''</p>
<p>/dev/input/event2: SONiX USB Keyboard</p>
<p>/dev/input/event3: SONiX USB Keyboard Consumer Control</p>
<p>/dev/input/event5: PixArt USB Optical Mouse</p>
<p>/dev/input/event6: sunxi-ir</p>
<p>Select the device event number [0-6]: '''<span style="color:#FF0000">1 </span> #需要输入5070800.lradc对应的序号'''</p>
<p>Input driver version is 1.0.1</p>
<p>Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100</p>
<p>Input device name: "5070800.lradc"</p>
<p>Supported events:</p>
:<p>Event type 0 (EV_SYN)</p>:<p>Event type 1 (EV_KEY)</p>::<p>Event code 2 (KEY_1)</p>::<p>Event code 28 (KEY_ENTER)</p>
<p>Properties:</p>
<p>Testing ... (interrupt to exit)</p>
<p>'''#下面是按下KEY1和KEY2后上报的键值'''</p>
<p>Event: time 1694075818.810877, type 1 (EV_KEY), code 2 (KEY_1), value 1</p>
<p>Event: time 1694075818.810877, -------------- SYN_REPORT ------------</p>
<p>Event: time 1694075819.536128, -------------- SYN_REPORT ------------</p>
<p>Event: time 1694075819.705009, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0</p>
<p>Event: time 1694075819.705009, -------------- SYN_REPORT ------------</p>|}</li></ol>
</li>
<li><p>如果需要修改KEY1和KEY2按下后上报的按键值,可以使用下面的方法:</p>
<ol style="list-style-type: lower-alpha;">
<li><p>在'''/usr/src/'''路径下有一个'''sun50i-h618-lradc-keys.dts'''文件,我们可以通过它来定义KEY1和KEY2为想要的按键值</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepizero2w:~$ '''cd /usr/src/'''</p>
<p>orangepi@orangepizero2w:/usr/src$ '''ls *.dts'''</p>
<p>sun50i-h618-lradc-keys.dts</p>|}</li>
<li><p>linux5.4系统'''sun50i-h618-lradc-keys.dts'''文件的内容如下所示:</p>
<ol style="list-style-type: lower-alpha;">
<li><p>KEY1对应:修改'''key0 = <600 > 2>;'''中的2为想要的按键值对应的数字</p></li>
<li><p>KEY2对应:修改'''key1 = <800 > 28>;'''中的28为想要的按键值对应的数字</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepizero2w:/usr/src$ '''sudo vim sun50i-h618-lradc-keys.dts'''</p>
<p>/dts-v1/;</p>
<p>/plugin/;</p>
<p>/ {</p>
:<p>fragment@0 {</p>::<p>target = <&keyboard>;</p> ::<p>__overlay__ {</p>:::<p>status = "okay";</p> :::<p>'''key0 = <600 <span style="color:#FF0000">2</span>>;'''</p>:::<p>'''key1 = <800 <span style="color:#FF0000">28</span>>;'''</p>::<p>};</p>:<p>};</p>
<p>};</p>
</li>
<li><p>linux6.1系统'''sun50i-h618-lradc-keys.dts'''文件的内容如下所示:</p>
<li><p>KEY1对应:修改'''linux,code = > <2>;'''中的2为想要的按键值对应的数字</p></li>
<li><p>KEY2对应:修改'''linux,code = > <28>;'''中的28为想要的按键值对应的数字</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepizero2w:/usr/src$ '''sudo''' '''vim''' '''sun50i-h618-lradc-keys.dts'''</p>
<p>/dts-v1/;</p>
<p>/plugin/;</p>
<p>/ {</p>
:<p>fragment@0 {</p>::<p>target = <&r_lradc>;</p> ::<p>__overlay__ {</p>:::<p>status = "okay";</p> :::<p>button-500 {</p>::::<p>label = "KEY_1";</p>::::<p>'''linux,code = <<span style="color:#FF0000">2</span>>;'''</p>:::<p>};</p> :::<p>button-800 {</p>::::<p>label = "KEY_ENTER";</p>::::<p>'''linux,code = <<span style="color:#FF0000">28</span>>;'''</p>:::<p>};</p>::<p>};</p>:<p>};</p>
<p>};</p>
</li>
<li><p>可以设置的按键值请参考下'''input-event-codes.h'''头文件中的宏定义,其在内核源码中的路径为:</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orange-pi-5.4-sun50iw9/include/uapi/linux/input-event-codes.h</p>
<p>orange-pi-6.1-sun50iw9/include/uapi/linux/input-event-codes.h</p>|}</li>
<li><p>修改完后,再使用'''orangepi-add-overlay'''命令让sun50i-h618-lradc-keys.dts配置添加到系统中</p>
{| class="wikitable" style="width:800px;"
|-
|
<p>orangepi@orangepizero2w:/usr/src$ '''sudo orangepi-add-overlay sun50i-h618-lradc-keys.dts'''</p>
<p>Compiling the overlay</p>
<p>Copying the compiled overlay file to /boot/overlay-user/</p>
<p>Reboot is required to apply the changes</p>|}</li>
<li><p>然后重启系统自定义的按键值就会生效了</p></li></ol>
</li></ol>