Hi all,

Can anyone tell me if it's possible to clear the keyboard buffer and if so how potentially dangerous this could be, or indeed not.

Basically I wish to use keyboard input in a game and I'm trying to avoid hitting the legendary buffer overflow problems. However I don't want to just resort to having to be selective about the keyboard configuration

I've scoured Google and Gamedev.net and found many articles, some saying "process the windows message pump correctly" but from the tests I've tried eg: using GetASyncKeyState() while still processing keyboard input (case WM_KEYDOWN: return 0; ) it appears that even the windows message system does not control the actual keyboard buffer in the way i need to. This is also a problem when using DInput I believe.

I'm no asm specialist but I'm happy to have a stab at it and interested also which is why I'm posting here.

My current way of thinking is...during the input phase, read the current keyboard states into a table, then clear/reset the keyboard buffer, if it's possible. Thus avoiding an overflow by clearing the buffer per game frame.

Thanks in advance for ANY suggestions....it's been asked before but I can't find a definative answer. Hopefully one of you guys can offer one.

Thanks!! =0)
Posted on 2003-06-18 11:23:14 by GCoder
Maybe you can set a hook to the keyboard, and stop every keystroke you don't need...
Posted on 2003-06-18 11:30:28 by JohnFound
Thanks for the post!

I'll give that some thought. I wonder if the buffer could still overflow though?...at least then the chances would be far reduced.
Posted on 2003-06-18 11:32:28 by GCoder