summaryrefslogtreecommitdiff
path: root/src/remapper.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/remapper.rs')
-rw-r--r--src/remapper.rs10
1 files changed, 4 insertions, 6 deletions
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()));