Keyboard Stuff
This commit is contained in:
parent
7fa557d685
commit
a1c05dc279
@ -1,6 +1,6 @@
|
||||
/*----------------*\
|
||||
|Nanite OS |
|
||||
|Copyright (C) 2024|
|
||||
|Copyright (C) 2025|
|
||||
|Tyler McGurrin |
|
||||
\*----------------*/
|
||||
#include "keyboard.h"
|
||||
@ -9,17 +9,9 @@
|
||||
#include <arch/i686/io.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define PS2_KEYBOARD_PORT 0x60
|
||||
|
||||
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) {
|
||||
void Print_Key(int scancode) {
|
||||
char* key;
|
||||
switch (scancode) {
|
||||
|
||||
case KEYSCAN_1:
|
||||
key = "1";
|
||||
@ -356,18 +348,6 @@ switch (scancode) {
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
void Keyboard_Handler()
|
||||
{
|
||||
char* key = Keyboard_Scanner();
|
||||
}
|
||||
printf("%s", key);
|
||||
return;
|
||||
}
|
||||
|
||||
void Keyboard_Init()
|
||||
{
|
||||
i686_IRQ_RegisterHandler(1, Keyboard_Handler);
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
/*----------------*\
|
||||
|Nanite OS |
|
||||
|Copyright (C) 2024|
|
||||
|Copyright (C) 2025|
|
||||
|Tyler McGurrin |
|
||||
\*----------------*/
|
||||
#pragma once
|
||||
|
||||
void Keyboard_Init();
|
||||
void Print_Key(int scancode);
|
||||
|
||||
typedef enum {
|
||||
typedef enum { // ill do it LATER!
|
||||
KEYSCAN_ESC = 1 ,
|
||||
KEYSCAN_1 = 2 ,
|
||||
KEYSCAN_2 = 3 ,
|
||||
|
||||
@ -15,15 +15,25 @@
|
||||
#include "../libs/version.h"
|
||||
#include "../libs/boot/bootparams.h"
|
||||
|
||||
#define PS2_KEYBOARD_PORT 0x60
|
||||
|
||||
extern uint8_t __bss_start;
|
||||
extern uint8_t __end;
|
||||
|
||||
int uptime;
|
||||
void timer(Registers* regs)
|
||||
{
|
||||
int 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) {
|
||||
|
||||
// print logo
|
||||
@ -40,10 +50,12 @@ void __attribute__((section(".entry"))) start(BootParams* bootParams) {
|
||||
|
||||
i686_IRQ_RegisterHandler(0, timer);
|
||||
printf("Load Keyboard Driver...");
|
||||
Keyboard_Init();
|
||||
i686_IRQ_RegisterHandler(1, keyboard);
|
||||
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("Memory Region Count: %x\n", bootParams->Memory.RegionCount);
|
||||
// for (int i = 0; i < bootParams->Memory.RegionCount; i++) {
|
||||
|
||||
21
src/kernel/util/util.c
Normal file
21
src/kernel/util/util.c
Normal 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
7
src/kernel/util/util.h
Normal file
@ -0,0 +1,7 @@
|
||||
/*----------------*\
|
||||
|Nanite OS |
|
||||
|Copyright (C) 2025|
|
||||
|Tyler McGurrin |
|
||||
\*----------------*/
|
||||
int string_length(char s[]);
|
||||
void append(char s[], char n);
|
||||
Loading…
x
Reference in New Issue
Block a user