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

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
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

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

Post 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.
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

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

Post 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
Last edited by Bender on Sun Mar 23, 2014 10:56 pm, edited 1 time in total.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

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

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

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

Post 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
Post Reply