Keyboard Sends Extra Character

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
bgg
Posts: 10
Joined: Wed Aug 15, 2018 7:43 pm
Libera.chat IRC: bgg

Keyboard Sends Extra Character

Post 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
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Keyboard Sends Extra Character

Post 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.
dseller
Member
Member
Posts: 84
Joined: Thu Jul 03, 2014 5:18 am
Location: The Netherlands
Contact:

Re: Keyboard Sends Extra Character

Post 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.
bgg
Posts: 10
Joined: Wed Aug 15, 2018 7:43 pm
Libera.chat IRC: bgg

Re: Keyboard Sends Extra Character

Post 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?
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Keyboard Sends Extra Character

Post 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++;       
    }
}
bgg
Posts: 10
Joined: Wed Aug 15, 2018 7:43 pm
Libera.chat IRC: bgg

Re: Keyboard Sends Extra Character

Post by bgg »

Thank You! I never really stopped to think about what the if statement was doing.
Post Reply