How would I make DirectInput less sensitive?

Started by
3 comments, last by Brobanx 22 years, 3 months ago
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"?
Advertisement
See GetDeviceData.

Also see Time Stamps and Sequence Numbers.
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,
Learn about game programming!Games Programming in C++: Start to Finish
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.
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.
Arcus

This topic is closed to new replies.

Advertisement