Archived

This topic is now archived and is closed to further replies.

Brobanx

How would I make DirectInput less sensitive?

Recommended Posts

Brobanx    136
As I have it right now, I have DirectInput checking for keypresses in a loop. It uses the GetDeviceState() method to acquire keyboard info. Whenever I press a key, it takes in about 20 keystrokes (because it goes through the loop 20 times before I can get my finger off the key!). Is there any way I can make it less sensitive (without adding a sleep command in my loop), or make it so that it identifies keystrokes as "hit", "held down", "relesead"?

Share this post


Link to post
Share on other sites
wazoo69    157
Just check for the release of the key rather than the pressing of it..

ie.
  
BOOL isKeyUp(DWORD dwKey)
{
if(DIkeyBuffer[dwKey] & 0x80)
{
//the key is currently down

return FALSE;
}

//our key is up!

return TRUE;
}


it''s what I use, and it tends to work quite a bit better

hth,

Share this post


Link to post
Share on other sites
Brobanx    136
Ok, I''ve decided I can set up a neat little system using some flags / good timing so that if you hold down the key for more than a quarter second it flags the key as "down", if you hold it for less than a quarter second it flags it as "hit", and if you release the key after holding it for more than a quarter second it flags it as released.

Actually, if you have an extremely slow comp the quarter-second thing might be bumped up a bit, but it takes at least a quarter second, and on any decent comps (pentiums) the quarter second should be more than enough time.

Share this post


Link to post
Share on other sites
Arcus    122
Why not just use buffered input instead of state. That way you can get all of the keys pressed sense the last time you checked. This is much better if you are taking in text etc. HTH.

Share this post


Link to post
Share on other sites