From 24c6311f3895a2f6b2c5f4fc6f2c4e3e4f6fc15e Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Tue, 6 May 2025 18:54:09 +0200 Subject: [PATCH] drain --- device/ps2controller.cc | 8 +++++--- device/ps2controller.h | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/device/ps2controller.cc b/device/ps2controller.cc index 7d9edb2..a2d541f 100644 --- a/device/ps2controller.cc +++ b/device/ps2controller.cc @@ -110,7 +110,7 @@ void init() { bool fetch(Key &pressed) { uint8_t status_reg = ctrl_port.inb(); if(!(status_reg & HAS_OUTPUT) ) - return false; // TODO Remove mouse events from buffer + return false; DBG_VERBOSE << "status: " << hex << static_cast(status_reg) << "\n" << flush; uint8_t out_buffer = data_port.inb(); @@ -142,6 +142,8 @@ void setLed(enum LED led, bool on) { sendData(leds); // Parameter } -void drainBuffer() {} - +void drainBuffer() { + while(ctrl_port.inb() & HAS_OUTPUT) + data_port.inb(); +} } // namespace PS2Controller diff --git a/device/ps2controller.h b/device/ps2controller.h index 62a19f6..f3d292d 100644 --- a/device/ps2controller.h +++ b/device/ps2controller.h @@ -146,7 +146,6 @@ void setLed(enum LED led, bool on); * should be emptied once right before allowing keyboard interrupts * (even if keystrokes might be lost). * - * \todo(12) Implement method */ void drainBuffer();