SOLUTION of internal keyboard failure in ArchLinux after upgrading
Circumstance
- description
After anyay -Syu
update, the internal keyboard didn’t work,but for the power button,sleep button,and two brightness adjusting keys using Fn(Fn+F5,Fn+F6) - System information:
- ArchLinux stable 5.8.8
- Xorg 1.20.9-2
- lightdm 1.30.0-4
- Xfce4 4.14.2-2
Problem probe
- First:hardware check
Run into a console tty using Ctrl+Alt+F2,randomly type some words,if worked properly,there is nothing wrong with the hardware. - Second:Xorg Driver check
the latest xorg has abondoned the xf86-input-keyboard driver,taking the new xf86-input-evdev and xf86-input-libinput driver,the latter is installed with xorg-server automatically serving as a dependency item,while I recommand you to install both of them bysudo pacman -S xf86-input-evdev
because the xf86-input-libinput does better in touchpad guesture.
then,let’s go teseing our driver
first copy the following codes and save it as a python scriptkeytest.py
,then make it executable bysudo chmod +x keytest.py
#!/usr/bin/python
import struct
keyboardFile = open('/dev/input/event4','rb')
data = keyboardFile.read(24)
print(struct.unpack('4IHHI',data))
keyboardFile.close()
second execute the script by sudo ./keytest.py
and press key Q of your internal keyboard
you will get an output sequence like this:
(1599824380, 0, 226140, 0, 4, 4, 16)
(1599824380, 0, 226140, 0, 1, 16, 1)
(1599824380, 0, 226140, 0, 0, 0, 0)
(1599824380, 0, 358344, 0, 4, 4, 16)
(1599824380, 0, 358344, 0, 1, 16, 0)
(1599824380, 0, 358344, 0, 0, 0, 0)
NOTE :
the value 16
is the keycode python receive from device file,which we will examine it later by grep "KEY_Q" /usr/include/linux/input-event-codes.h
.
third get the predefined keycode of Q by grep "KEY_Q" /usr/include/linux/input-event-codes.h
,which outputs like this:
#define KEY_Q 16
#define KEY_QUESTION 214
if keycode matches,the driver is ready for use.
- Third:Xorg configure file
- generate a new x configure file
if you cannot find axorg.conf
file in/etc/X11
or/etc
like me, you can simply regenerate a new skeleton bysudo Xorg :0 -configure
- copy the configure file to
/etc/X11
or/etc
:
sudo cp /root/xorg.conf.new /etc/X11/xorg.conf
- modify the configure file to make the driver work
- determine which device file your internal keyboard corresponds to by
sudo cat /proc/bus/input/devices
,your output may contain some lines like this:
- determine which device file your internal keyboard corresponds to by
- generate a new x configure file
I: Bus=0011 Vendor=0001 Product=0001 Version=ab41
N: Name="AT Translated Set 2 keyboard"
P: Phys=isa0060/serio0/input0
S: Sysfs=/devices/platform/i8042/serio0/input/input4
U: Uniq=
H: Handlers=sysrq kbd event4 leds
B: PROP=0
B: EV=120013
B: KEY=402000000 3803078f800d001 feffffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=7
which implies the device file of your internal keyboard is /dev/input/event4
- modify the xorg configure file
sudo vim /etc/X11/xorg.conf
then find a block like this:
modify it to the pattern as follows:Section "InputDevice" Identifier "Keyboard0" Driver "kbd" EndSection
Section "InputDevice" Identifier "Keyboard0" Driver "evdev" Option "Device" "/dev/input/event4" EndSection
- Bingo Enjoy your Arch!
- ending: I’m sorry for my poor English.Thanks for reading.