From 35d9c7bd48d823ec5a858107664b9b93845b77ad Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 28 Apr 2025 00:30:04 +0200 Subject: [PATCH] first try for ps2, time to debug --- device/ps2controller.cc | 23 +++++++++++++++++++---- main.cc | 16 ++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/device/ps2controller.cc b/device/ps2controller.cc index 11d46b1..bf78986 100644 --- a/device/ps2controller.cc +++ b/device/ps2controller.cc @@ -89,8 +89,11 @@ enum ControllerCommand { * * \param value data to be sent */ -[[maybe_unused]] static void sendData(uint8_t value) { - // TODO: You have to implement this method + static void sendData(uint8_t value) { + + if (!(ctrl_port.inb()&HAS_OUTPUT)) { + data_port.outb(value); + } (void)value; } @@ -106,8 +109,20 @@ void init() { bool fetch(Key &pressed) { // TODO: You have to implement this method - (void)pressed; - return false; + uint8_t status_reg = ctrl_port.inb(); + if(status_reg & IS_MOUSE || !(status_reg & HAS_OUTPUT) ) + return false; // TODO Remove mouse events from buffer + + uint8_t out_buffer = data_port.inb(); + + pressed = key_decoder.decode(out_buffer); + + + if (pressed.alt() || pressed.ctrl() || pressed.shift) { + return false; + } + else + return true; } void setRepeatRate(Speed speed, Delay delay) { diff --git a/main.cc b/main.cc index 1fb89a0..541495e 100644 --- a/main.cc +++ b/main.cc @@ -7,7 +7,7 @@ #include "arch/serial.h" #include "device/serialstream.h" #include "device/textstream.h" - +#include "device/ps2controller.h" TextStream kout = TextStream(0, 80, 0, 12, true); TextStream dout[8] = { @@ -68,14 +68,23 @@ extern "C" int main() { kout << "pointer: " << reinterpret_cast(1994473406541717165ull) << " -> 0x1badcafefee1dead" << endl; kout << "smiley: " << static_cast(1) << endl; - + /* Start application processors * To avoid unexpected behaviour, make sure that interrupts are not * enabled before the APs are booted. Otherwise it might interfere with the * Startup IPIs or even block devices like keyboard because of a missing EOI */ - ApplicationProcessor::boot(); + ApplicationProcessor::boot(); + + PS2Controller::init(); + Key key = Key(); + while (true){ + if (PS2Controller::fetch(key)) { + kout << key.ascii() ; + } + + } return 0; } @@ -86,7 +95,6 @@ extern "C" int main_ap() { - //TextWindow dout0 = TextWindow(0,20,13,19, false); //dout0.reset(); //dout0.reset(' ', CGA::Attribute(CGA::LIGHT_GREEN, CGA::RED, false));