From 10b43f3d1d9983eea9b1bea0b340ab491388354f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 17 Feb 2019 08:39:09 +0100 Subject: [PATCH] Kernel: Rename Keyboard to KeyboardDevice. --- Kernel/{Keyboard.cpp => KeyboardDevice.cpp} | 20 ++++++++++---------- Kernel/{Keyboard.h => KeyboardDevice.h} | 12 ++++++------ Kernel/Makefile | 2 +- Kernel/VirtualConsole.cpp | 4 ++-- Kernel/VirtualConsole.h | 4 ++-- Kernel/init.cpp | 6 +++--- 6 files changed, 24 insertions(+), 24 deletions(-) rename Kernel/{Keyboard.cpp => KeyboardDevice.cpp} (92%) rename Kernel/{Keyboard.h => KeyboardDevice.h} (81%) diff --git a/Kernel/Keyboard.cpp b/Kernel/KeyboardDevice.cpp similarity index 92% rename from Kernel/Keyboard.cpp rename to Kernel/KeyboardDevice.cpp index a21c827e0c..ed6254048b 100644 --- a/Kernel/Keyboard.cpp +++ b/Kernel/KeyboardDevice.cpp @@ -2,7 +2,7 @@ #include "i386.h" #include "IO.h" #include "PIC.h" -#include "Keyboard.h" +#include "KeyboardDevice.h" #include "VirtualConsole.h" #include @@ -97,7 +97,7 @@ static KeyCode shifted_key_map[0x100] = Key_Down, // 80 }; -void Keyboard::key_state_changed(byte raw, bool pressed) +void KeyboardDevice::key_state_changed(byte raw, bool pressed) { Event event; event.key = (m_modifiers & Mod_Shift) ? shifted_key_map[raw] : unshifted_key_map[raw]; @@ -110,7 +110,7 @@ void Keyboard::key_state_changed(byte raw, bool pressed) m_queue.enqueue(event); } -void Keyboard::handle_irq() +void KeyboardDevice::handle_irq() { for (;;) { byte status = IO::in8(I8042_STATUS); @@ -146,15 +146,15 @@ void Keyboard::handle_irq() } } -static Keyboard* s_the; +static KeyboardDevice* s_the; -Keyboard& Keyboard::the() +KeyboardDevice& KeyboardDevice::the() { ASSERT(s_the); return *s_the; } -Keyboard::Keyboard() +KeyboardDevice::KeyboardDevice() : IRQHandler(IRQ_KEYBOARD) , CharacterDevice(85, 1) { @@ -168,16 +168,16 @@ Keyboard::Keyboard() enable_irq(); } -Keyboard::~Keyboard() +KeyboardDevice::~KeyboardDevice() { } -bool Keyboard::can_read(Process&) const +bool KeyboardDevice::can_read(Process&) const { return !m_queue.is_empty(); } -ssize_t Keyboard::read(Process&, byte* buffer, size_t size) +ssize_t KeyboardDevice::read(Process&, byte* buffer, size_t size) { ssize_t nread = 0; while ((size_t)nread < size) { @@ -193,7 +193,7 @@ ssize_t Keyboard::read(Process&, byte* buffer, size_t size) return nread; } -ssize_t Keyboard::write(Process&, const byte*, size_t) +ssize_t KeyboardDevice::write(Process&, const byte*, size_t) { return 0; } diff --git a/Kernel/Keyboard.h b/Kernel/KeyboardDevice.h similarity index 81% rename from Kernel/Keyboard.h rename to Kernel/KeyboardDevice.h index ff49fdd5d0..fb8e9fc28b 100644 --- a/Kernel/Keyboard.h +++ b/Kernel/KeyboardDevice.h @@ -9,15 +9,15 @@ class KeyboardClient; -class Keyboard final : public IRQHandler, public CharacterDevice { +class KeyboardDevice final : public IRQHandler, public CharacterDevice { AK_MAKE_ETERNAL public: using Event = KeyEvent; - [[gnu::pure]] static Keyboard& the(); + [[gnu::pure]] static KeyboardDevice& the(); - virtual ~Keyboard() override; - Keyboard(); + virtual ~KeyboardDevice() override; + KeyboardDevice(); void set_client(KeyboardClient* client) { m_client = client; } @@ -32,7 +32,7 @@ private: virtual void handle_irq() override; // ^CharacterDevice - virtual const char* class_name() const override { return "Keyboard"; } + virtual const char* class_name() const override { return "KeyboardDevice"; } void key_state_changed(byte raw, bool pressed); void update_modifier(byte modifier, bool state) @@ -51,5 +51,5 @@ private: class KeyboardClient { public: virtual ~KeyboardClient(); - virtual void on_key_pressed(Keyboard::Event) = 0; + virtual void on_key_pressed(KeyboardDevice::Event) = 0; }; diff --git a/Kernel/Makefile b/Kernel/Makefile index b3e36ab606..0b66818c36 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -6,7 +6,7 @@ KERNEL_OBJS = \ i386.o \ Process.o \ i8253.o \ - Keyboard.o \ + KeyboardDevice.o \ CMOS.o \ PIC.o \ Syscall.o \ diff --git a/Kernel/VirtualConsole.cpp b/Kernel/VirtualConsole.cpp index 3760fa0b63..08bebe8624 100644 --- a/Kernel/VirtualConsole.cpp +++ b/Kernel/VirtualConsole.cpp @@ -3,7 +3,7 @@ #include "i386.h" #include "IO.h" #include "StdLib.h" -#include "Keyboard.h" +#include "KeyboardDevice.h" #include static byte* s_vga_buffer; @@ -476,7 +476,7 @@ void VirtualConsole::on_char(byte ch) set_cursor(m_cursor_row, m_cursor_column); } -void VirtualConsole::on_key_pressed(Keyboard::Event key) +void VirtualConsole::on_key_pressed(KeyboardDevice::Event key) { if (key.ctrl()) { if (key.character >= 'a' && key.character <= 'z') { diff --git a/Kernel/VirtualConsole.h b/Kernel/VirtualConsole.h index 3b86d60b8b..e9e9cedfe0 100644 --- a/Kernel/VirtualConsole.h +++ b/Kernel/VirtualConsole.h @@ -1,7 +1,7 @@ #pragma once #include "TTY.h" -#include "Keyboard.h" +#include "KeyboardDevice.h" #include "Console.h" class VirtualConsole final : public TTY, public KeyboardClient, public ConsoleImplementation { @@ -17,7 +17,7 @@ public: private: // ^KeyboardClient - virtual void on_key_pressed(Keyboard::Event) override; + virtual void on_key_pressed(KeyboardDevice::Event) override; // ^ConsoleImplementation virtual void on_sysconsole_receive(byte) override; diff --git a/Kernel/init.cpp b/Kernel/init.cpp index b28a0ace3f..312dc13498 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -2,7 +2,7 @@ #include "kmalloc.h" #include "i386.h" #include "i8253.h" -#include "Keyboard.h" +#include "KeyboardDevice.h" #include "Process.h" #include "system.h" #include "PIC.h" @@ -38,7 +38,7 @@ VirtualConsole* tty0; VirtualConsole* tty1; VirtualConsole* tty2; VirtualConsole* tty3; -Keyboard* keyboard; +KeyboardDevice* keyboard; PS2MouseDevice* ps2mouse; NullDevice* dev_null; VFS* vfs; @@ -154,7 +154,7 @@ VFS* vfs; vfs = new VFS; - keyboard = new Keyboard; + keyboard = new KeyboardDevice; ps2mouse = new PS2MouseDevice; dev_null = new NullDevice;