Some keyboard keys not responding

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
User avatar
alethiophile
Member
Member
Posts: 90
Joined: Sat May 30, 2009 10:28 am

Some keyboard keys not responding

Post by alethiophile »

I am currently in the process of writing a keyboard driver. My current implementation simply listens on IRQ1 and prints the hex value of the scancodes it reads. Code:

Code: Select all

void keyboard_handler(registers_t *regs) {
  if (regs->eax) {}
  u8int key = inportb(0x60);
  printf("%x\n", key);
}
This works fine and as advertised for most keys, but some do not print anything. The numpad keys, other than numlock and enter, do not respond, and neither do the windows-logo keys or the context-menu key. How do I get these keys to respond properly?
If I had an OS, there would be a link here.
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: Some keyboard keys not responding

Post by salil_bhagurkar »

Your code looks perfectly alright. Hence, we need to have a look at the code surrounding your irq handler. The function that calls it, the printf function and inportb. Again, chances are pretty less that there might be trouble in these functions too.
User avatar
alethiophile
Member
Member
Posts: 90
Joined: Sat May 30, 2009 10:28 am

Re: Some keyboard keys not responding

Post by alethiophile »

It works for most keys, no? So I would think that a problem with my IRQ handling, my inportb or my printf that only failed to pass the numpad keys would be pretty unlikely.
If I had an OS, there would be a link here.
User avatar
alethiophile
Member
Member
Posts: 90
Joined: Sat May 30, 2009 10:28 am

Re: Some keyboard keys not responding

Post by alethiophile »

I have just verified that, in fact, the numpad keys don't work in my host OS either, and instead seem to move the mouse cursor. (?) It might be relevant that on the computer I test on, both keyboard and mouse are plugged into a PS/2 to USB adapter. And when I test it on another computer, whose kb/mouse are connected via PS/2, it works. So I guess this is not a software problem.
If I had an OS, there would be a link here.
kokjo
Posts: 6
Joined: Thu Aug 06, 2009 2:16 pm
Location: Amager, Denmark

Re: Some keyboard keys not responding

Post by kokjo »

are you using bochs? that couth be the problem, have you tried on a real machine?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Some keyboard keys not responding

Post by Combuster »

kokjo wrote:have you tried on a real machine?
And when I test it on another computer, whose kb/mouse are connected via PS/2, it works.
Would you mind reading before posting a reply?
only failed to pass the numpad keys
Interesting that those are codes normally prefixed with e0 - I wonder if the combination of that and USB might have something to do with it, but I don't see anything in the shown code that might explain that behavior (please post the full code)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
alethiophile
Member
Member
Posts: 90
Joined: Sat May 30, 2009 10:28 am

Re: Some keyboard keys not responding

Post by alethiophile »

The numpad keys are fixed--turns out it was some obscure X setting that kidnapped the numpad keys for mouseless control of the cursor. None of the 'Windows-specific' keys work, even on hardware.
If I had an OS, there would be a link here.
Post Reply