Adding a skeleton for the memory management code
Moved the PMM away from being object orientated as it is just plain annoying renamed src folder to source Set timeout to 5 seconds in the grub config
This commit is contained in:
		
							
								
								
									
										51
									
								
								source/kernel/Drivers/PS-2/keyboard.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								source/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 ;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								source/kernel/Drivers/PS-2/keyboard.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								source/kernel/Drivers/PS-2/keyboard.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "../../Terminal/kterm.h"
 | 
			
		||||
typedef enum ScanCodeSet{
 | 
			
		||||
    None            =   0,
 | 
			
		||||
    ScanCodeSet1    =   1,
 | 
			
		||||
    ScanCodeSet2    =   2,
 | 
			
		||||
    ScanCodeSet3    =   3,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef enum Modifiers{
 | 
			
		||||
    LSHIFT  =   1,
 | 
			
		||||
    RSHIFT  =   2,
 | 
			
		||||
 | 
			
		||||
    LCTRL   =   3,
 | 
			
		||||
    RCTRL   =   4,
 | 
			
		||||
 | 
			
		||||
    LALT    =   5,
 | 
			
		||||
    RALT    =   6
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct KeyPressInfo{ 
 | 
			
		||||
    uint8_t PressedModifiers;
 | 
			
		||||
    uint8_t ScanCode;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
extern KeyPressInfo keyPress;
 | 
			
		||||
 | 
			
		||||
void KeyHandled();
 | 
			
		||||
 | 
			
		||||
char getASCIIKey();
 | 
			
		||||
uint8_t getKey();
 | 
			
		||||
		Reference in New Issue
	
	Block a user