Skip to content
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

Fix bug where Pause/Break key scancode is converted to Ctrl-NumLock. #37

Open
TomAwezome opened this issue Apr 6, 2022 · 4 comments
Open
Labels
bug Something isn't working enhancement New feature or request

Comments

@TomAwezome
Copy link
Collaborator

No description provided.

@TomAwezome TomAwezome added bug Something isn't working enhancement New feature or request labels Apr 6, 2022
@GutPuncher
Copy link
Contributor

GutPuncher commented Dec 6, 2023

https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Set_1
https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Set_2

Scancode Set 2:

  • Pause/Break
    • 0xE1 0x14 0x77 0xE1 0xF0 0x14 0xF0 0x77
  • LeftCtrl (Pressed)
    • 0x14
  • NumLock (Pressed)
    • 0x77
  • LeftCtrl (Released)
    • 0xF0 0x14
  • NumLock (Released)
    • 0xF0 0x77
  • LeftCtrl-NumLock (Pressed)
    • 0x14 0x77
  • LeftCtrl-NumLock (Released)
    • 0xF0 0x14 0xF0 0x77

@GutPuncher
Copy link
Contributor

It appears Zeal is interpreting Pause/Break as Ctrl-NumLock because of either the starting three bytes matching LeftCtrl-NumLock Pressed, or the latter four bytes matching LeftCtrl-NumLock Released. Though the specific bytes are different for Scan Code 1, both sets have matching byte values in the scancodes like this for these keys. The only distinguishing factor is that the isolated Pause/Break code starts with 0xE1 and divides the duplicates via another 0xE1. The code that processes 0xE1 bytes in the keyboard driver scan code parsing/scancode-to-keyname logic may need to be reviewed

@GutPuncher
Copy link
Contributor

https://github.com/Zeal-Operating-System/ZealOS/blob/master/src/Kernel/SerialDev/Keyboard.ZC

See:

  • ScanCode2Char
  • ScanCode2KeyName
  • KbdBuildSC
  • KbdPacketRead
  • KbdHandler

@GutPuncher
Copy link
Contributor

From the OSDev Wiki link above:

Note that scancodes with extended byte (E0) generates two different interrupts: the first containing the E0 byte, the second containing the scancode

The mentioned functions have different mechanisms for handling this 0xE0 "extended byte", but the odd 0xE1 of Pause/Break is likely being dropped/skipped/incorrectly matched, and the rest of its bytes matching up to the next closest scancode. An additional integration for factoring in the Pause/Break scancode similar to how 0xE0 bytes are handled may be needed to resolve this bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants