1use pc_keyboard::{KeyEvent, ScancodeSet, ScancodeSet1, ScancodeSet2};
2
3fn main() {
4 let mut s = ScancodeSet1::new();
5 match s.advance_state(0x01) {
7 Ok(Some(KeyEvent { code, state })) => {
8 println!("Scancode Set 1 0x01 is KeyCode '{code:?}' KeyState '{state:?}'");
9 }
10 Ok(None) => {
11 println!("This is wrong, we didn't think that was a complete sequence");
12 }
13 Err(e) => {
14 println!("There was an error: {e:?}");
15 }
16 }
17 match s.advance_state(0x81) {
19 Ok(Some(KeyEvent { code, state })) => {
20 println!("Scancode Set 1 0x81 is KeyCode '{code:?}' KeyState '{state:?}'");
21 }
22 Ok(None) => {
23 println!("This is wrong, we didn't think that was a complete sequence");
24 }
25 Err(e) => {
26 println!("There was an error: {e:?}");
27 }
28 }
29
30 let mut s = ScancodeSet2::new();
31 match s.advance_state(0x01) {
33 Ok(Some(KeyEvent { code, state })) => {
34 println!("Scancode Set 2 0x01 is KeyCode '{code:?}' KeyState '{state:?}'");
35 }
36 Ok(None) => {
37 println!("This is wrong, we didn't think that was a complete sequence");
38 }
39 Err(e) => {
40 println!("There was an error: {e:?}");
41 }
42 }
43 assert_eq!(Ok(None), s.advance_state(0xF0));
45 match s.advance_state(0x01) {
46 Ok(Some(KeyEvent { code, state })) => {
47 println!("Scancode Set 2 0xF0 0x01 is KeyCode '{code:?}' KeyState '{state:?}'");
48 }
49 Ok(None) => {
50 println!("This is wrong, we didn't think that was a complete sequence");
51 }
52 Err(e) => {
53 println!("There was an error: {e:?}");
54 }
55 }
56}