0
\$\begingroup\$

I'm developing a FPS game and I'm considering polling at a high frequency on a separate thread. This decouples the game loop and reading input. I get sub-frame samples and can process those samples from a queue. My question is about determinism. I want to drive input handling with a variation of a state machine or DPDA. These things are not known for "fuzzy-friendliness" so I need to filter dequeued inputs (in the signal processing sense). How do real games implement high frequency input handling?

\$\endgroup\$
8
  • \$\begingroup\$ What benefit do you hope to gain from polling input faster than your game simulation loop? Or what problem do you have that this would solve? The player can't move or shoot more frequently than the movement and shooting simulation code runs anyway, so most games just read the latest input state once per simulation (or rendering) step, and that's enough for their needs. \$\endgroup\$ – DMGregory Nov 3 '20 at 17:06
  • \$\begingroup\$ I want as few ms of latency as possible between keystroke and page flip. I also want smooth movement with digital keys. If I can answer "how long was a key down?" I can do that. \$\endgroup\$ – Jesse Lactin Nov 3 '20 at 17:48
  • 1
    \$\begingroup\$ You still need a simulation step to pick up the queued input and convert it into movement of game entities for the next rendering step to display. So just polling your input faster does not improve your latency. Your simulation-render loop is responsible for that. Smooth movement from digital inputs generally does not use timings shorter than a simulation frame, so I doubt you'd find this necessary for that use either. \$\endgroup\$ – DMGregory Nov 3 '20 at 17:51
  • \$\begingroup\$ Good info. Thank you. Having derivatives in more important to smooth movement, I guess? \$\endgroup\$ – Jesse Lactin Nov 3 '20 at 18:16
  • 1
    \$\begingroup\$ Just accumulating an intensity each simulation tick that a key is held down, or using an acceleration model on your character controller, is usually enough for that. Do you have any problems with your movement being not smooth enough currently? If so, try editing your question to show us how you're moving your character currently, and describe how the outputs differ from what you want. Then we can help you solve that problem. \$\endgroup\$ – DMGregory Nov 3 '20 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.