From c2957d876167367026b259cf3384145c1c51c47e Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 4 Jan 2024 10:52:40 +0200 Subject: [PATCH] Kernel: PS/2 device automatically sends commands when appended --- kernel/include/kernel/Input/PS2Device.h | 2 +- kernel/kernel/Input/PS2Device.cpp | 8 ++++++++ kernel/kernel/Input/PS2Keyboard.cpp | 8 -------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/include/kernel/Input/PS2Device.h b/kernel/include/kernel/Input/PS2Device.h index a5ce2796..db1ecb8b 100644 --- a/kernel/include/kernel/Input/PS2Device.h +++ b/kernel/include/kernel/Input/PS2Device.h @@ -21,7 +21,7 @@ namespace Kernel::Input virtual BAN::StringView name() const final override { return m_name; } virtual dev_t rdev() const final override { return m_rdev; } - protected: + private: void update(); private: diff --git a/kernel/kernel/Input/PS2Device.cpp b/kernel/kernel/Input/PS2Device.cpp index ac20a8c1..9534c58f 100644 --- a/kernel/kernel/Input/PS2Device.cpp +++ b/kernel/kernel/Input/PS2Device.cpp @@ -18,17 +18,25 @@ namespace Kernel::Input bool PS2Device::append_command_queue(uint8_t command) { if (m_command_queue.size() + 1 >= m_command_queue.capacity()) + { + dprintln("PS/2 command queue full"); return false; + } m_command_queue.push(command); + update(); return true; } bool PS2Device::append_command_queue(uint8_t command, uint8_t data) { if (m_command_queue.size() + 2 >= m_command_queue.capacity()) + { + dprintln("PS/2 command queue full"); return false; + } m_command_queue.push(command); m_command_queue.push(data); + update(); return true; } diff --git a/kernel/kernel/Input/PS2Keyboard.cpp b/kernel/kernel/Input/PS2Keyboard.cpp index 48dfc945..311fbcd4 100644 --- a/kernel/kernel/Input/PS2Keyboard.cpp +++ b/kernel/kernel/Input/PS2Keyboard.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #define SET_MASK(byte, mask, on_off) ((on_off) ? ((byte) | (mask)) : ((byte) & ~(mask))) #define TOGGLE_MASK(byte, mask) ((byte) ^ (mask)) @@ -28,7 +27,6 @@ namespace Kernel::Input append_command_queue(Command::SET_LEDS, 0x00); append_command_queue(Command::SCANCODE, PS2::KBScancode::SET_SCANCODE_SET2); append_command_queue(Command::ENABLE_SCANNING); - update(); } void PS2Keyboard::handle_device_command_response(uint8_t byte) @@ -130,12 +128,6 @@ namespace Kernel::Input event.modifier = m_modifiers | (released ? (uint8_t)Input::KeyEvent::Modifier::Released : 0); event.key = key; - if (event.pressed() && event.key == Input::Key::F11) - { - auto time = SystemTimer::get().time_since_boot(); - dprintln("{}.{9} s", time.tv_sec, time.tv_nsec); - } - if (m_event_queue.full()) { dwarnln("PS/2 event queue full");