-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support input device hot-plugging and removal via udev #68
Conversation
backend/linux_input.c
Outdated
@@ -170,6 +260,12 @@ void *twin_linux_input_create(twin_screen_t *screen) | |||
twin_set_file(dummy, tm->fd, TWIN_READ, tm); | |||
#endif | |||
|
|||
/* Start event handling thread */ | |||
if (pthread_create(&tm->udev_thread, NULL, twin_linux_udev_thread, tm)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you create yet another thread for event handling? Can you deal with udev in the existing thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We indeed require only one thread, the udev
and evdev
are now handled by one pollfd
array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent. You have discovered how effective I/O multiplexing can be for optimizing the code.
3661174
to
e9166a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase the latest main
branch and mention the dependent package libuuid
in the top-level documentation.
Have you tested the proposed changes with more than one mouse device? |
udev (userspace /dev) is a device manager for the Linux kernel. By monitoring "add" and "remove" events from udev, we can dynamically update the event device file descriptors table to enable device hot-plugging and removal. Close sysprog21#61
README.md
Outdated
@@ -88,6 +88,9 @@ For the VNC backend, please note that it has only been tested on GNU/Linux, and | |||
$ tools/build-neatvnc.sh | |||
``` | |||
|
|||
For Linux framebuffer backend, install `libudev`, and `libuuid`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary ,
(comma). That is,
For Linux framebuffer backend, install
libudev
andlibuuid
:
I adjusted the change to prevent the event device thread from reopening all file descriptors whenever |
Thank @shengwen-tw for contributing! |
Overview
udev
(userspace /dev
) is a device manager for the Linux kernel. By monitoringadd
andremove
events fromudev
, we can dynamically update the event device file descriptors table to enable device hot-plugging and removal.Prerequisites
To test the modified code, compile
mado
with theLinux framebuffer
backend.Test procedure
Ctrl+Alt+Fn
(e.g.,Ctrl+Alt+F3
) and then execute:Ctrl+Alt+F1
.