Suggestions wanted for DirectInput in FPS.
I am currently polling for input from the keyboard / mouse every 30ms but I am finding this has limitations.
If I tap and release a key or move the mouse ever so slightly I find that the increments I make to a rotation go until the next poll (the statements in my main program are performed every frame while the condition if key Z down is true. These statements will not stop until polling is done 30ms later, which is the next chance that the action will be stopped by if key Z up is true).
I can't just have a set increment of the rotation every key press (it has to be incrementing outside of the polling code) otherwise the increments only occur every 30ms making the animation jerky.
I also believe increasing the polling time for input will only serve to slow things down dramatically (I did try polling every 1ms and the program became terribly slow).
Perhaps there is a more efficient way of checking for input?
I hope my explanation was clear enough.
Paulcoz.
Edited by - paulcoz on 3/27/00 2:34:13 AM
I don''t know if it''ll solve your problem, but you may want to try buffered input or poll DirectInput devices more often. I may be way off here, but I poll both mouse and keyboard every frame and I haven''t had any slowdowns because of that.
============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
Polling every frame is something I have considered. Just to make sure we are talking about the same thing here:
while (main rendering loop)
(
Draw World
Check for input
)
Is that a reasonable way of doing it? Instead of having a timer message which triggers the input checks every 30ms your checks run every frame. Won''t that decrease the frame rate? There is quite a big slab of code to process (in my input checks anyway).
I read on some thread a while back that you could choose to just check the input state for keyboard / mouse when a new input message was received (instead of at regular intervals like I am doing it). I don''t know enough about buffered input to know whether that was what they were talking about.
Polling every frame just seems on the surface to be too slow to me, though I am an optimisation freak.
Paulcoz.
while (main rendering loop)
(
Draw World
Check for input
)
Is that a reasonable way of doing it? Instead of having a timer message which triggers the input checks every 30ms your checks run every frame. Won''t that decrease the frame rate? There is quite a big slab of code to process (in my input checks anyway).
I read on some thread a while back that you could choose to just check the input state for keyboard / mouse when a new input message was received (instead of at regular intervals like I am doing it). I don''t know enough about buffered input to know whether that was what they were talking about.
Polling every frame just seems on the surface to be too slow to me, though I am an optimisation freak.
Paulcoz.
My day job is working for Saitek (www.saitek.com), so I should be able to help here:
The answer lies in the last two posts, you need to use buffered input and check the buffers each frame. The nice thing about buffered input is that everything is time stamped, so even if your game is running like a slug (for whatever reason) and you are using some formula for movement based on time, then you can initiate actions based on the time stamps of the input, not just on the instant that you are processing the frame.
The answer lies in the last two posts, you need to use buffered input and check the buffers each frame. The nice thing about buffered input is that everything is time stamped, so even if your game is running like a slug (for whatever reason) and you are using some formula for movement based on time, then you can initiate actions based on the time stamps of the input, not just on the instant that you are processing the frame.
My day job is working for Saitek (www.saitek.com), so I should be able to help here:
The answer lies in the last two posts, you need to use buffered input and check the buffers each frame. The nice thing about buffered input is that everything is time stamped, so even if your game is running like a slug (for whatever reason) and you are using some formula for movement based on time, then you can initiate actions based on the time stamps of the input, not just on the instant that you are processing the frame.
The answer lies in the last two posts, you need to use buffered input and check the buffers each frame. The nice thing about buffered input is that everything is time stamped, so even if your game is running like a slug (for whatever reason) and you are using some formula for movement based on time, then you can initiate actions based on the time stamps of the input, not just on the instant that you are processing the frame.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement