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
Keyboard Sends Extra Character
-
- Member
- Posts: 799
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Keyboard Sends Extra Character
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 . 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.
Code: Select all
cmdchar(kbdus[scancode]);
Re: Keyboard Sends Extra Character
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.
My blog: http://www.rivencove.com/
Re: Keyboard Sends Extra Character
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.
New output:
https://imgur.com/a/HAiRu5H
New keyboard "driver":
https://pastebin.com/k4knjgAd
Is there anything else I am messing up?
New output:
https://imgur.com/a/HAiRu5H
New keyboard "driver":
https://pastebin.com/k4knjgAd
Is there anything else I am messing up?
-
- Member
- Posts: 799
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Keyboard Sends Extra Character
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
Thank You! I never really stopped to think about what the if statement was doing.