tape-kernel 1.0
a modular modern independent kernel
Loading...
Searching...
No Matches
kb.h File Reference
#include "../lib/types.h"
Include dependency graph for kb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define gtchr   __gtchr
#define scntasci   __scntasci
#define kbreset   __kbreset
#define kbstate   __kbstate

Functions

uint8_t __gtchr (void)
 listens for a character outside of loops from ports
uint8_t __scntasci (uint8_t inpt, uint8_t shifted)
 scntasci converts a keyboard scancode to an ascii character
void __kbreset (void)
 kbreset resets the keyboard modifier states
void __kbstate (uint8_t *shift, uint8_t *caps)
 kbstate exports the current keyboard modifier state

Macro Definition Documentation

◆ gtchr

#define gtchr   __gtchr

Definition at line 6 of file kb.h.

Referenced by __editor(), and __rdln().

◆ kbreset

#define kbreset   __kbreset

Definition at line 8 of file kb.h.

◆ kbstate

#define kbstate   __kbstate

Definition at line 9 of file kb.h.

◆ scntasci

#define scntasci   __scntasci

Definition at line 7 of file kb.h.

Referenced by __gtchr().

Function Documentation

◆ __gtchr()

uint8_t __gtchr ( void )

listens for a character outside of loops from ports

gtchr is a function that directly gets a key pressed from outside of rdln or loops

use of gtchr is done with

#include "../io/kb.h" //or just kb.h
uint8_t key = gtchr(); //also often times in a while(1) loop
if (key == 'e') { do something };
#define gtchr
Definition kb.h:6
unsigned char uint8_t
Definition types.h:28
See also
rdln()

Definition at line 109 of file kb.c.

References caps_lock, inb, scntasci, and shift_pressed.

◆ __kbreset()

void __kbreset ( void )

kbreset resets the keyboard modifier states

kbreset is a function that clears the shift and caps lock states back to their defaults (both off)

using kbreset is done with

#include "../io/kb.h" //or just kb.h
#define kbreset
Definition kb.h:8
See also
kbstate(), gtchr()

Definition at line 203 of file kb.c.

References caps_lock, and shift_pressed.

◆ __kbstate()

void __kbstate ( uint8_t * shift,
uint8_t * caps )

kbstate exports the current keyboard modifier state

kbstate is a function that writes the current shift and caps lock states into the provided pointers

Parameters
shift,apointer to store the shift state (1 = pressed)
caps,apointer to store the caps lock state (1 = enabled)

using kbstate is done with

#include "../io/kb.h" //or just kb.h
uint8_t shift, caps;
kbstate(&shift, &caps);
#define kbstate
Definition kb.h:9
See also
kbreset(), gtchr()

Definition at line 184 of file kb.c.

References caps_lock, and shift_pressed.

◆ __scntasci()

uint8_t __scntasci ( uint8_t inpt,
uint8_t shifted )

scntasci converts a keyboard scancode to an ascii character

scntasci is a function that translates ps/2 scancodes into ascii characters, applying shift and caps lock state for proper casing

Parameters
inpt,theraw scancode byte from the keyboard
shifted,whethershift is currently pressed (1) or not (0)

using scntasci is done with

#include "../io/kb.h" //or just kb.h
uint8_t scancode = inb(0x60);
uint8_t ascii = scntasci(scancode, 0); //convert without shift
#define inb
Definition io.h:6
#define scntasci
Definition kb.h:7
See also
gtchr(), kbstate()

Definition at line 26 of file kb.c.

References caps_lock.