Added support for the shift key in the keyboard driver.
This commit is contained in:
+2
-1
@@ -1,2 +1,3 @@
|
|||||||
obj/
|
obj/
|
||||||
iso/
|
iso/
|
||||||
|
kernel.iso
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Create an auto-incrementing build number.
|
||||||
|
|
||||||
|
BUILD_NUMBER_LDFLAGS = --defsym __BUILD_DATE=$$(date +'%Y%m%d')
|
||||||
|
BUILD_NUMBER_LDFLAGS += --defsym __BUILD_NUMBER=$$(cat $(BUILD_NUMBER_FILE))
|
||||||
|
|
||||||
|
# Build number file. Increment if any object file changes.
|
||||||
|
$(BUILD_NUMBER_FILE): $(OBJECTS)
|
||||||
|
if ! test -f build-number.txt; then echo 0 > build-number.txt; fi
|
||||||
|
echo $(($(cat build-number.txt) + 1)) > build-number.txt
|
||||||
|
echo __BUILD_DATE
|
||||||
|
echo __BUILD_NUMBER
|
||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
#ifndef __SYSTEM_H
|
#ifndef __SYSTEM_H
|
||||||
#define __SYSTEM_H
|
#define __SYSTEM_H
|
||||||
|
/* Primitives */
|
||||||
|
typedef enum { false, true } bool;
|
||||||
/* MAIN.C */
|
/* MAIN.C */
|
||||||
extern unsigned char *memcpy(unsigned char *dest, const unsigned char *src, int count);
|
extern unsigned char *memcpy(unsigned char *dest, const unsigned char *src, int count);
|
||||||
extern unsigned char *memset(unsigned char *dest, unsigned char val, int count);
|
extern unsigned char *memset(unsigned char *dest, unsigned char val, int count);
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ unsigned char kbdus[128] =
|
|||||||
0, /* F12 Key */
|
0, /* F12 Key */
|
||||||
0, /* All other keys are undefined */
|
0, /* All other keys are undefined */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool shift = false;
|
||||||
|
|
||||||
/* Handles the keyboard interrupt */
|
/* Handles the keyboard interrupt */
|
||||||
void keyboard_handler(struct regs *r)
|
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
|
/* You can use this one to see if the user released the
|
||||||
* shift, alt, or control keys... */
|
* shift, alt, or control keys... */
|
||||||
|
if(scancode == 0xAA || scancode == 0xB6)
|
||||||
|
{
|
||||||
|
shift = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Here, a key was just pressed. Please note that if you
|
/* Here, a key was just pressed. Please note that if you
|
||||||
* hold a key down, you will get repeated key press
|
* hold a key down, you will get repeated key press
|
||||||
* interrupts. */
|
* interrupts. */
|
||||||
|
if(scancode == 0x2A || scancode == 0x36)
|
||||||
|
{
|
||||||
|
shift = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
/* Just to show you how this works, we simply translate
|
/* Just to show you how this works, we simply translate
|
||||||
* the keyboard scancode into an ASCII value, and then
|
* the keyboard scancode into an ASCII value, and then
|
||||||
* display it to the screen. You can get creative and
|
* 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
|
* to the above layout to correspond to 'shift' being
|
||||||
* held. If shift is held using the larger lookup table,
|
* held. If shift is held using the larger lookup table,
|
||||||
* you would add 128 to the scancode when you look for it */
|
* 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
@@ -63,8 +63,8 @@ void outportb (unsigned short _port, unsigned char _data)
|
|||||||
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char __BUILD_DATE;
|
//extern char __BUILD_DATE;
|
||||||
extern char __BUILD_NUMBER;
|
//extern char __BUILD_NUMBER;
|
||||||
|
|
||||||
/* This is a very simple main() function. All it does is sit in an
|
/* This is a very simple main() function. All it does is sit in an
|
||||||
* infinite loop. This will be like our 'idle' loop */
|
* infinite loop. This will be like our 'idle' loop */
|
||||||
|
|||||||
Reference in New Issue
Block a user