VGA Keyboard HELP

Jun 6, 2011 at 4:54 AM

How do i read keys without the console!

Developer
Jun 6, 2011 at 5:27 PM
Edited Jun 6, 2011 at 5:31 PM

Well somewhere there is a keyboard already declared, but I don't remember where. I also haven't bothered to search for it, so instead I have this line in my kernel:

public static Keyboard k = new Keyboard();

 

Then in my kernel itself I have this:

char c;
if (k.GetChar(out c))
{
    ProcessKeyboard(c);
}

The ProcessKeyboard method is defined as this:

private int chrsProcd = 0;
private void ProcessKeyboard(char c)
{
    if (c == 'w') // Up arrow
    {
        if (MouseY > 0)
        {
            MouseY--;
            // The following can be used to create 
            // the appearance that the mouse is in 
            // multiple places at once.
            // First figure out how to remove old ones.

            //DrawCursor();
        }
    }
    else if (c == 's') // Down arrow
    {
        if (MouseY < s.Height - 4)
        {
            MouseY++;
            //DrawCursor();
        }
    }
    else if (c == 'a') // Left arrow
    {
        if (MouseX > 0)
        {
            MouseX--;
            //DrawCursor();
        }
    }
    else if (c == 'd') // Right arrow
    {
        if (MouseX < s.Width - 4)
        {
            MouseX++;
            //DrawCursor();
        }
    }

    // The following allows for processing multiple
    // characters per tick.
    if (chrsProcd < 7)
    {
        char c2;
        if (k.GetChar(out c2))
        {
            chrsProcd++;
            ProcessKeyboard(c2);
        }
    }
}

I use this method currently to test test my mouse drawing, as i haven't gotten the mouse itself working yet.

Jun 7, 2011 at 7:40 AM

Ok Thx