• Advertisement
Sign in to follow this  

DirectInput Keyboard Delay

This topic is 3959 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've notice that when I press a key in my app, it will register like 1-5 times. I've found a solution to it by doing:
if(GetTickCount() - delayRate > lastHit[0])
{
	//Do Stuff
	lastHit[0] = GetTickCount();
}
But it seems tedious for every button, so before I do some massive copy and pasting, is there a way to modify the repeat rate/delay rate of all keyboard input? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
DirectInput is not made for text input. DInput treats your keyboard like a giant gamepad. If a button is down you get the down flag set and vice versa.

If you need convenient text input rather use the WM_CHAR message, that's what its made for. It also follows the keyboard layout and user language. With DInput you'd have to convert that all yourself.

Share this post


Link to post
Share on other sites
Don't use DirectInput. For low-level input (i.e. you really need to know what keys are pressed every frame), use WM_INPUT. For text input, use WM_CHAR, and let Windows handle keyrepeat and so on for you. Always use WM_CHAR, never implement your own keyrepeat - that way you can respect the user's keyrepeat settings from the OS, which is good practice and will make your users happy.

Share this post


Link to post
Share on other sites
Thanks, I kinda looked up some stuff on it but didnt find too much on how to use it. Is it basically the whole AsyncGetKeyState or whatever?

Share this post


Link to post
Share on other sites
Not really. Raw input is a separate mechanism - see MSDN (there's a lot of linked articles off that page that will have relevant information).

DirectInput is basically an extra layer on top of raw input, but it doesn't do much except add complication. It's generally recommended (including by Microsoft) to use raw input directly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement