From 13fbf3e6e36bfc345093b8084ffead856f1fa3e0 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 30 Jul 2015 23:26:47 -0700 Subject: [PATCH] Qt: Fix non-SDL build with compilers that fail to respect short-circuiting --- src/platform/qt/InputController.cpp | 18 +++++++++++++++--- src/platform/qt/InputController.h | 2 -- src/platform/qt/Window.cpp | 2 -- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index 11e5ce018..85bf49b1c 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -207,10 +207,12 @@ void InputController::setPreferredGamepad(uint32_t type, const QString& device) } GBARumble* InputController::rumble() { -#if defined(BUILD_SDL) && SDL_VERSION_ATLEAST(2, 0, 0) +#ifdef BUILD_SDL +#if SDL_VERSION_ATLEAST(2, 0, 0) if (m_playerAttached) { return &m_sdlPlayer.rumble.d; } +#endif #endif return nullptr; } @@ -497,19 +499,29 @@ bool InputController::hasPendingEvent(GBAKey key) const { return m_pendingEvents.contains(key); } -#if defined(BUILD_SDL) && SDL_VERSION_ATLEAST(2, 0, 0) void InputController::suspendScreensaver() { +#ifdef BUILD_SDL +#if SDL_VERSION_ATLEAST(2, 0, 0) GBASDLSuspendScreensaver(&s_sdlEvents); +#endif +#endif } void InputController::resumeScreensaver() { +#ifdef BUILD_SDL +#if SDL_VERSION_ATLEAST(2, 0, 0) GBASDLResumeScreensaver(&s_sdlEvents); +#endif +#endif } void InputController::setScreensaverSuspendable(bool suspendable) { +#ifdef BUILD_SDL +#if SDL_VERSION_ATLEAST(2, 0, 0) GBASDLSetScreensaverSuspendable(&s_sdlEvents, suspendable); -} #endif +#endif +} void InputController::stealFocus(QWidget* focus) { m_focusParent = focus; diff --git a/src/platform/qt/InputController.h b/src/platform/qt/InputController.h index b0e25e92f..f73524bad 100644 --- a/src/platform/qt/InputController.h +++ b/src/platform/qt/InputController.h @@ -87,12 +87,10 @@ signals: public slots: void testGamepad(int type); -#if defined(BUILD_SDL) && SDL_VERSION_ATLEAST(2, 0, 0) // TODO: Move these to somewhere that makes sense void suspendScreensaver(); void resumeScreensaver(); void setScreensaverSuspendable(bool); -#endif private: void postPendingEvent(GBAKey); diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 4029becc7..1ab8ca049 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -210,9 +210,7 @@ void Window::loadConfig() { enterFullScreen(); } -#if defined(BUILD_SDL) && SDL_VERSION_ATLEAST(2, 0, 0) m_inputController.setScreensaverSuspendable(opts->suspendScreensaver); -#endif m_mruFiles = m_config->getMRU(); updateMRU();