Skip to content

fix: repeated keyboard input when INT 16h polls an empty 8042 buffer - #2320

Merged
maximilien-noal merged 1 commit into
OpenRakis:masterfrom
fusefib:patch-1
Aug 24, 2026
Merged

fix: repeated keyboard input when INT 16h polls an empty 8042 buffer#2320
maximilien-noal merged 1 commit into
OpenRakis:masterfrom
fusefib:patch-1

Conversation

@fusefib

@fusefib fusefib commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

Added a check in BiosKeyboardInt9Handler.Run() for the Intel 8042 output-buffer-full/data-pending status bit before reading keyboard data from port 0x60.

If no new keyboard data is pending, the handler acknowledges IRQ1 and returns without processing a scancode.

Rationale behind Changes

The in-memory INT 16h handler invokes INT 09h when the BIOS keyboard buffer is empty in order to fetch pending keyboard input.

However, BiosKeyboardInt9Handler.Run() previously read port 0x60 unconditionally. Intel8042Controller.ReadByte() intentionally returns the previous data byte when no new data is pending.

This meant that when INT 16h invoked INT 09h while the 8042 output buffer was empty, the previous keyboard scancode could be processed again as if it were new input. In affected software, this caused a single physical key press to be duplicated repeatedly.

The issue was reproduced with the text adventure game Solus (1988). With SOLUS.COM: pressing L once resulted in a rapid flood of l characters despite the input pipeline receiving exactly one key-down and one key-up event. Pressing Enter once similarly resulted in multiple Enter key events being processed.

Suggested Testing Steps

  1. Run SOLUS.COM and wait for its text parser prompt.

  2. Tap a letter key such as L once, or press Enter once.

    • Before this change, a single key press can be processed repeatedly.
    • After this change, a single key press should be processed exactly once.

INT 16h may invoke INT 09h while waiting for a keystroke. When the
8042 output buffer is empty, reading port 0x60 returns the previous
data byte, causing the same scancode to be processed repeatedly.

Check the controller status before reading the keyboard data port.
@maximilien-noal maximilien-noal added BIOS Related to the IBM PC BIOS bugfix fixes a bug labels Aug 24, 2026
@maximilien-noal

Copy link
Copy Markdown
Member

@fusefib thank you for this fix; :)

@maximilien-noal

Copy link
Copy Markdown
Member

@fusefib tested and approved! Thanks again.

@maximilien-noal
maximilien-noal self-requested a review August 24, 2026 19:14
@maximilien-noal
maximilien-noal merged commit 75016f2 into OpenRakis:master Aug 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BIOS Related to the IBM PC BIOS bugfix fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants