Page 1 of 1

Keyboard Sends Extra Character

Posted: Wed Oct 03, 2018 5:01 pm
by bgg
I have gotten interrupts working for a while now, but the keyboard sends an extra character when I press the keys e, q, t, u, w, and y. I can't seem to figure out what I should be doing/changing about how I receive the keys and or scan codes.
Ex: https://imgur.com/a/EUvl7St
Keyboard code (W.I.P.) https://pastebin.com/PDmcsMVj

Re: Keyboard Sends Extra Character

Posted: Thu Oct 04, 2018 12:31 am
by MichaelPetch
Might help to see all your code. Do you send an EOI, do you properly save and restore the required registers when your interrupts run. Do you have the exact same output every time you run it or does it differ each time? I also have a potential concern about this

Code: Select all

cmdchar(kbdus[scancode]);
. It suggests you are doing command processing inside an interrupt handler. You shouldn't do that. You could create a keyboard buffer that you populate with keystrokes and your kernel could sit in a HLT loop waiting for interrupts and processing keystrokes from the buffer. This keeps the main command processing out of the interrupt handler itself.

Re: Keyboard Sends Extra Character

Posted: Fri Oct 05, 2018 1:09 am
by dseller
The output on the screen looks fine to me. The error seems to be in the out.log file, which I assume you pipe your serial port into. Perhaps there is an issue in your serial output code, instead of your keyboard handling code.

Re: Keyboard Sends Extra Character

Posted: Fri Oct 05, 2018 9:35 pm
by bgg
After some "intense" rewriting and adding a keyboard buffer, I have found out that the character displayed are the keys being released. And I don't know how it is finding the character, because my keyboard array doesn't have the character. #-o ](*,)
New output:
https://imgur.com/a/HAiRu5H
New keyboard "driver":
https://pastebin.com/k4knjgAd
Is there anything else I am messing up?

Re: Keyboard Sends Extra Character

Posted: Fri Oct 05, 2018 9:43 pm
by MichaelPetch
Maybe you mean to do:

Code: Select all

void keyboard_handler(struct regs *r)
{
    unsigned char scancode;
    scancode = inb(0x60);
    key = kbdus[scancode];
    if (scancode & 0x80)
    {
    }
    else
    {
        kbuff[kbufn] = key;
        terminal_putchar(key);
        write_serial(key);
        write_serial(kbuff[kbufn]);
        kbufn++;       
    }
}

Re: Keyboard Sends Extra Character

Posted: Fri Oct 05, 2018 9:45 pm
by bgg
Thank You! I never really stopped to think about what the if statement was doing.