Skip to content

Commit

Permalink
update evdev-rs to 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhanYF authored and wez committed May 6, 2024
1 parent 7e5a230 commit 6448220
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 43 deletions.
34 changes: 4 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 4 additions & 6 deletions src/deviceinfo.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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(),
Expand Down
10 changes: 4 additions & 6 deletions src/remapper.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(())
}
Expand All @@ -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()));

Expand Down

0 comments on commit 6448220

Please sign in to comment.