Fixed freeze in fheroes2 when separate rendering thread is used

This commit is contained in:
pelya
2011-03-03 18:31:27 +02:00
parent d00aef85b6
commit f1a2cd9cf3
5 changed files with 30 additions and 26 deletions

View File

@@ -1199,57 +1199,61 @@ static SDL_mutex * BufferedEventsMutex = NULL;
extern void SDL_ANDROID_PumpEvents()
{
SDL_Event ev;
SDL_ANDROID_processAndroidTrackballDampening();
SDL_ANDROID_processMoveMouseWithKeyboard();
if( !BufferedEventsMutex )
BufferedEventsMutex = SDL_CreateMutex();
SDL_mutexP(BufferedEventsMutex);
while( BufferedEventsStart != BufferedEventsEnd )
{
SDL_Event * ev = &BufferedEvents[BufferedEventsStart];
ev = BufferedEvents[BufferedEventsStart];
BufferedEvents[BufferedEventsStart].type = 0;
BufferedEventsStart++;
if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
BufferedEventsStart = 0;
SDL_mutexV(BufferedEventsMutex);
switch( ev->type )
switch( ev.type )
{
case SDL_MOUSEMOTION:
SDL_SendMouseMotion(NULL, 0, ev->motion.x, ev->motion.y);
SDL_SendMouseMotion(NULL, 0, ev.motion.x, ev.motion.y);
break;
case SDL_MOUSEBUTTONDOWN:
if( ((oldMouseButtons & SDL_BUTTON(ev->button.button)) != 0) != ev->button.state )
if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state )
{
oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev->button.button)) | (ev->button.state ? SDL_BUTTON(ev->button.button) : 0);
SDL_SendMouseButton( NULL, ev->button.state, ev->button.button );
oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0);
SDL_SendMouseButton( NULL, ev.button.state, ev.button.button );
}
break;
case SDL_KEYDOWN:
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev->key.keysym.sym, ev->key.state);
SDL_SendKeyboardKey( ev->key.state, &ev->key.keysym );
SDL_SendKeyboardKey( ev.key.state, &ev.key.keysym );
break;
case SDL_JOYAXISMOTION:
if( ev->jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev->jaxis.which] )
SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev->jaxis.which], ev->jaxis.axis, ev->jaxis.value );
if( ev.jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jaxis.which] )
SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev.jaxis.which], ev.jaxis.axis, ev.jaxis.value );
break;
case SDL_JOYBUTTONDOWN:
if( ev->jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev->jbutton.which] )
SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev->jbutton.which], ev->jbutton.button, ev->jbutton.state );
if( ev.jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev.jbutton.which], ev.jbutton.button, ev.jbutton.state );
break;
#if SDL_VERSION_ATLEAST(1,3,0)
case SDL_FINGERMOTION:
SDL_SendTouchMotion(0, ev->tfinger.fingerId, 0, ev->tfinger.x, ev->tfinger.y, ev->tfinger.pressure);
SDL_SendTouchMotion(0, ev.tfinger.fingerId, 0, ev.tfinger.x, ev.tfinger.y, ev.tfinger.pressure);
break;
case SDL_FINGERDOWN:
SDL_SendFingerDown(0, ev->tfinger.fingerId, ev->tfinger.state ? 1 : 0, ev->tfinger.x, ev->tfinger.y, ev->tfinger.pressure);
SDL_SendFingerDown(0, ev.tfinger.fingerId, ev.tfinger.state ? 1 : 0, ev.tfinger.x, ev.tfinger.y, ev.tfinger.pressure);
break;
case SDL_TEXTINPUT:
SDL_SendKeyboardText(ev->text.text);
SDL_SendKeyboardText(ev.text.text);
break;
#endif
}
ev->type = 0;
BufferedEventsStart++;
if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
BufferedEventsStart = 0;
SDL_mutexP(BufferedEventsMutex);
}
SDL_mutexV(BufferedEventsMutex);
};