Last active
December 13, 2017 13:29
-
-
Save remi6397/f9c62f6d6976a16d9fe386dbcd693ebb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut pressure_pen = evdev::enumerate().into_iter().find(|d| d.absolute_axes_supported().contains(ABS_PRESSURE)); | |
let get_pressure: Box<FnMut() -> i32> = match pressure_pen { | |
Some(pressure_pen) => Box::new(move || -> i32 { | |
let mut events = pressure_pen.events_no_sync().unwrap(); | |
// ^^^^^^^^^^^^ - cannot borrow captured outer variable in FnMut closure as mutable | |
let pressure = events.find(|ev| ev.code < 0xFF && 1 << ev.code == ABS_PRESSURE.bits()); | |
match pressure { | |
Some(pressure) => pressure.value, | |
_ => 0i32 | |
} | |
}), | |
_ => Box::new(move || -> i32 { 1000i32 }) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment