Skip to content
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

Update evdev-rs to 0.6.1 #52

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading