Jump to content
  • Advertisement
Sign in to follow this  
LevyDee

Keyboard input delay

This topic is 2969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Setting up a win32 window and message handling function like such

LRESULT CALLBACK WndProc(etc....)
{
switch(message)
{
case WM_KEYDOWN:
{
switch(wParam)
{
case 0x57:
///Do something if 'W' key is hit
}
}
}
}

Doing this, causes a short delay if you hold down the 'W' key. My specific problem, is this. Im just learning D3D, and I want to move the camera sort of like a fps. So if the user holds down 'W', the camera move's forward, or if they push and hold 'S', they move back. Easy enough to accomplish by assigning a global variable to the D3DXMatrixLookAtLH.

So the problem is, If I push and hold down 'W', the camera will move forward, stop, then continue to move forward smoothly after the initial delay.(Im incrementing the variable in my wParam switch).

How would you fix this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
In your WM_KEYDOWN handler toggle a flag when the key is pressed and in your update function move forward if that flag indicates that the key is held down.

Share this post


Link to post
Share on other sites
As no such user suggested, set some bool like "moveForeward" to true for WM_KEYDOWN. Don't forget to set it to false on WM_KEYUP!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!