Sign in to follow this  
Crazyfool

DirectInput Keyboard Delay

Recommended Posts

Crazyfool    307
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
Endurion    5411
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
ApochPiQ    23062
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
Crazyfool    307
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
ApochPiQ    23062
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this