Skip to content

Commit

Permalink
chore: taking it easy on the reader, have it sleep often
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnarus-G committed Aug 14, 2024
1 parent ecb3576 commit 9017e24
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cli/src/inputspeed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ pub fn setup_input_speed_reader() {
let mut buffer = [0u8; 4];

loop {
let _ = file
.read(&mut buffer)
file.read_exact(&mut buffer)
.expect("failed to read 4 bytes from /dev/maccel");

// The buffer, we expect, is just 4 bytes for a number (fixedpt)
let num: f32 = Fixedpt(i32::from_be_bytes(buffer)).into();

// Safety don't care about race conditions
unsafe { INPUT_SPEED = num };

thread::sleep(std::time::Duration::from_nanos(500));
}
});
}

0 comments on commit 9017e24

Please sign in to comment.