• ### Announcements

#### Archived

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

# 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 on other sites
Oluseyi    2103
See GetDeviceData.

Also see Time Stamps and Sequence Numbers.

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