MP3 1.0
This is the Doxygen document for ECE391 MP3.
Loading...
Searching...
No Matches
Functions | Variables
keyboard.c File Reference

Functions for keyboard inputs and buffers. More...

#include "i8259.h"
#include "keyboard.h"
#include "lib.h"
#include "terminal.h"

Functions

void keyboardInit ()
 Initializes the keyboard by enabling its interrupts to the PIC. More...
 
void keyboardInterrupt ()
 Handler for keyboard interrupt. More...
 
int populateKeyboardBuffer (char c)
 Add the input character c into the keyboard buffer. More...
 
void clearKeyboardBuffer ()
 Wipe the keyboard buffer. More...
 
void transferKeyboardBuffer (char *buf, int32_t nbytes)
 Transfer nbytes of the active terminal's keyboard buffer into the provided buf. More...
 
void checkTerminalSwap (unsigned char i)
 Checks keyboard inputs to see if terminal swap command issued. More...
 

Variables

int cap
 
int lshift
 
int rshift
 
int shift
 
int ctrlPressed = 0
 
int altPressed = 0
 
unsigned char scancodeToChar [SCANCODE_ARRAY_SIZE]
 [Caps lock OFF,shift OFF]Array to translate scancode given by keyboard to corresponding character. More...
 
unsigned char scancodeToCharCapOn [SCANCODE_ARRAY_SIZE]
 [Caps lock ON,shift OFF]Array to translate scancode given by keyboard to corresponding character. More...
 
unsigned char scancodeToCharShiftOn [SCANCODE_ARRAY_SIZE]
 [Caps lock OFF,shift ON]Array to translate scancode given by keyboard to corresponding character. More...
 
unsigned char scancodeToCharShiftOnCapOn [SCANCODE_ARRAY_SIZE]
 [Caps lock ON,shift ON]Array to translate scancode given by keyboard to corresponding character. More...
 

Detailed Description

Functions for keyboard inputs and buffers.

Author
Group 8
Version
1.0
Date
2023-03-11

Function Documentation

◆ checkTerminalSwap()

void checkTerminalSwap ( unsigned char  i)

Checks keyboard inputs to see if terminal swap command issued.

Parameters
iHexcode returned from keyboard for current key pressed / released.
Note
This function enters swapTerminal if valid F key is pressed.

◆ clearKeyboardBuffer()

void clearKeyboardBuffer ( )

Wipe the keyboard buffer.

◆ keyboardInit()

void keyboardInit ( )

Initializes the keyboard by enabling its interrupts to the PIC.

◆ keyboardInterrupt()

void keyboardInterrupt ( )

Handler for keyboard interrupt.

Takes scancode and indexes into array to print relevant character. Also handle special cases such as shift, caps lock, ctrl + L, enter, backspace, tab, and Alt + F1/F2/F3 (terminal swaps).

Note
Always uses kputc instead of putc in order to always write to display.

◆ populateKeyboardBuffer()

int populateKeyboardBuffer ( char  c)

Add the input character c into the keyboard buffer.

Parameters
cThe character to be added to the corresponding keyboard buffer.
Returns
0 on success.
-1 on failure.
Note
If buffer is full, we stall and don't take any more key presses.

◆ transferKeyboardBuffer()

void transferKeyboardBuffer ( char *  buf,
int32_t  nbytes 
)

Transfer nbytes of the active terminal's keyboard buffer into the provided buf.

Parameters
bufBuffer that will contain the characters transfered.
nbytesNumber of bytes to copy.
Warning
This clears the active terminal's keyboard buffer.

Variable Documentation

◆ altPressed

int altPressed = 0

◆ cap

int cap

◆ ctrlPressed

int ctrlPressed = 0

◆ lshift

int lshift

◆ rshift

int rshift

◆ scancodeToChar

unsigned char scancodeToChar[SCANCODE_ARRAY_SIZE]

[Caps lock OFF,shift OFF]Array to translate scancode given by keyboard to corresponding character.

Note
Null characters for those that aren't printed typically or we do not support yet.

◆ scancodeToCharCapOn

unsigned char scancodeToCharCapOn[SCANCODE_ARRAY_SIZE]

[Caps lock ON,shift OFF]Array to translate scancode given by keyboard to corresponding character.

Note
Null characters for those that aren't printed typically or we do not support yet.

◆ scancodeToCharShiftOn

unsigned char scancodeToCharShiftOn[SCANCODE_ARRAY_SIZE]

[Caps lock OFF,shift ON]Array to translate scancode given by keyboard to corresponding character.

Note
Null characters for those that aren't printed typically or we do not support yet.

◆ scancodeToCharShiftOnCapOn

unsigned char scancodeToCharShiftOnCapOn[SCANCODE_ARRAY_SIZE]

[Caps lock ON,shift ON]Array to translate scancode given by keyboard to corresponding character.

Note
Null characters for those that aren't printed typically or we do not support yet.

◆ shift

int shift