Keyboard class

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
FireDemon

Keyboard class

Post by FireDemon »

Can someone give me a simple keyboard class.
eL JeDi

Re:Keyboard class

Post by eL JeDi »

[attachment deleted by admin]
FoxEdge

Re:Keyboard class

Post 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.
Tim

Re:Keyboard class

Post 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.
Post Reply