From 425e3fd1fd97e50041d8272bf4bcc7c1107571a1 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Tue, 16 Apr 2024 14:42:14 +0200 Subject: keyboard: implement leds and reboot works on qemu, untested on real machine --- src/machine/key.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/machine/key.rs') diff --git a/src/machine/key.rs b/src/machine/key.rs index 8d4e5f9..48e98b2 100644 --- a/src/machine/key.rs +++ b/src/machine/key.rs @@ -21,18 +21,23 @@ impl convert::Into for Key { } } +// Technically the *Lock are special keys, instead of Modifiers +// but we don't need another type FWIW. +// Mask bits[2:0] to get the leds. bitflags! { #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub struct Modifiers:u8 { const NONE = 0; - const SHIFT = 1 << 0; - const ALT_LEFT = 1 << 1; - const ALT_RIGHT = 1 << 2; - const CTRL_LEFT = 1 << 3; - const CTRL_RIGHT = 1 << 4; - const CAPSLOCK = 1 << 5; - const NUMLOCK = 1 << 6; - const SCROLL_LOCK = 1 << 7; + // lock states + const SCROLL_LOCK = 1 << 0; + const NUMLOCK = 1 << 1; + const CAPSLOCK = 1 << 2; + // modifiers + const SHIFT = 1 << 3; + const ALT_LEFT = 1 << 4; + const ALT_RIGHT = 1 << 5; + const CTRL_LEFT = 1 << 6; + const CTRL_RIGHT = 1 << 7; } } -- cgit v1.2.3-70-g09d2