Skip to content

Commit

Permalink
fix: arrows jumping by 2
Browse files Browse the repository at this point in the history
  • Loading branch information
winstonallo committed Mar 2, 2025
1 parent 06a610e commit d0ab036
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ mod terminal;
#[unsafe(no_mangle)]
pub extern "C" fn kernel_main() {
if let Err(e) = ps2::init() {
panic!("{}", e);
panic!("could not initialize PS/2: {}", e);
}

arch::x86::set_gdt();
#[allow(static_mut_refs)]
shell::launch(unsafe { &mut SCREEN });
Expand Down
6 changes: 3 additions & 3 deletions src/ps2/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ pub fn read_if_ready() -> Option<Key> {

if code == 0xE0 {
while !is_ps2_data_available() {}
let extended_code = unsafe { read(DATA_PORT) };
unsafe { LAST_KEY = Some(extended_code) };
return SCANCODE_TO_KEY[extended_code as usize].1;
let _ = unsafe { read(DATA_PORT) };
unsafe { LAST_KEY = None };
return None;
}

unsafe { LAST_KEY = Some(code) };
Expand Down
8 changes: 4 additions & 4 deletions src/ps2/scancodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,17 @@ pub const SCANCODE_TO_KEY: [(u8, Option<Key>); 256] = [
(0x68, None),
(0x69, Some(N1)),
(0x6A, None),
(0x6B, Some(N4)),
(0x6B, Some(ArrowLeft)),
(0x6C, Some(N7)),
(0x6D, None),
(0x6E, None),
(0x6F, None),
(0x70, Some(N0)),
(0x71, Some(Point)),
(0x72, Some(N2)),
(0x72, Some(ArrowDown)),
(0x73, Some(N5)),
(0x74, Some(N6)),
(0x75, Some(N8)),
(0x74, Some(ArrowRight)),
(0x75, Some(ArrowUp)),
(0x76, Some(Escape)),
(0x77, Some(NumLock)),
(0x78, Some(F11)),
Expand Down

0 comments on commit d0ab036

Please sign in to comment.