Page 1 of 1
Keyboard class
Posted: Sat Jan 18, 2003 1:20 pm
by FireDemon
Can someone give me a simple keyboard class.
Re:Keyboard class
Posted: Sat Jan 18, 2003 1:47 pm
by eL JeDi
[attachment deleted by admin]
Re:Keyboard class
Posted: Sat Jan 18, 2003 2:01 pm
by FoxEdge
//Make believe Keyboard.h
class Keyboard
{
public:
Keyboard()
{
copy(keyscan,English);
}
~Keyboard()
{
}
int getchar()
{
outport(key);
return keyscan(key);
}
private:
unsigned char keyscan[256];
};
I just made that up, but can anyone help me figure out how to do it.
Re:Keyboard class
Posted: Sat Jan 18, 2003 3:45 pm
by Tim
What you need from your keyboard driver:
- To be able to handle interrupts from the keyboard controller
- To accept requests from programs which need to know which keys have been pressed
What I recommend you do is write a driver which can handle an IRQ 1. When it gets IRQ 1, it needs to read a scan code from the keyboard controller (in(0x60)), convert it to an ASCII code, and put it into the end of the keyboard buffer. When a program wants to get a key, it needs to read from the start of the same keyboard buffer.