-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
148 additions
and
188 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,80 @@ | ||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <kernel/idt.h> | ||
#include <stdio.h> | ||
#include <util.h> | ||
#include <stdbool.h> // compiler | ||
#include <stddef.h> // compiler | ||
#include <stdint.h> // compiler | ||
#include <kernel/idt.h> // more keyboard | ||
#include <stdio.h> // vkprintf kprintf putchar | ||
#include <util.h> // various (itoa etc) | ||
#include <mem/alloc.h> // kmalloc | ||
#include <mem/memcmp.h> // memcmp | ||
#include <mem/memcpy.h> | ||
#include <io/clr.h> | ||
#include "keyboard.h" | ||
#include <time.h> | ||
#include <io/util.h> | ||
#include <mem/memcpy.h> // memcpy | ||
#include <io/clr.h> // colors | ||
#include "keyboard.h" // keyboard map | ||
#include <sys/time.h> // timing | ||
#include <io/util.h> // comparison functions | ||
#include <sys/ssp.h> // stack smash protector | ||
#include <kernel/io/cmds.h> // cmd callbacks | ||
#include "kinit.c" // kernel init, called before kmain | ||
|
||
int counter=0; // counts how many keys have been pressed | ||
char typed[1024]; // holds current line of keyboard input | ||
char just_typed[1024]; // holds input that was typed before enter was pressed | ||
void dellast(void) { | ||
// deletes last character from working keyboard memory | ||
typed[counter]='\0'; | ||
counter--; | ||
typed[counter]='\0'; | ||
counter--; | ||
} | ||
void keyboard_handler_main(void) | ||
{ | ||
void keyboard_handler_main(void) { | ||
// handles keyboard input, called by boot.asm | ||
unsigned char status; | ||
char keycode; | ||
write_port(0x20, 0x20); | ||
unsigned char status; | ||
char keycode; | ||
write_port(0x20, 0x20); | ||
|
||
status = read_port(KEYBOARD_STATUS_PORT); | ||
if (status & 0x01) { | ||
keycode = read_port(KEYBOARD_DATA_PORT); | ||
if(keycode<0) | ||
return; | ||
else if(keycode == ENTER_KEY_CODE) { | ||
kprintf("\n"); // checktype(); | ||
status = read_port(KEYBOARD_STATUS_PORT); | ||
if (status & 0x01) { | ||
keycode = read_port(KEYBOARD_DATA_PORT); | ||
if(keycode<0) | ||
return; | ||
else if(keycode==ENTER_KEY_CODE) { | ||
kprintf("\n"); // checktype(); | ||
terminal_column--; | ||
for (int it=0;it<1024;it++) { | ||
just_typed[it]='\0'; | ||
} | ||
memcpy(just_typed,typed,1024); | ||
for (int it=0;it<1024;it++) { | ||
typed[it]='\0'; | ||
} | ||
counter=0; | ||
for (int it=0;it<1024;it++) { | ||
typed[it]='\0'; | ||
} | ||
counter=0; | ||
return; | ||
} else if (keys(keycode)=='`') { | ||
dellast(); | ||
terminal_column--; | ||
return; | ||
} else if (keys(keycode)=='`') { | ||
dellast(); | ||
terminal_column--; | ||
write_to(' ', terminal_color, terminal_column, terminal_row); | ||
return; | ||
} else { | ||
typed[counter]=keys(keycode); | ||
counter++; | ||
const char key=keys(keycode); | ||
} | ||
setclr(deftype(),0); | ||
write_to(' ', terminal_color, terminal_column, terminal_row); | ||
return; | ||
} else { | ||
typed[counter]=keys(keycode); | ||
counter++; | ||
const char key=keys(keycode); | ||
} | ||
setclr(deftype(),0); | ||
const char key=keys(keycode); | ||
putchar(key); | ||
raw_putchar(key); | ||
// terminal_column-=3; | ||
// kprintf(" "); | ||
// terminal_column-=3; | ||
// kprinth(key); | ||
setclr(defcol(),0); | ||
} | ||
} | ||
void hello() { | ||
kprintf("And to you!\n"); | ||
} | ||
void hi() { | ||
kprintf("mom!\n"); | ||
setclr(defcol(),0); | ||
} | ||
} | ||
int kmain() { | ||
term_init(); | ||
idt_init(); | ||
kb_init(); | ||
kprintf("Hello World!\nhi\n"); | ||
kprintn(3); | ||
|
||
int kmain(void) { | ||
vkprintf("s","Hello World!\n"); | ||
while (true){ | ||
while ( | ||
!cmp(just_typed,"hello",hello) && | ||
!cmp(just_typed,"hi",hi) | ||
) {} // while neither of these have just been typed, do nothing. once they have been, erase them to avoid an infinite loop | ||
for (int it=0;it<1024;it++) { | ||
just_typed[it]='\0'; | ||
} | ||
just_typed[it]='\0'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
int kinit(void) { | ||
term_init(); | ||
idt_init(); | ||
kb_init(); | ||
setclr(defcol(),0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
void hello() { | ||
kprintf("And to you!\n"); | ||
} | ||
void hi() { | ||
kprintf("mom!\n"); | ||
} |
Oops, something went wrong.