Page 1 of 1

PS/2 Keyboard stop sending scan codes when I press SHIFT?

Posted: Sun Mar 23, 2014 10:41 pm
by windows8
PS/2 Keyboard will send scan codes all the time when a key is pressed.There are no problems.
When a key such as 'a' is pressed and I press SHIFT or CTRL,some problems are coming!!!

I try it on QEMU and VirtualBox,the keyboard will send the scan code of SHIFT/CTRL,and still send the scan code of 'a' to my os.
But I try it on VirtualPlayer or my real computer,things are different.
The keyboard will also send the scan code of SHIFT/CTRL,and stop sending the scan code of 'a'!!!

Of course,I want the keyboard to send the scan code of 'a' still,but keyboard doesn't!
So l look for the wiki "PS/2 Keyboard",I can't find anything about this.

How to slove this? Thank you and sorry for my bad English.

Re: PS/2 Keyboard stop sending scan codes when I press SHIFT

Posted: Sun Mar 23, 2014 10:54 pm
by Bender
Hi,
Well you need to check whether shift is up or down too.
How does your handler look like?
From the description given it's not easy to find out the problem.
-Bender

Re: PS/2 Keyboard stop sending scan codes when I press SHIFT

Posted: Sun Mar 23, 2014 10:56 pm
by Brendan
Hi,
windows8 wrote:PS/2 Keyboard will send scan codes all the time when a key is pressed.There are no problems.
When a key such as 'a' is pressed and I press SHIFT or CTRL,some problems are coming!!!

I try it on QEMU and VirtualBox,the keyboard will send the scan code of SHIFT/CTRL,and still send the scan code of 'a' to my os.
But I try it on VirtualPlayer or my real computer,things are different.
The keyboard will also send the scan code of SHIFT/CTRL,and stop sending the scan code of 'a'!!!

Of course,I want the keyboard to send the scan code of 'a' still,but keyboard doesn't!
So l look for the wiki "PS/2 Keyboard",I can't find anything about this.

How to slove this? Thank you and sorry for my bad English.
For PS/2 hardware, only one key (the most recently pressed key) is supposed to repeat. This means that if you're holding down 'a' and press shift, then the shift key is the most recently pressed key (and not 'a') so the 'a' stops repeating. Because the shift key doesn't repeat, in this case you should get nothing more (until you release 'a' and get one 'a released' scancode).

If you want 'a' to continue repeating after you've pressed shift; then you have to ignore the hardware's key repeat and implement key repeat yourself in software. I suspect that Linux does it this way (possibly so that you can set any repeat rate you like instead of being limited to repeat rates that the hardware supports). I also suspect that emulators just forward what the OS sends it, and that you're running emulators on Linux (which sends "aaaaaAAAAAAAaaaaaaAAAAAA") and would get different results if you were running the emulators on Windows(which sends "aaaaa" instead).


Cheers,

Brendan

Re: PS/2 Keyboard stop sending scan codes when I press SHIFT

Posted: Sun Mar 23, 2014 11:13 pm
by windows8
Brendan wrote:
For PS/2 hardware, only one key (the most recently pressed key) is supposed to repeat. This means that if you're holding down 'a' and press shift, then the shift key is the most recently pressed key (and not 'a') so the 'a' stops repeating. Because the shift key doesn't repeat, in this case you should get nothing more (until you release 'a' and get one 'a released' scancode).

If you want 'a' to continue repeating after you've pressed shift; then you have to ignore the hardware's key repeat and implement key repeat yourself in software. I suspect that Linux does it this way (possibly so that you can set any repeat rate you like instead of being limited to repeat rates that the hardware supports). I also suspect that emulators just forward what the OS sends it, and that you're running emulators on Linux (which sends "aaaaaAAAAAAAaaaaaaAAAAAA") and would get different results if you were running the emulators on Windows(which sends "aaaaa" instead).
Oh,I tried it on Linux and it sent ""aaaaaAAAAAAAaaaaaaAAAAAA".I thought PS/2 Keyboard does this,so I asked the question...
Now I know my problem,maybe I should implement this in my os (as the same as you said),not PS/2 hardware.

Thank you very much. :D :D