From 10bc7e539400394b479ce0595ab9a051d6ce0263 Mon Sep 17 00:00:00 2001 From: vinsdragonis Date: Mon, 21 Feb 2022 04:19:43 +0530 Subject: [PATCH] Added keyboard support --- boot/bin/boot.bin | Bin 512 -> 512 bytes boot/bin/kernel.bin | Bin 12276 -> 14744 bytes boot/bin/kernel.img | Bin 18430 -> 22857 bytes boot/bin/kernel.o | Bin 15602 -> 20355 bytes boot/boot.asm | 2 +- boot/input.c | 357 +++++++++++++++++++++++++++++++++++++++++++- boot/main.c | 28 +++- os.img | Bin 12788 -> 15256 bytes 8 files changed, 380 insertions(+), 7 deletions(-) diff --git a/boot/bin/boot.bin b/boot/bin/boot.bin index 1b58b24d8594f321b233370b08884cb01a642f1d..876622ba863d975630f2eb77b9105982ce6a780b 100644 GIT binary patch delta 12 TcmZo*X<(V4!YIE{^)@2_7GndC delta 12 TcmZo*X<(V4!YH{>^)@2_7DWSz diff --git a/boot/bin/kernel.bin b/boot/bin/kernel.bin index 6dc08c0b9bb908033d3c779c646cd005d188e059..b246411f07ae04d003a549260b2f790c1090951f 100644 GIT binary patch delta 3505 zcmZ|SYfMvT7zgmTwUx@nRs?19R#X%$2!c5AGTG!zr>F=b>U5$AtMxjhD$a6hIx-r< zqG@y{`(mwI7X9FsOeouup)(fu!OJ$c`9Y(bj?=YS+#o_Sw0r*NZDA+z^h3}8JkRev z_qK2Qww^waCS||ESm-%36gwHKmd?*&Y}?Ih>CP8v+p{(ow=h=cTTUG>;$_KH=UYu{ zbpibfS{T?heJL$zv5FQSdY8-o3}rdW{!>~bf0h>T=V(cbPn@2gv-(Pn?Oi@r#+c1) zJwtWr;PXhtb=6=q+su-U=i}GEt8_nhg$+`NhA~>k>kN2!U(XrTeNbC7fYK)II zKI4tWLyhP1LFnj!cStj%RVGQ%YPIyVa8TZzt6SS5L}*JlVl5ibFZT>o_4BH+U5J#? zk=^$k&0Zro8EfvcCs489^}x{F)llqZR5P|$_O~3@QIc0(T^b+Cd}Tn}6d%xI9WSbR z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}+~*k}B6?6W+N{UQE$*k{c70d`|D6>-FwC{vE=TfAfOI)JvtarCV<0C@Gl z1v`;~Ha$tMn_LgkKBAY1UPIbw*nJ#t~jPf?KJy#~vp- zMKn%yo@m04^UEPWk-S3W4lG1ViF`x`QmsAR5E2f;@8b{>{v(ax8?FrLQ=%`4zFr^$ z&Lgg~6Z1sB5={}!BFTbtL@V%cq`QZx21(Z2MD#Gx6GR454dDJ=kR~~fw8>t~IV5?; z-y?}1Di>Ttl7|zaU?n2J4kXdDn>-q3)_e~iC!oA5O98(c!s1&jF-IM^3>1|hyI z;$y(qM5^#1(j2K$+`xMy_c6vlic~dtL?$-zOmZ;s7%8(qFYe0bbDSvUE~`0(^b diff --git a/boot/boot.asm b/boot/boot.asm index ea84c96..0230920 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -64,7 +64,7 @@ section code mov bx, 0x1000 ; location of the code being loaded from the hard disk mov ah, 0x02 - mov al, 25 ; number of sectors to read from the hard disk + mov al, 31 ; number of sectors to read from the hard disk mov ch, 0x00 mov dh, 0x00 mov cl, 0x02 diff --git a/boot/input.c b/boot/input.c index 1ee9844..f355015 100644 --- a/boot/input.c +++ b/boot/input.c @@ -5,6 +5,11 @@ int left_clicked, right_clicked, middle_clicked; int current_byte = 0; uint8_t bytes[4] = {0}; +int Scancode = -1; + +#define TRUE 1 +#define FALSE 0 + #define pic1_command 0x20 #define pic1_data 0x21 #define pic2_command 0xa0 @@ -98,11 +103,11 @@ void RemapPIC() { } void HandleISR1() { - inportb(0x60); + Scancode = inportb(0x60); outportb(0xa0, 0x20); outportb(0x20, 0x20); - clearScreen(0, 0, 255); + // clearScreen(0, 0, 0); } void HandleMouseInterrupt(); @@ -202,7 +207,7 @@ void HandleMousePacket() { uint8_t status = bytes[0]; int32_t change_x = (int32_t) bytes[1]; int32_t change_y = (int32_t)bytes[2]; - int mouse_speed = 3; + int mouse_speed = 2; if (status & x_overflow || status & y_overflow) return; @@ -237,3 +242,349 @@ void HandleMousePacket() { else if (y > VBE->y_resolution) y = VBE->y_resolution; } + +int shift_pressed = FALSE; +int caps_pressed = FALSE; +int escape_pressed = FALSE; +int backspace_pressed = FALSE; +int alt_pressed = FALSE; +int ctrl_pressed = FALSE; +int enter_pressed = FALSE; + +unsigned char ProcessScancode(int scancode) +{ + if (scancode == 0x01) + escape_pressed = TRUE; + + else if (scancode == 0x02) + if (shift_pressed == TRUE) + return '!'; + else + return '1'; + + else if (scancode == 0x03) + if (shift_pressed == TRUE) + return '"'; + else + return '2'; + + else if (scancode == 0x04) + if (shift_pressed == TRUE) + return '#'; + else + return '3'; + + else if (scancode == 0x05) + if (shift_pressed == TRUE) + return '$'; + else + return '4'; + + else if (scancode == 0x06) + if (shift_pressed == TRUE) + return '%'; + else + return '5'; + + else if (scancode == 0x07) + if (shift_pressed == TRUE) + return '^'; + else + return '6'; + + else if (scancode == 0x08) + if (shift_pressed == TRUE) + return '&'; + else + return '7'; + + else if (scancode == 0x09) + if (shift_pressed == TRUE) + return '*'; + else + return '8'; + + else if (scancode == 0x0A) + if (shift_pressed == TRUE) + return '('; + else + return '9'; + + else if (scancode == 0x0B) + if (shift_pressed == TRUE) + return ')'; + else + return '0'; + + else if (scancode == 0x0C) + if (shift_pressed == TRUE) + return '_'; + else + return '-'; + + else if (scancode == 0x0D) + if (shift_pressed == TRUE) + return '+'; + else + return '='; + + // Backspace + else if (scancode == 0x0E) + backspace_pressed = TRUE; + + else if (scancode == 0x0F) + return '\t'; + + else if (scancode == 0x10) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'Q'; + else + return 'q'; + + else if (scancode == 0x11) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'W'; + else + return 'w'; + + else if (scancode == 0x12) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'E'; + else + return 'e'; + + else if (scancode == 0x13) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'R'; + else + return 'r'; + + else if (scancode == 0x14) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'T'; + else + return 't'; + + else if (scancode == 0x15) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'Y'; + else + return 'y'; + + else if (scancode == 0x16) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'U'; + else + return 'u'; + + else if (scancode == 0x17) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'I'; + else + return 'i'; + + else if (scancode == 0x18) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'O'; + else + return 'o'; + + else if (scancode == 0x19) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'P'; + else + return 'p'; + + else if (scancode == 0x1A) + if (shift_pressed == TRUE) + return '{'; + else + return '['; + + else if (scancode == 0x1B) + if (shift_pressed == TRUE) + return '}'; + else + return ']'; + + // enter pressed + else if (scancode == 0x1C) + { + enter_pressed = TRUE; + return '\n'; + } + + // ctrl pressed + else if (scancode == 0x1D) + ctrl_pressed = TRUE; + + else if (scancode == 0x1E) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'A'; + else + return 'a'; + + else if (scancode == 0x1F) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'S'; + else + return 's'; + + else if (scancode == 0x20) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'D'; + else + return 'd'; + + else if (scancode == 0x21) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'F'; + else + return 'f'; + + else if (scancode == 0x22) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'G'; + else + return 'g'; + + else if (scancode == 0x23) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'H'; + else + return 'h'; + + else if (scancode == 0x24) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'J'; + else + return 'j'; + + else if (scancode == 0x25) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'K'; + else + return 'k'; + + else if (scancode == 0x26) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'L'; + else + return 'l'; + + else if (scancode == 0x27) + if (shift_pressed == TRUE) + return ':'; + else + return ';'; + + else if (scancode == 0x28) + if (shift_pressed == TRUE) + return '@'; + else + return '\''; + + else if (scancode == 0x29) + if (shift_pressed == TRUE) + return '~'; + else + return '`'; + + // shift pressed + else if (scancode == 0x2A) + shift_pressed = TRUE; + + else if (scancode == 0x2B) + if (shift_pressed == TRUE) + return '|'; + else + return '\\'; + + else if (scancode == 0x2C) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'Z'; + else + return 'z'; + + else if (scancode == 0x2D) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'X'; + else + return 'x'; + + else if (scancode == 0x2E) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'C'; + else + return 'c'; + + else if (scancode == 0x2F) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'V'; + else + return 'v'; + + else if (scancode == 0x30) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'B'; + else + return 'b'; + + else if (scancode == 0x31) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'N'; + else + return 'n'; + + else if (scancode == 0x32) + if (shift_pressed == TRUE || caps_pressed == TRUE) + return 'M'; + else + return 'm'; + + else if (scancode == 0x33) + if (shift_pressed == TRUE) + return '<'; + else + return ','; + + else if (scancode == 0x34) + if (shift_pressed == TRUE) + return '>'; + else + return '.'; + + else if (scancode == 0x35) + if (shift_pressed == TRUE) + return '?'; + else + return '/'; + + // shift pressed + else if (scancode == 0x36) + shift_pressed = TRUE; + + // alt pressed + else if (scancode == 0x38) + alt_pressed = TRUE; + + else if (scancode == 0x39) + return ' '; + + // Caps pressed + else if (scancode == 0x3A) + if (caps_pressed == TRUE) + caps_pressed = FALSE; + else if (caps_pressed == FALSE) + caps_pressed = TRUE; + + // shift released + if (scancode == 0xAA) + shift_pressed = FALSE; + + // shift released + if (scancode == 0xB6) + shift_pressed = FALSE; + + return '\0'; +} \ No newline at end of file diff --git a/boot/main.c b/boot/main.c index a03a956..7d8bc95 100644 --- a/boot/main.c +++ b/boot/main.c @@ -1,7 +1,7 @@ #include "graphics/graphics.h" int start() { - VBEInfoBlock *VBE = (VBEInfoBlock *)VBEInfoAddress; + VBEInfoBlock *VBE = (VBEInfoBlock*) VBEInfoAddress; x = VBE->x_resolution / 2; y = VBE->y_resolution / 2; @@ -10,6 +10,10 @@ int start() { char header[] = "Welcome to Wyvern OS!"; char *p = header; + char characterBuffer[1000] = "\0"; + char *characterBufferPointer = characterBuffer; + int characterBufferLength = 0; + base = (unsigned int) &isr1; base12 = (unsigned int) &isr12; @@ -17,16 +21,34 @@ int start() { InitializeMouse(); while (1) { - clearScreen(181.0f / 255.0f * 16.0f, 232.0f / 255.0f * 32.0f, 255.0f / 255.0f * 16.0f); + char c = ProcessScancode(Scancode); + + if (backspace_pressed == TRUE) + { + characterBuffer[characterBufferLength - 1] = '\0'; + characterBufferLength--; + backspace_pressed = FALSE; + Scancode = -1; + } + else if (c != '\0') + { + characterBuffer[characterBufferLength] = c; + characterBuffer[characterBufferLength + 1] = '\0'; + characterBufferLength++; + Scancode = -1; + } + + clearScreen(90.0f / 255.0f * 16.0f, 120.0f / 255.0f * 32.0f, 120.0f / 255.0f * 16.0f); DrawRect(150, 140, 350, 40, 0, 0, 0); DrawString(getArialCharacter, font_arial_width, font_arial_height, p, 240, 150, 255, 255, 255); + DrawString(getArialCharacter, font_arial_width, font_arial_height, characterBufferPointer, 240, 180, 255, 255, 255); DrawRect(300, 300, 50, 50, 20, 200, 50); DrawRect(325, 325, 50, 50, 200, 50, 50); // DrawRect(x, y, 10, 10, 0, 0, 0); - DrawMouse(x, y, 40.0, 100.0 / 255.0 * 32, 100.0 / 255.0 * 16); + DrawMouse(x, y, 50.0, 150.0 / 255.0 * 32, 150.0 / 255.0 * 16); Flush(); } diff --git a/os.img b/os.img index 82d79eef7b4c9602b3b64a7cb483379745e7ebac..dc015a30eee16a87968234dbcc84ae1802ec6fb8 100644 GIT binary patch delta 3513 zcmZ|SYiv_x7zgn8l$Mok&@wuha_eAY8>8$3L#{GqM-av+_lux|!5r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