Keyboard Issue
Well I am using DirectInput in C++ to get what keys have pressed in my game. From the DirectInput, when a key is pressed it is sent a textinput box class that prints whats been pressed. My issue with it comes from when a key is being pressed it continues sending buffer data to the textinput box and fills the box up after just one press. I am trying to keep a second delay betwen 1 press then fill the box, using sleep() doesnt help, just lags up the game. Anyone have any solutions?
You can use buffered input instead of immediate input. However, you can also do this using immediate input. Do something like this:
In the above pseude-code, delay = 1/typematic_rate (number of characters/s).
initially, set last_time_key_pressed = 0whenever a key is pressed if current_time - last_time_key_pressed < delay ignore key press else process key press last_time_key_pressed = current_time
In the above pseude-code, delay = 1/typematic_rate (number of characters/s).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement