• Advertisement
Sign in to follow this  

Choppy keyboard input with SDL?

This topic is 3888 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

I am using SDL_PollEvent() and my keyinput is choppy. Meaning if you hold down the key and then press another key there is a delay before it uses the new keydown input... I am not sure what would cause this? I was using Dinput before with win32 before I moved to SDL and never had this issue before. If you were to use it as is, you would be dead in a FPS game, from the delays. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
I'm also using SDL_PollEvent and don't seem to have any problems with this. What's your frame rate like? Is it possible that some of your game processing might be delaying the time between SDL_PollEvent calls enough to cause it?

Share this post


Link to post
Share on other sites
Quote:
Original post by strtok
I'm also using SDL_PollEvent and don't seem to have any problems with this. What's your frame rate like? Is it possible that some of your game processing might be delaying the time between SDL_PollEvent calls enough to cause it?


It could be and I am hoping it's not for I have no idea how I would get around that...

Share this post


Link to post
Share on other sites
The only time I have had a problem with keyboard delay is when I have a low frame rate (10 or lower). Which cause a delay in the polling of the events.

Share this post


Link to post
Share on other sites
You are using while(SDL_PollEvent(...)) rather than if(SDL_PollEvent(...)), right?

The latter can cause choppy response to any type of event.

Share this post


Link to post
Share on other sites
while(SDL_PollEvent(sdlEvent))
{
switch(sdlEvent->type)
{}
}

Is what I am using.

Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999

It could be and I am hoping it's not for I have no idea how I would get around that...


Are you using OpenGL, and if so, do you have vsync swapping enabled? This could really delay your events if you have heavy per-frame processing going on. Do you use any kind of timers (or delta ticks) to control the frequency at which your code takes action based on events (i.e. every few frames instead of each and every frame)?

Share this post


Link to post
Share on other sites
I think it has to do with

SDL_EnableKeyRepeat() the delay is too long.

Share this post


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

  • Advertisement