VOGONS


Patch for fixing keyboard repeat behavior

Topic actions

First post, by jazztickets

User metadata
Rank Newbie
Rank
Newbie

Hey guys

Here's a patch I made to fix a nit-picky problem I found with DOSBOX's repeat behavior.

For example, if you press & hold the key 'd', then press & hold the key 'f' while still holding 'd', then let go of 'd', 'f' no longer repeats.

This is problematic for games that rely on keyboard repeat for movement.

Here is the patch for src/hardware/keyboard.cpp
http://pastebin.com/wsu3E39D

The patch also changes the default keyboard repeat delay from 500ms to 200ms.

Reply 1 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

That's strange, i think the current behaviour is what i remember from back then, maybe somebody can confirm either behaviour on a real system.

What games are affected?

Reply 2 of 20, by robertmo

User metadata
Rank l33t++
Rank
l33t++

jazztickets is right, confirmed on 386 and pentiummmx

Reply 3 of 20, by jazztickets

User metadata
Rank Newbie
Rank
Newbie

It's more for those games that used the classic "if(kbhit()) key = getch()" combo. I was going through my old games that I made in high school and I noticed something was off. I was using Windows 98 and Borland C++ at the time, so kbhit() would use the windows keyboard delay.

Reply 4 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

😀 Thanks.

Reply 6 of 20, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

doesn't work at my place.
the old key doesn't start repeating here.

Water flows down the stream
How to ask questions the smart way!

Reply 7 of 20, by robertmo

User metadata
Rank l33t++
Rank
l33t++

the old key shouldn't start repeating (that is how it works on real computer and in winxp's cmd)
only the new key should not stop when you release the old key (like it is in dosbox without the patch)

Anyway the patch doesn't make it as it was on real computer as it introduces a short delay when releasing the old key (the delay doesn't happen on real computer and in winxp's cmd)

Reply 8 of 20, by jazztickets

User metadata
Rank Newbie
Rank
Newbie

Not sure what you mean by "real computer". A computer running MS-DOS?

I wrote the patch on a Windows XP box. My patch mimics the behavior exactly. When you release the old key there's always a delay before the repeat starts on the key that's still down.

Reply 9 of 20, by robertmo

User metadata
Rank l33t++
Rank
l33t++

ddddddddddddddd(delay when pressing "j")jjjjjjjjjjjjjjjjjjjjjjjjjjjj(no delay when releasing "d")jjjjjjjjjjjjjjjjjjjjjjjjj

I checked that on winxp32bit cmd, win7 64bit cmd, and on pentium 166mmx in msdos6.2 and on 286 with msdos6.2

Reply 10 of 20, by jazztickets

User metadata
Rank Newbie
Rank
Newbie

Interesting. That doesn't happen on any computer i've ever used. What keyboard are you using?

Reply 11 of 20, by robertmo

User metadata
Rank l33t++
Rank
l33t++

basic 101/102 keyboards, and what are yours? have you tested it now on other computers? cause memory may not be good 😉

Reply 12 of 20, by jazztickets

User metadata
Rank Newbie
Rank
Newbie

All mine are 104 or greater and USB. I have one 104 PS/2 keyboard that I haven't tried but i'm sure that works all the same.

Regardless, the issue at hand is whether the last key should be repeating. I think we can all agree that the patch should be implemented.

Reply 14 of 20, by robertmo

User metadata
Rank l33t++
Rank
l33t++

heh, usb doesn't even work in dos so i wonder how you used it in the old days 😉 so the ps2 one is definitely worth trying (my ps2 is actually also about 104 as it has win keys), but there were no win keys in the dos days too heh.

Reply 15 of 20, by jazztickets

User metadata
Rank Newbie
Rank
Newbie

Yeah, I don't have any DOS computers around. I'm just talking about Windows XP and beyond.

Reply 16 of 20, by robertmo

User metadata
Rank l33t++
Rank
l33t++

ok so try the ps2 keyboard please 😀

Reply 17 of 20, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I am going with robertmo his observations and added a slightly simpler version of your patch to the SVN.

Thanks to both of you.

Water flows down the stream
How to ask questions the smart way!

Reply 18 of 20, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

IMO, the default repeat delay was fine as it was. Some games might work better with less delay, but you can change it with MODE.COM or other keyboard utility programs (that's how it was on real DOS systems). Unless I type light and fast at the prompt, I get lots of typos from "bounced" keys.

Reply 19 of 20, by jazztickets

User metadata
Rank Newbie
Rank
Newbie

I say make it a command line option or editable in a .conf file. One less program to hunt down.