Getting rid of delay on keydown (C++)

Discussion in 'OT Technology' started by RanciD, Dec 5, 2003.

  1. RanciD

    RanciD New Member

    Joined:
    Jul 10, 2002
    Messages:
    2,271
    Likes Received:
    0
    Location:
    Boston
    I'm making a game in VC++ with DirectX. I'm using DirectInput and everything is working fine.. it can handle multiple keys at once, etc. except that when you press down a key and hold it it will perform the desired action once (ie fire your weapon) then pause a second before it starts to repeat this action continually. In a game this is EXTREMELY annoying and isn't tolerable. I'll hold right arrow expecting to move out of the way of incoming fire, I'll move right a tiny bit then it just pauses before I start moving again unless I repeatedly tap the button instead. There's got to be some way to get rid of this delay. Google isn't giving me anything, please help! :sadwavey:
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    hmmm, that's very interesting.... what does your keydown event look like? It's been awhile since i've played with DirectInput.
     
  3. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    You should be polling the keyboard and checking the state of the keys you're interested in, rather than relying on a keydown event.

    The delay and repeat rate are defined by the OS. Look at the keyboard control panel applet. But, in a game, I don't think you want to be relying on this mechanism.
     
  4. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    yeah, you definately rely on windows messaging... i thought that with DirectInput, it was direct access to the hardware which should make it possible but i dunno, it's been awhile
     
  5. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    have u thought about writing your own keyboard interupt?
     
  6. RanciD

    RanciD New Member

    Joined:
    Jul 10, 2002
    Messages:
    2,271
    Likes Received:
    0
    Location:
    Boston
    Sorry guys.. I found the problem. Yeah DirectInput allows you to directly access the hardware.. my problem was that I still had my HandleKeys function getting called when I recieved a keydown message from Windows! oops.
     

Share This Page