From f262d8932fc89ed8b02b5aff93a4bce7d68b34da Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 4 Jun 2011 17:53:42 +0200 Subject: PS3: Keep updating the screen while the XMB is open to prevent it from freezing --- backends/events/ps3sdl/ps3sdl-events.cpp | 39 ++++++++++++++++++++++++++++++++ backends/events/ps3sdl/ps3sdl-events.h | 1 + 2 files changed, 40 insertions(+) diff --git a/backends/events/ps3sdl/ps3sdl-events.cpp b/backends/events/ps3sdl/ps3sdl-events.cpp index 4bcc8e15ba..eefc641844 100644 --- a/backends/events/ps3sdl/ps3sdl-events.cpp +++ b/backends/events/ps3sdl/ps3sdl-events.cpp @@ -25,6 +25,8 @@ #if defined(PLAYSTATION3) #include "backends/events/ps3sdl/ps3sdl-events.h" +#include "backends/platform/sdl/sdl.h" +#include "engines/engine.h" #include "common/util.h" #include "common/events.h" @@ -121,4 +123,41 @@ bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { return true; } +/** + * The XMB (PS3 in game menu) needs the screen buffers to be constantly flip while open. + * This pauses execution and keeps redrawing the screen until the XMB is closed. + */ +void PS3SdlEventSource::preprocessEvents(SDL_Event *event) { + if (event->type == SDL_ACTIVEEVENT) { + if (event->active.state == SDL_APPMOUSEFOCUS && !event->active.gain) { + // XMB opened + if (g_engine) + g_engine->pauseEngine(true); + + for (;;) { + if (!SDL_PollEvent(event)) { + // Locking the screen forces a full redraw + Graphics::Surface* screen = g_system->lockScreen(); + if (screen) { + g_system->unlockScreen(); + g_system->updateScreen(); + } + SDL_Delay(10); + continue; + } + if (event->type == SDL_QUIT) + return; + if (event->type != SDL_ACTIVEEVENT) + continue; + if (event->active.state == SDL_APPMOUSEFOCUS && event->active.gain) { + // XMB closed + if (g_engine) + g_engine->pauseEngine(false); + return; + } + } + } + } +} + #endif diff --git a/backends/events/ps3sdl/ps3sdl-events.h b/backends/events/ps3sdl/ps3sdl-events.h index 328f613350..8cf2f43426 100644 --- a/backends/events/ps3sdl/ps3sdl-events.h +++ b/backends/events/ps3sdl/ps3sdl-events.h @@ -30,6 +30,7 @@ */ class PS3SdlEventSource : public SdlEventSource { protected: + void preprocessEvents(SDL_Event *event); bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event); bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event); }; -- cgit v1.2.3