Restructering Kernel folder before moving to higher half kernel
The boot up process will be changed somewhat dramatically, therefor a restructering of the kernel seems as a good starting point.
This commit is contained in:
51
src/kernel/Drivers/PS-2/keyboard.cpp
Normal file
51
src/kernel/Drivers/PS-2/keyboard.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "keyboard.h"
|
||||
|
||||
KeyPressInfo keyPress {};
|
||||
|
||||
void KeyHandled(){
|
||||
keyPress.ScanCode= 0x00;
|
||||
keyPress.PressedModifiers = 0x00;
|
||||
}
|
||||
|
||||
|
||||
char getASCIIKey(){
|
||||
char keyPressed;
|
||||
// Wait until a key is pressed
|
||||
while(keyPress.ScanCode == 0x00) {
|
||||
asm volatile ("NOP");
|
||||
}
|
||||
|
||||
|
||||
// Translate keycode to ascii
|
||||
// Probably a lookup table might be handy
|
||||
// Until 0x37
|
||||
const char* ASCIILookUp =
|
||||
"\01234567890-=\0\0QWERTYUIOP[]\0\0ASDFGHJKL;\'`\0\\ZXCVBNM,./\0";
|
||||
|
||||
uint8_t ASCII_Index = keyPress.ScanCode - 3 ;
|
||||
//printf("ASCII_INDEX: %x\n", ASCII_Index);
|
||||
keyPressed = ASCIILookUp[ASCII_Index];
|
||||
|
||||
KeyHandled();
|
||||
|
||||
return keyPressed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t getKey(){
|
||||
// Wait until a key is pressed
|
||||
while(keyPress.ScanCode == 0x00){
|
||||
asm volatile ("NOP");
|
||||
}
|
||||
|
||||
if( keyPress.ScanCode > 0x37){
|
||||
keyPress.ScanCode = 0x00;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t ScanCode = keyPress.ScanCode;
|
||||
// KeyHandled();
|
||||
|
||||
return ScanCode ;
|
||||
}
|
Reference in New Issue
Block a user