DirectInput Keyboard Delay

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 on other sites
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 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 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 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.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628282
• Total Posts
2981805

• 9
• 10
• 11
• 17
• 14