23 lines
412 B
Rust
23 lines
412 B
Rust
|
extern crate evdev_rs;
|
||
|
|
||
|
use std::fs::File;
|
||
|
|
||
|
pub struct HwDevice {
|
||
|
pub device: evdev_rs::Device,
|
||
|
_file: File,
|
||
|
}
|
||
|
|
||
|
impl HwDevice {
|
||
|
pub fn new(path: &str) -> Self {
|
||
|
let f = File::open(path).unwrap();
|
||
|
let mut d = evdev_rs::Device::new().unwrap();
|
||
|
d.set_fd(&f).unwrap();
|
||
|
|
||
|
HwDevice {
|
||
|
device: d,
|
||
|
// keep fd open
|
||
|
_file: f,
|
||
|
}
|
||
|
}
|
||
|
}
|