I found the problem when used the recommended method of handling window events for mouse and keyboard on the 3D scene (mouse for the look direction, keyboard - the moving):
if(SDL_PollEvent(&ev))
{
switch(ev.type){
case SDL_KEYDOWN: {
render.push_keys(&ev);
break;
}
case SDL_MOUSEMOTION: {
SDL_WarpMouseInWindow(id, iW/2, iH/2);
render.push_mouse(&ev);
break;
}
}
}
Description of the problem: on the 3D scene mouse events subpressing the events queue from the keboard. When the mouse don’t moving keyboard handling is working correctly. Otherwise, all the keboard events accumulated in the buffer and start handling only when the mouse was stop. I was found this on the Linux+Xfce4 with SDL2. On the MS-Win 8 it is insensibly.
Has anyone seen this problem? How differently to implement event handling?
Change your **if(SDL_PollEvent(&ev)) ** into **while(SDL_PollEvent(&ev)) ** and check if it works after that. If not, let me know and I will try to help you further.
But I doubt in choosing the method of the checking window events (resize, quit) in this case. It is better to choose function for the checking window events? Can you help me to select?
To be able to help you further, I’m afraid I’ll need to see the rest of your code, especially the one that’s handling the keyboard and mouse inputs (i.e the function that handles all the ‘actions’). Do you have your code in github, dropbox or similar?
Thank you for your time. For myself, I already solved the issue.
Do you have a relationship to SDL2 developers? If it is necessary, I can prepare a small sample application and place the code in an open place to understand and fix the issue in the topic.