keyboards on PC to play games: Ignored keys with other keys pressed

post your own high scores or enter our challenge competitions
Post Reply
User avatar
Wouter Scholten
Posts: 231
Joined: Wed May 02, 2001 10:14 pm
Location: NL
Contact:

keyboards on PC to play games: Ignored keys with other keys pressed

Post by Wouter Scholten » Thu Feb 08, 2018 8:26 pm

I think this topic doesn't suit other subforums better so I'm asking here as I will perhaps get more response: So, yesterday I tried Defender on mame and immediately recalled why I didn't play it more on the PC when "Williams arcade classics" came out (1995). The issue is my IBM clicky keyboards. The click is not great, it hinders for this type of game, but also pressing A+Z or S+X and keeping them pressed and then pressing return/enter or shift just ignores the enter/shift key. Not all keys are ignored, space works for example, but, I just cannot play Defender (nor Planetoid emulated) this way. I wonder if this is a specific issue for IBM keyboards. Could you try in say a texteditor pressing A+Z then Enter, does it give a new line? You could also try playing Planetoid: does return give fire when already pressing A+Z before pressing return? And which keyboard are you using?

You may want yo have a look too at my Planetoid page for a bit more on this and playing experiences of Defender vd. Planetoid (not based on this issue)


http://wouter.bbcmicro.net/bbc/spellen/planetoid.html

User avatar
tricky
Posts: 2707
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by tricky » Thu Feb 08, 2018 8:47 pm

Most keyboards including the beeb work by having the switches in a grid (matrix) and then for say each row, checking which columns have keys pressed.
With this arrangement, if you press three keys on the corners of a rectangle, the fourth key will also be "pressed".
Try this on the beeb, the wiring is in the AUG.

I don't know exactly how this is made worse with "N-key-rollover" which PC keyboards often have, but I suspect it is to stop erroneous key "presses".

There is some Acorn related discussion here which contains a link to Jeltron where I had to find 12 non-ghosting keys that also made sense for two players where each player had up, down, left, right, fire and power-up.

On Windows, you can use DirectInput (probably XInput now) to get a little lower level info about the keys pressed, which MAME may be able to use, but that can't help if the keyboard isn't sending the info.

Sorry for the poor reply, but hopefully you can use it to find a better explanation.

User avatar
Wouter Scholten
Posts: 231
Joined: Wed May 02, 2001 10:14 pm
Location: NL
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by Wouter Scholten » Thu Feb 08, 2018 9:33 pm

tricky wrote:Most keyboards including the beeb work by having the switches in a grid (matrix) and then for say each row, checking which columns have keys pressed.
With this arrangement, if you press three keys on the corners of a rectangle, the fourth key will also be "pressed".
Try this on the beeb, the wiring is in the AUG.

I don't know exactly how this is made worse with "N-key-rollover" which PC keyboards often have, but I suspect it is to stop erroneous key "presses".

There is some Acorn related discussion here which contains a link to Jeltron where I had to find 12 non-ghosting keys that also made sense for two players where each player had up, down, left, right, fire and power-up.

On Windows, you can use DirectInput (probably XInput now) to get a little lower level info about the keys pressed, which MAME may be able to use, but that can't help if the keyboard isn't sending the info.

Sorry for the poor reply, but hopefully you can use it to find a better explanation.
I know about 4th key generation, I found out myself long ago, in the 80s or 1995 at the latest. But that and rollover is not the issue for the BBC because this is a 3 key problem. For the PC not sure if 3 keys together mean that only some fake key is generated (so no event for return but a fake key, or is no event at all generated, need to check), that could be the case, and so that means a definite problem when relying on key events instead of with the BBC, where you scan a particular key. With the BBC, those keys that you check for that are actually pressed will give as result 'pressed', but also the 4th key (which is better than a not-pressed result for key 3). I've done the checking with X key events, but this doesn't seem X-only, but perhaps I should do more tests. In any case I'd be interested in results of this simple test, for loose keyboards but also laptops, to get a better view of the problem, for people running X on unix, and for people running windoze, and for those using apple.

User avatar
tricky
Posts: 2707
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by tricky » Thu Feb 08, 2018 10:57 pm

Sorry, I didn't notice who had posted.
I think the OS is "protecting you" from possible clashes.
If you use DirectInput (just a wrapper on Win32) on windows, you can read A+Z+RETURN, but with normal input, the 2 (3?) key rollover holds onto the RETURN until one of the first two keys have been released.

User avatar
Wouter Scholten
Posts: 231
Joined: Wed May 02, 2001 10:14 pm
Location: NL
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by Wouter Scholten » Thu Feb 08, 2018 11:34 pm

tricky wrote:Sorry, I didn't notice who had posted.
I think the OS is "protecting you" from possible clashes.
If you use DirectInput (just a wrapper on Win32) on windows, you can read A+Z+RETURN, but with normal input, the 2 (3?) key rollover holds onto the RETURN until one of the first two keys have been released.
I don't use windoze, but X on FreeBSD, however, as I said, it is not about holding anything, it's a deeper layer because some other key combinations do not have this problem on my keyboard. Using an editor: Q+A for example, and then pressing ENTER gives a new line (and whichever of Q/A was repeating stops). A+Z and then ENTER doesn't (either Z or Z keeps repeating).

User avatar
Wouter Scholten
Posts: 231
Joined: Wed May 02, 2001 10:14 pm
Location: NL
Contact:

Some answers

Post by Wouter Scholten » Mon Feb 12, 2018 1:17 pm

So, I checked what is possible with PC keyboards and there is apparently nothing that can be done at a lower level with them, but then why did I never have problems with many PC games such as Doom, Descent, Duke 3d, Sega ralley? Well, the answer from unicomp (pckeyboard.com) who make the same keyboards as the original IBM keyboards (same key switches etc.), gives some hints. They gave a quite long reply. Here it is:
Given the way we connect our switch matrix, our statement about phantom keys and rollover is, unfortunately, complicated. Our keyboards meet and exceed the Microsoft and IBM standards for multi-key combinations. Our keyboards will support any one to four modifier key combination (Shift, Control, Alt and/or GUI keys) plus a fifth key as long as:

1) No Left+Right modifier keys (Left+Right Shift, Left+Right Control, etc.) are involved in the combination, and

2) Neither the Up Arrow, Pause key, nor the Caps Lock key are the fifth key.

Our original intent was to support multi-key sequences required by any Microsoft OS or Application and to the best of my knowledge, that's still true. Of course our keyboards will support other key combinations larger than five key sequences without generating a phantom key situation and there are some 3 key sequences which will generate a phantom condition. Consequently, it's difficult to make a generic statement beyond the one above.

As for rollover, the USB HID and boot protocol standards limit our USB keyboards to six key rollover. The buffer sizes and key processing in our PS/2 controller limit those keyboards to 7 or 8 key rollover.
I had already read about the rollover limitations due to HID protocol but say 6 key rollover is enough, and with that I will assume is meant also no ghost (i.e. apparent) key presses created by multiple others up to that amount.

The default key combinations for the PC games that I mention often use the cursor keys for movement with shift/alt for fast/strafe (duke/doom/descent), so there seems no problem in many cases along with the fact that such games do not require the accuracy in movement (or else you're dead!) that 1980s arcade type games require. And the one case where accuracy is required, aiming and then shooting at something, I used the mouse (also for shooting). But I also used the mouse along with the movement keys during running. So this explains why I didn't have problems playing games on the PC, except when I tried Defender on Willams arcade classics (I tried a few games in 1995 but stopped at it was unplayable due to the above problems) and then a few other similar games that require multiple key presses at the same time. Possibly the WASD pattern that many people use explains for PC gaming also why they have fewer problems: It is more likely then to not press keys at the same time because these keys are all close together. I find it far inferior to 1 direction per hand, but of course I then run into problems with 2-key rollover with e.g. ZX/'.

Some people mention 'cheap keyboards' have this problem, which is not so, I have a bunch of original IBM keyboards, 2x US 101, a few Dutch 102, even a 122 key terminal keyboard, and they all have 2-key rollover which just isn't good enough.

With the BBC micro, you can scan each key instead of waiting for key press/release events, which is far better even though ghost keys appear with 3 keys pressed.

So it seems there is no way around it: The issue is a hardware limitation in the keyboards, no way to get lower level access from whatever OS you use. So for proper PC gaming, you need to get a 6-key or n-key rollover keyboard. Often rollover is not mentioned except for when a keyboard is a "gamers' keyboard". When were they introduced? I guess that nobody played games on the PC in the 1980s or 1990s :)

User avatar
Rich Talbot-Watkins
Posts: 1339
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by Rich Talbot-Watkins » Mon Feb 12, 2018 3:20 pm

I've long been of the view that most PC keyboards have this hardware limitation, and where multiple key rollover is important, you can buy "gamers' keyboards" which are sold with this as an explicit feature.

I have a Corsair keyboard with Cherry Blue keyswitches for that nice clicky feel, and it appears to support 10 key rollover, but my previous cheap membrane keyboard only supported 2 key rollover, plus modifier keys (so Shift, Ctrl, Alt etc are treated as a special case).

I assume the circuitry required to support many keys pressed in parallel (without producing 'ghost' keypresses) is much more complicated.

User avatar
tricky
Posts: 2707
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by tricky » Mon Feb 12, 2018 4:19 pm

I don't know about linux, but I checked A+Z+RETURN on half a dozen keyboards running windows, none would pass on the RETURN in an editor or using the "higher level" APIs, but all would give RETURN using the lower level messages. I suspect that you can get A+Z+RETURN with the "right" API on linux.

User avatar
leenew
Posts: 3633
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by leenew » Mon Feb 12, 2018 5:25 pm

When I built my arcade controller, it needed one of these: https://www.ultimarc.com/ipac1.html
No ghosting, and really configurable, but over £25 if I remember correctly.

Lee.

User avatar
Wouter Scholten
Posts: 231
Joined: Wed May 02, 2001 10:14 pm
Location: NL
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by Wouter Scholten » Mon Feb 12, 2018 7:12 pm

tricky wrote:I don't know about linux, but I checked A+Z+RETURN on half a dozen keyboards running windows, none would pass on the RETURN in an editor or using the "higher level" APIs, but all would give RETURN using the lower level messages. I suspect that you can get A+Z+RETURN with the "right" API on linux.
Thanks for that, confirms how big of a problem it is.

As to the right API: No, it seems it is impossible. I looked up what protocol the keyboards use and there is no way to issue a command to check for a key being pressed. You only have key release and key press events... If the keyboard doesn't produce the return-pressed event, this means you are screwed. I had this issue with my own X-framebuffer code in which I take each key press/release event, there is nothing else according to the kb protocol specs that can be done.

User avatar
Wouter Scholten
Posts: 231
Joined: Wed May 02, 2001 10:14 pm
Location: NL
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by Wouter Scholten » Mon Feb 12, 2018 7:15 pm

leenew wrote:When I built my arcade controller, it needed one of these: https://www.ultimarc.com/ipac1.html
No ghosting, and really configurable, but over £25 if I remember correctly.

Lee.
Nice one, price is not an issue, a n-key rollover kbd is much more expensive so perhaps a good idea to use something like that alongside my IBM clicky keyboard (which is perfect for text editing).

What other switches/joystick did you use? Did you make a plywood enclosure?

User avatar
leenew
Posts: 3633
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by leenew » Mon Feb 12, 2018 9:27 pm

Just dug it out from under the bed.. :D
20180212_211919.jpg
20180212_212007.jpg
20180212_211959.jpg
The buttons are Happ arcade buttons.
The joysticks are a 4 way pacman joystick and 8 way Happ competitions
https://www.arcadeworlduk.com/products/ ... stick.html

Lee.

Coeus
Posts: 964
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by Coeus » Mon Feb 12, 2018 10:51 pm

Rich Talbot-Watkins wrote:I assume the circuitry required to support many keys pressed in parallel (without producing 'ghost' keypresses) is much more complicated.
Not complicated but it does cost a few pence more - it needs extra diodes. If you look at the circuit diagram of the BBC micro keyboard at the bottom of each column in the matrix is a diode before that column intersects with row 0. Row zero has the Shift and Control keys as well as the start-up option switches, i.e. all those switches which could be closed at the same time as any other switch on the keyboard and must not ghost.

If you wanted every key on the keyboard to be independently detectable regardless of how many other keys are down then you would need such a diode at every maxtrix point so, for example, a diode between each key-switch and its column.

On the question of clicky IBM keyboards I believe the type F was multi-key rollover but that was capacitive, i.e. the PCB itself is covered in a layer of plastic and each key brings down something conductive onto the top face of that plastic close to, but not touching the pads. That forms a pair of capacitors between that conductive element and the PC with the plastic film as the dialectic. At the frequency the keyboard is scanned at those capacitors have low enough impedance to be detected as a connection.

The Type M, which is far more common and came in with the PC/AT, and gave rise to the now common layout, was much cost reduced and this is the version which continues to be made as mentioned above.

crj
Posts: 834
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: keyboards on PC to play games: Ignored keys with other keys pressed

Post by crj » Tue Feb 13, 2018 8:58 pm

Coeus wrote:Not complicated but it does cost a few pence more - it needs extra diodes.
It looks like diodes are about a penny each in bulk, so it adds a pound to the cost of a keyboard... plus the extra assembly and testing work.

Frankly, the simpler solution would be for someone to make an integrated keyboard controller in a TQFP144 or BGA144 with one pin per key. It would probably be cheaper as well.

If going for small production volumes, you could take a sledgehammer to the problem and use a Max 10 FPGA. £4.25 for a UBGA-169 package with 130 IO lines. And 2000 LUTs of FPGA would be, er, sufficient for keyboard control. (-8

Post Reply