Skip to content

Add/update set2 scancodes #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub enum KeyCode {
BackTick,
BracketSquareLeft,
BracketSquareRight,
Break,
CapsLock,
Comma,
ControlLeft,
Expand Down Expand Up @@ -142,6 +143,7 @@ pub enum KeyCode {
ShiftRight,
Slash,
Spacebar,
SysReq,
Tab,
Quote,
WindowsLeft,
Expand Down
10 changes: 7 additions & 3 deletions src/scancodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl ScancodeSet for ScancodeSet1 {

/// Contains the implementation of Scancode Set 2.
/// See the OS dev wiki: https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Set_2
/// Additional reference: https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html
pub struct ScancodeSet2;

impl ScancodeSet for ScancodeSet2 {
Expand Down Expand Up @@ -372,8 +373,8 @@ impl ScancodeSet for ScancodeSet2 {
0x59 => Ok(KeyCode::ShiftRight), // 59
0x5A => Ok(KeyCode::Enter), // 5A
0x5B => Ok(KeyCode::BracketSquareRight), // 5B
0x5D => Ok(KeyCode::HashTilde), // 5D
0x61 => Ok(KeyCode::BackSlash), // 61
0x5D => Ok(KeyCode::BackSlash), // 5D
0x61 => Ok(KeyCode::HashTilde), // 61
0x66 => Ok(KeyCode::Backspace), // 66
0x69 => Ok(KeyCode::Numpad1), // 69
0x6B => Ok(KeyCode::Numpad4), // 6B
Expand All @@ -394,12 +395,13 @@ impl ScancodeSet for ScancodeSet2 {
0x7D => Ok(KeyCode::Numpad9), // 7D
0x7E => Ok(KeyCode::ScrollLock), // 7E
0x83 => Ok(KeyCode::F7), // 83
0x84 => Ok(KeyCode::SysReq), // 84
0xAA => Ok(KeyCode::PowerOnTestOk), // AA
_ => Err(Error::UnknownKeyCode),
}
}

/// Implements the extended byte codes for set 1 (prefixed with E0)
/// Implements the extended byte codes for set 2 (prefixed with E0)
fn map_extended_scancode(code: u8) -> Result<KeyCode, Error> {
match code {
0x11 => Ok(KeyCode::AltRight), // E011
Expand All @@ -418,7 +420,9 @@ impl ScancodeSet for ScancodeSet2 {
0x74 => Ok(KeyCode::ArrowRight), // E074
0x75 => Ok(KeyCode::ArrowUp), // E075
0x7A => Ok(KeyCode::PageDown), // E07A
0x7C => Ok(KeyCode::PrintScreen), // E07C
0x7D => Ok(KeyCode::PageUp), // E07D
0x7E => Ok(KeyCode::Break), // E07E
_ => Err(Error::UnknownKeyCode),
}
}
Expand Down