summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifei Zhan <git@zhan.science>2024-05-06 02:58:49 +0000
committerWez Furlong <wez@wezfurlong.org>2024-05-05 22:20:21 -0700
commit6448220c1146a08a80e8878aef5e17948660a580 (patch)
treeb87c2581728521f4698e925a607bc85753552f71
parent7e5a230ce09183596af53cc777d64d8520492c35 (diff)
update evdev-rs to 0.6.1
-rw-r--r--Cargo.lock34
-rw-r--r--Cargo.toml2
-rw-r--r--src/deviceinfo.rs10
-rw-r--r--src/remapper.rs10
4 files changed, 13 insertions, 43 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7547fb5..9120936 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -72,12 +72,6 @@ checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
-version = "0.1.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
-
-[[package]]
-name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
@@ -187,15 +181,14 @@ dependencies = [
[[package]]
name = "evdev-rs"
-version = "0.3.1"
+version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95f73dad019df28348aad51f059684bdf628822325c26d34fbe126e513369799"
+checksum = "9812d5790fb6fcce449333eb6713dad335e8c979225ed98755c84a3987e06dba"
dependencies = [
"bitflags",
"evdev-sys",
"libc",
"log",
- "nix",
]
[[package]]
@@ -311,7 +304,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
]
[[package]]
@@ -321,19 +314,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
-name = "nix"
-version = "0.13.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4dbdc256eaac2e3bd236d93ad999d3479ef775c863dbda3068c4006a92eec51b"
-dependencies = [
- "bitflags",
- "cc",
- "cfg-if 0.1.10",
- "libc",
- "void",
-]
-
-[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -596,12 +576,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
-name = "void"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
-
-[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -613,7 +587,7 @@ version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
dependencies = [
- "cfg-if 1.0.0",
+ "cfg-if",
"wasm-bindgen-macro",
]
diff --git a/Cargo.toml b/Cargo.toml
index fd7bc25..8761c63 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ authors = ["Wez Furlong"]
edition = "2018"
[dependencies]
-evdev-rs = "0.3"
+evdev-rs = "0.6.1"
anyhow = "1.0"
log = "0.4"
pretty_env_logger = "0.3"
diff --git a/src/deviceinfo.rs b/src/deviceinfo.rs
index 7239294..353f105 100644
--- a/src/deviceinfo.rs
+++ b/src/deviceinfo.rs
@@ -1,5 +1,5 @@
-use anyhow::{anyhow, bail, Context, Result};
-use evdev_rs::Device;
+use anyhow::{bail, Context, Result};
+use evdev_rs::{Device, DeviceWrapper};
use std::cmp::Ordering;
use std::path::PathBuf;
@@ -13,10 +13,8 @@ pub struct DeviceInfo {
impl DeviceInfo {
pub fn with_path(path: PathBuf) -> Result<Self> {
let f = std::fs::File::open(&path).context(format!("opening {}", path.display()))?;
- let mut input = Device::new().ok_or_else(|| anyhow!("failed to make new Device"))?;
- input
- .set_fd(f)
- .context(format!("assigning fd for {} to Device", path.display()))?;
+ let input = Device::new_from_file(f)
+ .with_context(|| format!("failed to create new Device from file {}", path.display()))?;
Ok(Self {
name: input.name().unwrap_or("").to_string(),
diff --git a/src/remapper.rs b/src/remapper.rs
index 9183ea8..5803ae4 100644
--- a/src/remapper.rs
+++ b/src/remapper.rs
@@ -1,6 +1,6 @@
use crate::mapping::*;
use anyhow::*;
-use evdev_rs::{Device, GrabMode, InputEvent, ReadFlag, TimeVal, UInputDevice};
+use evdev_rs::{DeviceWrapper, Device, GrabMode, InputEvent, ReadFlag, TimeVal, UInputDevice};
use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
use std::path::Path;
@@ -65,7 +65,7 @@ pub struct InputMapper {
fn enable_key_code(input: &mut Device, key: KeyCode) -> Result<()> {
input
- .enable(&EventCode::EV_KEY(key.clone()))
+ .enable(EventCode::EV_KEY(key.clone()))
.context(format!("enable key {:?}", key))?;
Ok(())
}
@@ -74,10 +74,8 @@ impl InputMapper {
pub fn create_mapper<P: AsRef<Path>>(path: P, mappings: Vec<Mapping>) -> Result<Self> {
let path = path.as_ref();
let f = std::fs::File::open(path).context(format!("opening {}", path.display()))?;
- let mut input = Device::new().ok_or_else(|| anyhow!("failed to make new Device"))?;
- input
- .set_fd(f)
- .context(format!("assigning fd for {} to Device", path.display()))?;
+ let mut input = Device::new_from_file(f)
+ .with_context(|| format!("failed to create new Device from file {}", path.display()))?;
input.set_name(&format!("evremap Virtual input for {}", path.display()));