use pc_keyboard::Ps2Decoder;
fn main() {
let mut decoder = Ps2Decoder::new();
match decoder.add_word(0x0402) {
Ok(byte) => println!("Word 0x0402 is byte 0x{:02x}", byte),
Err(e) => println!("Word 0x0402 failed to decode: {:?}", e),
}
for bit in [
false, true, false, false, false, false, false, false, false, false, true,
] {
match decoder.add_bit(bit) {
Ok(None) => println!("Added {}, not enough bits yet!", bit as u8),
Ok(Some(byte)) => println!("Added {}, got byte 0x{byte:02x}", bit as u8),
Err(e) => println!("Failed to decode: {e:?}"),
}
}
for bit in [
false, true, false, false, false, false, true, false, false, false, true,
] {
match decoder.add_bit(bit) {
Ok(None) => println!("Added {}, not enough bits yet!", bit as u8),
Ok(Some(byte)) => println!("Added {}, got byte 0x{byte:02x}", bit as u8),
Err(e) => println!("Failed to decode: {e:?}"),
}
}
}