View Full Version : Disabling key hold-downs. PLEASE HELP
04-17-2001, 04:45 PM
Okay now that i've got your attention.
Im working in a win32 enviroment and have been using the function GetaSyncKeyState() to detect rapid keyboard input. The problem is, when I tap the button, the thing that I want to move, moves too much!!!
How do I make it so It'll only move one per key-press??
04-17-2001, 07:44 PM
You might want to invest some time in researching DirectInput. That's probably the best way to go about it.
this has nothing to do with opengl.
im still trying to figure out how dinputs gonna help http://www.opengl.org/discussion_boards/ubb/wink.gif
you could use the window messages
or do someit like (works on the principle a key is pressed until its not pressed)
04-18-2001, 03:41 AM
GetaSyncKeyState() is for very fast, asycnchronous monitoring, You probably should use something else, or, only move on a 'change' of keystate. Set a flag called 'PreviousPressed' or something, and only move if the button is pressed && PreviousPressed is false.
04-19-2001, 10:41 AM
This code will do it:
// check if key was pressed (opposed to held down)
if (!(lParam & 0x40000000))
keys[wParam] = TRUE;
04-19-2001, 12:01 PM
If you don't want to use anything as advanced as DirectInput, you could always put some thought into it. GetAsyncKeyState tells if the key is being pressed down, correct? Just keep a flag around that tells what the previous state of the key was. Only move the object if the last call to GetAsyncKeyState showed that the key hadn't been pressed.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.