WM_CHAR and Windows auto-repeat
Hmm... I'm modifying my input system in my game engine so that I can get standard character input (Before it was all Direct Input polling stuff). So, the WM_CHAR message is really nice, except that it's coming in really fast. Basically, when the user just taps the 'k' key, I get something like 12 k's.
I know that standard edit controls in Windows don't exhibit this behavior. For example, Notepad behaves the same way as the textbox in my browser - when I hit a character on my keyboard, it gives me the first character, waits about half a second, then starts repeating characters at a constant rate (about 9 a second).
Since this seems to be default behavior for windows apps, and I can see it when I open my control panel Windows properties, is there a simple way that I can get my engine to behave the same way? Does windows provide an interface to this, or should I write my own timer-based delay system to ignore the correct CHAR messages?
Thanks in advance for any help!
It sounds like you are encountering the same problem I had with trying to use the WM_CHAR messages. I never could solve it. I eventually went with using the ToAscii function instead (in the normal keyup/down messages). I'll be interested to hear how this is solved because it really stumped me.
I doubt that was WM_CHAR implementation error, it should be your error. WM_CHAR message is processed and sent by Windows in these circumstances:
*User pressed a key once: 3 messages will be sent: WM_KEYDOWN, WM_CHAR and WM_KEYUP
*User pressed a key, held down it for a few seconds then released. a number of these messages will be sent: WM_KEYDOWN, WM_CHAR and WM_KEYDOWN, WM_CHAR and ...
the last message will be WM_KEYUP.
That said, your app shouldn't receive WM_CHAR as if it was polling keys as GetKeyState (). If you're still in doubt, just create a simple textbox then count number of WM_CHAR messages are sent. Number of millisecs Windows has to wait before sending multiple WM_KEYDOWN and WM_CHAR is stored in SM_* (I don't quite remember) by calling GetSystemMetrics () (?) .
*User pressed a key once: 3 messages will be sent: WM_KEYDOWN, WM_CHAR and WM_KEYUP
*User pressed a key, held down it for a few seconds then released. a number of these messages will be sent: WM_KEYDOWN, WM_CHAR and WM_KEYDOWN, WM_CHAR and ...
the last message will be WM_KEYUP.
That said, your app shouldn't receive WM_CHAR as if it was polling keys as GetKeyState (). If you're still in doubt, just create a simple textbox then count number of WM_CHAR messages are sent. Number of millisecs Windows has to wait before sending multiple WM_KEYDOWN and WM_CHAR is stored in SM_* (I don't quite remember) by calling GetSystemMetrics () (?) .
You appear to have accidentally double-posted. I've closed the other one for you, but you did get a response there as well.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement