WKern
Loading...
Searching...
No Matches
keyin.c File Reference
#include <global.h>
#include <io/kio.h>

Go to the source code of this file.

Functions

unsigned char scancode_to_ascii (unsigned char scancode)
 Converts a keyboard scancode to an ASCII character.
unsigned char Keytoshift (unsigned char ascii)
 Converts an ASCII character to its shifted equivalent.
void Irq1HandlerC (void)
 IRQ handler for PS/2 keyboard (IRQ1).
char Kgetkey ()
 Gets the next character from the keyboard buffer (blocking).
void Kgetstr (char *str, int length)
 Reads a line of input from the keyboard (blocking).
void Kflush ()
 Flushes the keyboard controller input buffer.

Variables

volatile char Keybuf [256]
 Circular buffer storing incoming keystrokes.
volatile int buf_head = 0
 Head index for Keybuf.
volatile int buf_tail = 0
 Tail index for Keybuf.

Function Documentation

◆ Irq1HandlerC()

void Irq1HandlerC ( void )

IRQ handler for PS/2 keyboard (IRQ1).

Reads raw scancode, handles modifier keys (Shift, CapsLock), converts to ASCII, and stores in the Keybuf ring buffer.

Definition at line 130 of file keyin.c.

◆ Keytoshift()

unsigned char Keytoshift ( unsigned char ascii)

Converts an ASCII character to its shifted equivalent.

Parameters
asciiThe base character
Returns
Shifted version of the input character, or the same character if no shift mapping exists.

Definition at line 73 of file keyin.c.

◆ Kflush()

void Kflush ( )

Flushes the keyboard controller input buffer.

Reads and discards all unread bytes in the controller’s 0x60 port.

Definition at line 219 of file keyin.c.

◆ Kgetkey()

char Kgetkey ( )

Gets the next character from the keyboard buffer (blocking).

Returns
The next ASCII character from the input buffer.

Definition at line 169 of file keyin.c.

◆ Kgetstr()

void Kgetstr ( char * str,
int length )

Reads a line of input from the keyboard (blocking).

Handles basic line editing (Enter, Backspace, Delete).

Parameters
strDestination buffer
lengthMaximum buffer length (including null terminator)

Definition at line 186 of file keyin.c.

◆ scancode_to_ascii()

unsigned char scancode_to_ascii ( unsigned char scancode)

Converts a keyboard scancode to an ASCII character.

Parameters
scancodeThe raw scancode from keyboard hardware.
Returns
Corresponding ASCII character, or 0 if unmapped.

Definition at line 33 of file keyin.c.

Variable Documentation

◆ buf_head

volatile int buf_head = 0

Head index for Keybuf.

Definition at line 65 of file keyin.c.

◆ buf_tail

volatile int buf_tail = 0

Tail index for Keybuf.

Definition at line 67 of file keyin.c.

◆ Keybuf

volatile char Keybuf[256]

Circular buffer storing incoming keystrokes.

Definition at line 63 of file keyin.c.