[Solved] Polling keyboard - last scancode not resetting?
Posted: Fri Jan 08, 2021 6:28 am
Hi
I am polling the PS/2 keyboard for scancodes and everything is working apart from the last scancode appears to be read every time I poll the device. I can't see how I can reset it from the wiki, or if I should be doing that at all.
Here's the function where I get the scancode:
I would appreciate any pointers or tips that could get me going here.
I am polling the PS/2 keyboard for scancodes and everything is working apart from the last scancode appears to be read every time I poll the device. I can't see how I can reset it from the wiki, or if I should be doing that at all.
Here's the function where I get the scancode:
Code: Select all
static __attribute__ ((noinline))
auto pollKeyboardForScancode()
-> uint8_t
{
auto scancode = char{ 0 };
auto ps2_status = uint8_t{ 0x64 };
auto ps2_data = uint8_t{ 0x60 };
asm(R"(
poll:
in al, %b[_ps2_status]
test al, 1
jz poll
.have_key:
in al, %b[_ps2_data]
mov %[_char], al
)"
: [_char] "=r" (scancode)
: [_ps2_data] "g" (ps2_data),
[_ps2_status] "g" (ps2_status)
: "eax"
);
return scancode;
}