Does my keyboard.h work?
Posted: Sat Nov 12, 2016 9:07 am
I have made my keyboard.h and imported the code that implements everything needed for terminal_writestring and terminal_writestring, and terminal_initialize, and a file that defines inb/outb and many other functions.
However, since my keyboard.h is extremely large, i would want to know if it actually works.
Here are it's functions:
It includes a enum containing all the scancodes of:
the entire 26 letter alphabet, not uppercase/lowercase since the scan code table does not say that, scan code type/table 1
equal sign (=), point (.), single quote ('), slash (/) and all numbers from 0 to 9.
and:
a get scan code function copied from the OSDev website
and a write letter if scan code = anything from the enums that is not and is instead
Here's the code:
However, since my keyboard.h is extremely large, i would want to know if it actually works.
Here are it's functions:
It includes a enum containing all the scancodes of:
the entire 26 letter alphabet, not uppercase/lowercase since the scan code table does not say that, scan code type/table 1
equal sign (=), point (.), single quote ('), slash (/) and all numbers from 0 to 9.
and:
a get scan code function copied from the OSDev website
and a write letter if scan code = anything from the enums that is not
Code: Select all
int a; a="qwertyuiop"
Code: Select all
getkey(){
if key = A then print A
if key = B then print B...
if key = equalsign then print =
Here's the code:
Code: Select all
enum scancodedata {
AP_SCD = 0x1E,
BP_SCD = 0x30,
CP_SCD = 0x2E,
DP_SCD = 0x20,
EP_SCD = 0x12,
FP_SCD = 0x21,
GP_SCD = 0x22,
HP_SCD = 0x23,
IP_SCD = 0x17,
JP_SCD = 0x24,
KP_SCD = 0x25,
LP_SCD = 0x26,
MP_SCD = 0x32,
NP_SCD = 0x31,
OP_SCD = 0x18,
PP_SCD = 0x19,
QP_SCD = 0x10,
RP_SCD = 0x13,
SP_SCD = 0x1F,
TP_SCD = 0x14,
UP_SCD = 0x16,
VP_SCD = 0x2F,
WP_SCD = 0x11,
XP_SCD = 0x2D,
YP_SCD = 0x15,
ZP_SCD = 0x2C,
ENTERP_SCD = 0x1C,
1P_SCD = 0x02,
2P_SCD = 0x03,
3P_SCD = 0x04,
4P_SCD = 0x05,
5P_SCD = 0x06,
6P_SCD = 0x07,
7P_SCD = 0x08,
8P_SCD = 0x09,
9P_SCD = 0x0A,
0P_SCD = 0x0B,
SLASHP_SCD = 0x35,
POINTP_SCD = 0x34,
SINGQUOTP_SCD = 0x28,
EQUALP_SCD = 0x0D,
/* SCD = Scan Code Data
(X)P = (X)Pressed */
};
char getScancode()
{
char c=0;
do {
if(inb(0x60)!=c)
{
c=inb(0x60);
if(c>0)
return c;
}
}while(1);
}
char getchar()
{
return scancode[getScancode()+1];
}
int
getKey()
{
getScancode();
if (scancode == AP_SCD)
{
terminal_writestring("A");
}
if (scancode == BP_SCD)
{
terminal_writestring("B");
}
if (scancode == CP_SCD)
{
terminal_writestring("C");
}
if (scancode == DP_SCD)
{
terminal_writestring("D");
}
if (scancode == EP_SCD)
{
terminal_writestring("E");
}
if (scancode == FP_SCD)
{
terminal_writestring("F");
}
if (scancode == GP_SCD)
{
terminal_writestring("G");
}
if (scancode == HP_SCD)
{
terminal_writestring("H");
}
if (scancode == IP_SCD)
{
terminal_writestring("I");
}
if (scancode == JP_SCD)
{
terminal_writestring("J");
}
if (scancode == KP_SCD)
{
terminal_writestring("K");
}
if (scancode == LP_SCD)
{
terminal_writestring("L");
}
if (scancode == MP_SCD)
{
terminal_writestring("M");
}
if (scancode == NP_SCD)
{
terminal_writestring("N");
}
if (scancode == OP_SCD)
{
terminal_writestring("O");
}
if (scancode == PP_SCD)
{
terminal_writestring("P");
}
if (scancode == QP_SCD)
{
terminal_writestring("Q");
}
if (scancode == RP_SCD)
{
terminal_writestring("R");
}
if (scancode == SP_SCD)
{
terminal_writestring("S");
}
if (scancode == TP_SCD)
{
terminal_writestring("T");
}
if (scancode == UP_SCD)
{
terminal_writestring("U");
}
if (scancode == VP_SCD)
{
terminal_writestring("V");
}
if (scancode == WP_SCD)
{
terminal_writestring("W");
}
if (scancode == XP_SCD)
{
terminal_writestring("X");
}
if (scancode == YP_SCD)
{
terminal_writestring("Y");
}
if (scancode == ZP_SCD)
{
terminal_writestring("Z");
}
if (scancode == ENTERP_SCD)
{
terminal_row = terminal_row++;
terminal_column = 0;
}
if (scancode == 1P_SCD)
{
terminal_writestring("1");
}
if (scancode == 2P_SCD)
{
terminal_writestring("2");
}
if (scancode == 3P_SCD)
{
terminal_writestring("3");
}
if (scancode == 4P_SCD)
{
terminal_writestring("4");
}
if (scancode == 5P_SCD)
{
terminal_writestring("5");
}
if (scancode == 6P_SCD)
{
terminal_writestring("6");
}
if (scancode == 7P_SCD)
{
terminal_writestring("7");
}
if (scancode == 8P_SCD)
{
terminal_writestring("8");
}
if (scancode == 9P_SCD)
{
terminal_writestring("9");
}
if (scancode == 0P_SCD)
{
terminal_writestring("0");
}
if (scancode == SLASHP_SCD)
{
terminal_writestring("/");
}
if (scancode == POINTP_SCD)
{
terminal_writestring(".");
}
if (scancode == SINGQUOTP_SCD)
{
terminal_writestring("'");
}
if (scancode == EQUALP_SCD)
{
terminal_writestring("=");
}
}