Created
May 26, 2016 09:22
-
-
Save Acconut/1d31c1d04430cfa144437bd9c81e541e 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
#![feature(read_exact)] | |
use std::fs::File; | |
use std::io::Read; | |
use std::mem::transmute; | |
#[derive(Debug)] | |
struct RawEvent { | |
time_a: i64, | |
time_b: i64, | |
typ: u16, | |
code: u16, | |
value: i32 | |
} | |
fn main() { | |
let mut f = File::open("/dev/input/event16").unwrap(); | |
let mut buf: [u8; 24] = [0; 24]; | |
loop { | |
f.read_exact(&mut buf).unwrap(); | |
let ev: RawEvent = unsafe { transmute(buf) }; | |
if ev.typ == 0 { | |
continue | |
} | |
println!("event: {:?}", ev); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment