Added support for the shift key in the keyboard driver.

This commit is contained in:
2018-11-11 16:31:41 -06:00
parent af15d43c8a
commit a061366ff2
6 changed files with 36 additions and 6 deletions
+18 -2
View File
@@ -44,6 +44,9 @@ unsigned char kbdus[128] =
0, /* F12 Key */
0, /* All other keys are undefined */
};
bool shift = false;
/* Handles the keyboard interrupt */
void keyboard_handler(struct regs *r)
{
@@ -58,13 +61,21 @@ void keyboard_handler(struct regs *r)
{
/* You can use this one to see if the user released the
* shift, alt, or control keys... */
if(scancode == 0xAA || scancode == 0xB6)
{
shift = false;
}
}
else
{
/* Here, a key was just pressed. Please note that if you
* hold a key down, you will get repeated key press
* interrupts. */
if(scancode == 0x2A || scancode == 0x36)
{
shift = true;
return;
}
/* Just to show you how this works, we simply translate
* the keyboard scancode into an ASCII value, and then
* display it to the screen. You can get creative and
@@ -73,7 +84,12 @@ void keyboard_handler(struct regs *r)
* to the above layout to correspond to 'shift' being
* held. If shift is held using the larger lookup table,
* you would add 128 to the scancode when you look for it */
putch(kbdus[scancode]);
unsigned char* letter = kbdus[scancode];
if(shift)
{
letter = letter - 32;
}
putch(letter);
}
}
+2 -2
View File
@@ -63,8 +63,8 @@ void outportb (unsigned short _port, unsigned char _data)
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
}
extern char __BUILD_DATE;
extern char __BUILD_NUMBER;
//extern char __BUILD_DATE;
//extern char __BUILD_NUMBER;
/* This is a very simple main() function. All it does is sit in an
* infinite loop. This will be like our 'idle' loop */