DirectInput Keyboard Delay

Started by
3 comments, last by ApochPiQ 17 years ago
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.
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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?
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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement