Public Member Functions | Private Attributes | Static Private Attributes
Keyboard Class Reference

PS2 Keyboard device driver. More...

#include <Keyboard.h>

Inheritance diagram for Keyboard:
Device File

Public Member Functions

 Keyboard (const u32 inode)
 Constructor. More...
virtual FileSystem::Result initialize ()
 Initialize the device. More...
virtual FileSystem::Result interrupt (const Size vector)
 Executed when a key state has changed. More...
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read a character from the keyboard. More...
- Public Member Functions inherited from Device
 Device (const u32 inode, const FileSystem::FileType type)
 Constructor. More...
virtual ~Device ()
 Destructor. More...
virtual const StringgetIdentifier () const
 Get unique device identifier. More...
- Public Member Functions inherited from File
 File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
 Constructor function. More...
virtual ~File ()
 Destructor function. More...
u32 getInode () const
 Get inode number. More...
FileSystem::FileType getType () const
 Retrieve our filetype. More...
virtual FileSystem::Result write (IOBuffer &buffer, Size &size, const Size offset)
 Write bytes to the file. More...
virtual FileSystem::Result status (FileSystem::FileStat &st)
 Retrieve file statistics. More...
virtual bool canRead () const
 Check if the File has data ready for reading. More...
virtual bool canWrite () const
 Check if the File can be written to. More...

Private Attributes

u8 shiftState
 State of the shift key. More...
bool pending
 Do we have a byte ready? More...
Arch::IO m_io
 Port I/O object. More...

Static Private Attributes

static const char keymap [0x3a][2]
 Keyboard map table. More...

Additional Inherited Members

- Protected Attributes inherited from Device
String m_identifier
 Unique identifier for this Device. More...
- Protected Attributes inherited from File
const u32 m_inode
 Inode number. More...
const FileSystem::FileType m_type
 Type of this file. More...
UserID m_uid
 Owner of the file. More...
GroupID m_gid
 Group of the file. More...
FileSystem::FileModes m_access
 Access permissions. More...
Size m_size
 Size of the file, in bytes. More...

Detailed Description

PS2 Keyboard device driver.

Definition at line 46 of file Keyboard.h.

Constructor & Destructor Documentation

◆ Keyboard()

Keyboard::Keyboard ( const u32  inode)


inodeInode number

Definition at line 45 of file Keyboard.cpp.

References Device::m_identifier.

Member Function Documentation

◆ initialize()

FileSystem::Result Keyboard::initialize ( )

Initialize the device.

Result code

Reimplemented from Device.

Definition at line 52 of file Keyboard.cpp.

References FileSystem::Success.

◆ interrupt()

FileSystem::Result Keyboard::interrupt ( const Size  vector)

Executed when a key state has changed.

vectorInterrupt vector.
Result code

Reimplemented from Device.

Definition at line 57 of file Keyboard.cpp.

References pending, and FileSystem::Success.

◆ read()

FileSystem::Result Keyboard::read ( IOBuffer buffer,
Size size,
const Size  offset 

Read a character from the keyboard.

bufferInput/Output buffer to output bytes to.
sizeMaximum number of bytes to read on input. On output, the actual number of bytes read.
offsetOffset inside the file to start reading.
Result code

Reimplemented from File.

Definition at line 63 of file Keyboard.cpp.

References EnableIRQ, keymap, m_io, pending, ProcessCtl(), PS2_IRQ, PS2_PORT, PS2_RELEASE, FileSystem::RetryAgain, SELF, shiftState, FileSystem::Success, and IOBuffer::write().

Field Documentation

◆ keymap

const char Keyboard::keymap
Initial value:
{0x0, 0x0}, {0x0, 0x0}, {'1', '!'}, {'2', '@'},
{'3', '#'}, {'4', '$'}, {'5', '%'}, {'6', '^'},
{'7', '&'}, {'8', '*'}, {'9', '('}, {'0', ')'},
{'-', '_'}, {'=', '+'}, {'\b','\b'},{'\t','\t'},
{'q', 'Q'}, {'w', 'W'}, {'e', 'E'}, {'r', 'R'},
{'t', 'T'}, {'y', 'Y'}, {'u', 'U'}, {'i', 'I'},
{'o', 'O'}, {'p', 'P'}, {'[', '{'}, {']', '}'},
{'\n','\n'},{0x0, 0x0}, {'a', 'A'}, {'s', 'S'},
{'d', 'D'}, {'f', 'F'}, {'g', 'G'}, {'h', 'H'},
{'j', 'J'}, {'k', 'K'}, {'l', 'L'}, {';', ':'},
{'\'','\"'},{'`', '~'}, {0x0, 0x0}, {'\\','|'},
{'z', 'Z'}, {'x', 'X'}, {'c', 'C'}, {'v', 'V'},
{'b', 'B'}, {'n', 'N'}, {'m', 'M'}, {',', '<'},
{'.', '>'}, {'/', '?'}, {0x0, 0x0}, {'*', '*'},
{0x0, 0x0}, {' ', ' '}

Keyboard map table.

Temporary hardcoded keyboard map, from kb.c in SkelixOS.

See also

Definition at line 92 of file Keyboard.h.

Referenced by read().

◆ m_io

Arch::IO Keyboard::m_io

Port I/O object.

Definition at line 105 of file Keyboard.h.

Referenced by read().

◆ pending

bool Keyboard::pending

Do we have a byte ready?

Definition at line 102 of file Keyboard.h.

Referenced by interrupt(), and read().

◆ shiftState

u8 Keyboard::shiftState

State of the shift key.

Non-zero if pressed, and ZERO otherwise.

Definition at line 99 of file Keyboard.h.

Referenced by read().

The documentation for this class was generated from the following files: