Kernel: Rename Keyboard to KeyboardDevice.

This commit is contained in:
Andreas Kling 2019-02-17 08:39:09 +01:00
parent 2dc0ef8813
commit 10b43f3d1d
Notes: sideshowbarker 2024-07-19 15:41:28 +09:00
6 changed files with 24 additions and 24 deletions

View File

@ -2,7 +2,7 @@
#include "i386.h"
#include "IO.h"
#include "PIC.h"
#include "Keyboard.h"
#include "KeyboardDevice.h"
#include "VirtualConsole.h"
#include <AK/Assertions.h>
@ -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;
}

View File

@ -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;
};

View File

@ -6,7 +6,7 @@ KERNEL_OBJS = \
i386.o \
Process.o \
i8253.o \
Keyboard.o \
KeyboardDevice.o \
CMOS.o \
PIC.o \
Syscall.o \

View File

@ -3,7 +3,7 @@
#include "i386.h"
#include "IO.h"
#include "StdLib.h"
#include "Keyboard.h"
#include "KeyboardDevice.h"
#include <AK/AKString.h>
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') {

View File

@ -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;

View File

@ -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;