rktk/drivers/interface/keyscan.rs
1pub use kmsm::interface::state::input_event::KeyChangeEvent;
2
3/// Key scanner driver interface.
4///
5/// The keyscan driver has two roles:
6/// - Scanning the keys
7/// - Determining which hand is currently using the keyboard on a split keyboard
8///
9/// This is because the key scanning circuit often includes a left/right determination circuit.
10pub trait KeyscanDriver {
11 /// The size of the calibration data in bytes. If 0, calibration is not supported.
12 const CALIBRATION_SIZE: usize = 0;
13
14 type CalibrationError: core::error::Error;
15
16 /// Save calibration data into the provided buffer. Returns `Ok(())` on success.
17 fn save_calibration(&self, _buf: &mut [u8]) -> Result<(), Self::CalibrationError> {
18 Ok(())
19 }
20
21 /// Load calibration data from the provided buffer. Returns `Ok(())` on success.
22 fn load_calibration(&mut self, _buf: &[u8]) -> Result<(), Self::CalibrationError> {
23 Ok(())
24 }
25
26 /// Scans a key and returns the delta from the previous key scan
27 async fn scan(&mut self, callback: impl FnMut(KeyChangeEvent));
28
29 /// Starts calibration mode.
30 fn start_calibration(&mut self) {}
31
32 /// Ends calibration mode.
33 fn end_calibration(&mut self) {}
34}
RKTK API Docs