Keyboard Stuff

This commit is contained in:
Tyler McGurrin 2025-05-29 06:42:24 -04:00
parent 7fa557d685
commit a1c05dc279
5 changed files with 425 additions and 405 deletions

View File

@ -1,6 +1,6 @@
/*----------------*\ /*----------------*\
|Nanite OS | |Nanite OS |
|Copyright (C) 2024| |Copyright (C) 2025|
|Tyler McGurrin | |Tyler McGurrin |
\*----------------*/ \*----------------*/
#include "keyboard.h" #include "keyboard.h"
@ -9,16 +9,8 @@
#include <arch/i686/io.h> #include <arch/i686/io.h>
#include <stdio.h> #include <stdio.h>
#define PS2_KEYBOARD_PORT 0x60 void Print_Key(int scancode) {
char* key;
char* Keyboard_Scanner()
{
int scancode;
char* key = "";
scancode = i686_inb(PS2_KEYBOARD_PORT);
// Debug Message, unneeded
// printf("Keycode = %d Port = %d\n", keycode, PS2_KEYBOARD_PORT);
switch (scancode) { switch (scancode) {
case KEYSCAN_1: case KEYSCAN_1:
@ -357,17 +349,5 @@ switch (scancode) {
break; break;
} }
return key;
}
void Keyboard_Handler()
{
char* key = Keyboard_Scanner();
printf("%s", key); printf("%s", key);
return;
}
void Keyboard_Init()
{
i686_IRQ_RegisterHandler(1, Keyboard_Handler);
} }

View File

@ -1,13 +1,13 @@
/*----------------*\ /*----------------*\
|Nanite OS | |Nanite OS |
|Copyright (C) 2024| |Copyright (C) 2025|
|Tyler McGurrin | |Tyler McGurrin |
\*----------------*/ \*----------------*/
#pragma once #pragma once
void Keyboard_Init(); void Print_Key(int scancode);
typedef enum { typedef enum { // ill do it LATER!
KEYSCAN_ESC = 1 , KEYSCAN_ESC = 1 ,
KEYSCAN_1 = 2 , KEYSCAN_1 = 2 ,
KEYSCAN_2 = 3 , KEYSCAN_2 = 3 ,

View File

@ -15,15 +15,25 @@
#include "../libs/version.h" #include "../libs/version.h"
#include "../libs/boot/bootparams.h" #include "../libs/boot/bootparams.h"
#define PS2_KEYBOARD_PORT 0x60
extern uint8_t __bss_start; extern uint8_t __bss_start;
extern uint8_t __end; extern uint8_t __end;
int uptime;
void timer(Registers* regs) void timer(Registers* regs)
{ {
int uptime;
uptime++; uptime++;
} }
int keyboard_scancode;
void keyboard()
{
keyboard_scancode = i686_inb(PS2_KEYBOARD_PORT);
// Debug Message, need to make a serial output thingy :)
// printf("Keycode = %d Port = %d\n", keycode, PS2_KEYBOARD_PORT);
}
void __attribute__((section(".entry"))) start(BootParams* bootParams) { void __attribute__((section(".entry"))) start(BootParams* bootParams) {
// print logo // print logo
@ -40,10 +50,12 @@ void __attribute__((section(".entry"))) start(BootParams* bootParams) {
i686_IRQ_RegisterHandler(0, timer); i686_IRQ_RegisterHandler(0, timer);
printf("Load Keyboard Driver..."); printf("Load Keyboard Driver...");
Keyboard_Init(); i686_IRQ_RegisterHandler(1, keyboard);
printf("Done!\n"); printf("Done!\n");
printf("%d", uptime);
// Debug Info for Memory :3
// Debug Info for Memory :3 i REALLY need to make a like serial debug output thingy
// printf("Boot Device: %x\n", bootParams->BootDevice); // printf("Boot Device: %x\n", bootParams->BootDevice);
// printf("Memory Region Count: %x\n", bootParams->Memory.RegionCount); // printf("Memory Region Count: %x\n", bootParams->Memory.RegionCount);
// for (int i = 0; i < bootParams->Memory.RegionCount; i++) { // for (int i = 0; i < bootParams->Memory.RegionCount; i++) {

21
src/kernel/util/util.c Normal file
View File

@ -0,0 +1,21 @@
/*----------------*\
|Nanite OS |
|Copyright (C) 2024|
|Tyler McGurrin |
\*----------------*/
#include "util.h"
int string_length(char s[]) {
int i = 0;
while (s[i] != '\0') {
++i;
}
return i;
}
void append(char s[], char n) {
int len = string_length(s);
s[len] = n;
s[len + 1] = '\0';
}

7
src/kernel/util/util.h Normal file
View File

@ -0,0 +1,7 @@
/*----------------*\
|Nanite OS |
|Copyright (C) 2025|
|Tyler McGurrin |
\*----------------*/
int string_length(char s[]);
void append(char s[], char n);