From 250d70a958f2d7ddac61ed45415c145fcb3a70e7 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Thu, 13 Feb 2025 11:41:15 +0200 Subject: [PATCH] ps2: add more keys --- .../src/arch/x86/peripherals/ps2/codeset.rs | 20 +++++----- kernel/src/arch/x86/peripherals/ps2/mod.rs | 8 +++- lib/abi/src/io/input.rs | 40 +++++++++++++++++++ 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/kernel/src/arch/x86/peripherals/ps2/codeset.rs b/kernel/src/arch/x86/peripherals/ps2/codeset.rs index 714a2a8e..9960e917 100644 --- a/kernel/src/arch/x86/peripherals/ps2/codeset.rs +++ b/kernel/src/arch/x86/peripherals/ps2/codeset.rs @@ -134,15 +134,15 @@ table! { pub static CODE_SET_1_E0: [Key; 128; Key::Unknown] = [ 0x1D => Key::RControl, 0x38 => Key::RAlt, - // 0x47 => Key::Home, - // 0x48 => Key::Up, - // 0x49 => Key::PageUp, - // 0x4B => Key::Left, - // 0x4D => Key::Right, - // 0x4F => Key::End, - // 0x50 => Key::Down, - // 0x51 => Key::PageDown, - // 0x52 => Key::Insert, - // 0x53 => Key::Delete, + 0x47 => Key::Home, + 0x48 => Key::Up, + 0x49 => Key::PageUp, + 0x4B => Key::Left, + 0x4D => Key::Right, + 0x4F => Key::End, + 0x50 => Key::Down, + 0x51 => Key::PageDown, + 0x52 => Key::Insert, + 0x53 => Key::Delete, ]; } diff --git a/kernel/src/arch/x86/peripherals/ps2/mod.rs b/kernel/src/arch/x86/peripherals/ps2/mod.rs index 6d532e3f..388115b6 100644 --- a/kernel/src/arch/x86/peripherals/ps2/mod.rs +++ b/kernel/src/arch/x86/peripherals/ps2/mod.rs @@ -79,6 +79,7 @@ impl InterruptHandler for PS2Controller { fn handle_irq(self: Arc, _vector: IrqVector) -> bool { let mut count = 0; let mut inner = self.inner.lock(); + let mut e0 = false; loop { let Some(mut scancode) = inner.try_recv() else { @@ -87,7 +88,10 @@ impl InterruptHandler for PS2Controller { count += 1; - let e0 = scancode == 0xE0; + if scancode == 0xE0 { + e0 = true; + continue; + } let release = scancode >= 0x80; if release { @@ -101,6 +105,8 @@ impl InterruptHandler for PS2Controller { KeyboardKeyEvent::Pressed(key) }; + e0 = false; + ygg_driver_input::send_event(event); } diff --git a/lib/abi/src/io/input.rs b/lib/abi/src/io/input.rs index 5f7f100d..4ad3dc11 100644 --- a/lib/abi/src/io/input.rs +++ b/lib/abi/src/io/input.rs @@ -12,12 +12,22 @@ pub enum KeyboardKey { RShift, LControl, RControl, + PageUp, + PageDown, LAlt, RAlt, CapsLock, Escape, Backspace, Tab, + Up, + Down, + Left, + Right, + Home, + End, + Insert, + Delete, Unknown, } @@ -54,6 +64,16 @@ impl KeyboardKey { // 0x98: Escape // 0x99: Backspace // 0x9A: Tab + // 0xA0: PageUp + // 0xA1: PageDown + // 0xA2: Up + // 0xA3: Down + // 0xA4: Left + // 0xA5: Right + // 0xA6: Home + // 0xA7: End + // 0xA8: Insert + // 0xA9: Delete // 0xFF: Unknown KeyboardKeyCode(match self { Self::Char(b) => b as u16, @@ -69,6 +89,16 @@ impl KeyboardKey { Self::Escape => 0x98, Self::Backspace => 0x99, Self::Tab => 0x9A, + Self::PageUp => 0xA0, + Self::PageDown => 0xA1, + Self::Up => 0xA2, + Self::Down => 0xA3, + Self::Left => 0xA4, + Self::Right => 0xA5, + Self::Home => 0xA6, + Self::End => 0xA7, + Self::Insert => 0xA8, + Self::Delete => 0xA9, Self::Unknown => 0xFF, }) } @@ -93,6 +123,16 @@ impl KeyboardKey { 0x98 => Self::Escape, 0x99 => Self::Backspace, 0x9A => Self::Tab, + 0xA0 => Self::PageUp, + 0xA1 => Self::PageDown, + 0xA2 => Self::Up, + 0xA3 => Self::Down, + 0xA4 => Self::Left, + 0xA5 => Self::Right, + 0xA6 => Self::Home, + 0xA7 => Self::End, + 0xA8 => Self::Insert, + 0xA9 => Self::Delete, _ => Self::Unknown, } }