You are not logged in.
Hi,
I've been trying to make this piece of software work: https://bitbucket.org/rid77/evd/src/master/.
What it does is grab keyboard events with ioctl (as well as Video and Lid event but i do not care about those), do something with the event (function static bool handle_kb_event(void) for keyboard events) and forward the event by means of /dev/uinput (function static void forward_event(void)). The event is forwarded by writing to the virtual keyboard file descriptor: write(fd_vk, &ev, ev_size).
I modified the keyboard event handler to look like this (in the original code the function is a dummy one):
static bool handle_kb_event(void) {
/*
* if (ev.value == 0) {
return true;
}
*/
switch (ev.code) {
case KEY_BRIGHTNESSDOWN:
case KEY_BRIGHTNESSUP:
return handle_brightness_event();
}
return false;
}
This way, the brightness keys will control the brightness level.
The reason I want this code to work is so that the brightness keys will work in X as well as in the virtual desktop even without the need of being logged in (that was actually the coder's main motivation).
The code works in the virtual console (keypresses are intercepted, handled and reinjected) but it would not work in the DE. It seems that the reinjected events would not reach the X server, so keyboard stops working in X all the way. I cannot even type anything in the DE, that's why I know the reinjected events are not reaching X.
The virtual keyboard seems not to be detected by Xinput, I guess this is the reason it's not working.
Do you know why X migh not be able to detect my virtual keyboard? I read X will detect input devices based on udev rules as I have no configuration file in /etc/X11 (so default device detection by X is done). The device node is there (/dev/uinput) and it works in the virtual console, so this is no the problem.
Currently I'm running:
KERNEL: 5.11.16-arch1-1
DE: xfce 4.16
INPUT DEVICE LIBRARY: libinput 1.17.1
Thanks.
Last edited by ffcc (2021-05-20 20:40:38)
Offline
Xorg log?
(If you post it, please use code tags, https://bbs.archlinux.org/help.php#bbcode )
The keys are not handled by https://wiki.archlinux.org/title/Acpid ?
Offline
I checked the Xorg log and it turns out it was a permission problem.
...
[ 3164.543] (EE) systemd-logind: failed to take device /dev/input/event18: No such device
[ 3164.543] (**) Virtual Keyboard: always reports core events
[ 3164.543] (**) Option "Device" "/dev/input/event18"
[ 3164.543] (**) Option "_source" "server/udev"
[ 3164.543] (EE) xf86OpenSerial: Cannot open device /dev/input/event18
Permission denied.
[ 3164.543] (II) event18: opening input device '/dev/input/event18' failed (Permission denied).
[ 3164.543] (II) event18 - failed to create input device '/dev/input/event18'.
[ 3164.543] (EE) libinput: Virtual Keyboard: Failed to create a device for /dev/input/event18
...The virtual keyboard was created on /dev/input/event18 whose owner group is 'input'. So I added my user to the 'input' group and now it works!
Thank you so much.
Offline