1
0

use libudev to handle device disconnect/reconnect

This change has substantially bumped up the daemon's overall robustness,
as the code now ensures that the controller will only start once the
/dev/input/eventXX file is set up, which was causing all sorts of issues
in the past.

Additionally, this change enables the daemon to run as a proper
background task that _doesn't_ constantly die / need to be restarted,
which removes the need for any janky udev "on add" rules, and instead, a
simple systemd user service will suffice.
This commit is contained in:
Daniel Prilik
2020-11-06 00:22:56 -05:00
parent 559a28c2d7
commit f7a261cb8a
11 changed files with 555 additions and 276 deletions

34
Cargo.lock generated
View File

@@ -230,6 +230,16 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "libudev-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324"
dependencies = [
"libc",
"pkg-config",
]
[[package]]
name = "lock_api"
version = "0.4.1"
@@ -269,6 +279,18 @@ dependencies = [
"libc",
]
[[package]]
name = "nix"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85db2feff6bf70ebc3a4793191517d5f0331100a2f10f9bf93b5e5214f32b7b7"
dependencies = [
"bitflags 1.2.1",
"cc",
"cfg-if 0.1.10",
"libc",
]
[[package]]
name = "notify-rust"
version = "4.0.0"
@@ -451,9 +473,11 @@ dependencies = [
"evdev-rs",
"hidapi",
"lazy_static",
"nix",
"notify-rust",
"parking_lot",
"signal-hook",
"udev",
]
[[package]]
@@ -487,6 +511,16 @@ dependencies = [
"winapi",
]
[[package]]
name = "udev"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "048df778e99eea028c08cca7853b9b521df6948b59bb29ab8bb737c057f58e6d"
dependencies = [
"libc",
"libudev-sys",
]
[[package]]
name = "unicode-xid"
version = "0.0.4"