Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PC Speaker - problem with keybaord buffer overflow in my app

Status
Not open for further replies.

otto77

Programmer
Mar 4, 2003
3
US
Greetings!

I am writing an MFC-based app using DriectX and bypassing the Windows message pump. OK, its a game. Anyway, I use DirectInput for getting keyboard input, and for some reason, after about five minutes or so of using the arrow keys in the program, the PC speaker starts to make an annoying clicking noise. I assume that this is because the keyboard buffer is full, but how do I stop it? I really don't want to re-design things to process windows messages (and I'm not sure if this would help). I also don't want to disconnect my PC speaker (unless I absolutley have to). What I would like to know is this:

1. Is there any way of sending a command to the PC speaker, so that it will shut up? I have to believe there is, since there is the MessageBeep(0xFFFFFFFF) function that will make the speaker beep - so there has to be something to silence it, right?

OR...

2. Is there anyway that I can ask the keyboard buffer if it is full, and tell it to clear itself? Something like this might also work.
 
Hello.

How do you read the keyboard data? Buffered or immediate?

ps: DirectX version?
 
Which method are you using to read the keyboard input? Please post this code, so we can see what's wrong, although it's almost certain that you only peek at the messages and are not removing them from the buffer.
Greetings,
Rick
 
Somebody helped me out with this problem. I was actually bypassing the Windows message pump completley, so that was causing the keyboard buffer to fill up. Windows must automatically keep that from happening, I guess. I still don't really understand it, but it works now that I put it a call to PeekMessage (with the PM_REMOVE flag) and DispatchMessage in my main loop.

Thanks for your replies anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top