diff --git a/Core/Core.cpp b/Core/Core.cpp index d92c88a9e2..8beaecd685 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -57,8 +57,6 @@ static double lastActivity = 0.0; static double lastKeepAwake = 0.0; static GraphicsContext *graphicsContext; -extern InputState input_state; - void Core_SetGraphicsContext(GraphicsContext *ctx) { graphicsContext = ctx; } @@ -152,16 +150,16 @@ bool UpdateScreenScale(int width, int height, bool smallWindow) { return false; } -void UpdateRunLoop() { +void UpdateRunLoop(InputState *input_state) { if (windowHidden && g_Config.bPauseWhenMinimized) { sleep_ms(16); return; } - NativeUpdate(input_state); + NativeUpdate(*input_state); { - lock_guard guard(input_state.lock); - EndInputState(&input_state); + lock_guard guard(input_state->lock); + EndInputState(input_state); } if (GetUIState() != UISTATE_EXIT) { @@ -169,13 +167,13 @@ void UpdateRunLoop() { } } -void Core_RunLoop(GraphicsContext *ctx) { +void Core_RunLoop(GraphicsContext *ctx, InputState *input_state) { graphicsContext = ctx; while ((GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT) { time_update(); #if defined(USING_WIN_UI) double startTime = time_now_d(); - UpdateRunLoop(); + UpdateRunLoop(input_state); // Simple throttling to not burn the GPU in the menu. time_update(); @@ -187,13 +185,13 @@ void Core_RunLoop(GraphicsContext *ctx) { ctx->SwapBuffers(); } #else - UpdateRunLoop(); + UpdateRunLoop(input_state); #endif } while (!coreState && GetUIState() == UISTATE_INGAME) { time_update(); - UpdateRunLoop(); + UpdateRunLoop(input_state); #if defined(USING_WIN_UI) if (!windowHidden && !Core_IsStepping()) { ctx->SwapBuffers(); @@ -234,7 +232,7 @@ static inline void CoreStateProcessed() { } // Some platforms, like Android, do not call this function but handle things on their own. -void Core_Run(GraphicsContext *ctx) +void Core_Run(GraphicsContext *ctx, InputState *input_state) { #if defined(_DEBUG) host->UpdateDisassembly(); @@ -249,7 +247,7 @@ reswitch: if (GetUIState() == UISTATE_EXIT) { return; } - Core_RunLoop(ctx); + Core_RunLoop(ctx, input_state); #if defined(USING_QT_UI) && !defined(MOBILE_DEVICE) return; #else @@ -261,7 +259,7 @@ reswitch: { case CORE_RUNNING: // enter a fast runloop - Core_RunLoop(ctx); + Core_RunLoop(ctx, input_state); break; // We should never get here on Android. diff --git a/Core/Core.h b/Core/Core.h index 8b8edfa699..5398853de4 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -21,10 +21,11 @@ #include "Core/CoreParameter.h" class GraphicsContext; +struct InputState; // called from emu thread -void UpdateRunLoop(); -void Core_Run(GraphicsContext *ctx); +void UpdateRunLoop(GraphicsContext *input_state); +void Core_Run(GraphicsContext *ctx, InputState *input_state); void Core_Stop(); void Core_ErrorPause(); // For platforms that don't call Core_Run diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index eaf5fc81f5..33ce542869 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -192,7 +192,7 @@ unsigned int WINAPI TheThread(void *) if (!Core_IsActive()) UpdateUIState(UISTATE_MENU); - Core_Run(graphicsContext); + Core_Run(graphicsContext, &input_state); } shutdown: diff --git a/ext/native/base/BlackberryMain.cpp b/ext/native/base/BlackberryMain.cpp index 3de6a62502..bdf357475a 100644 --- a/ext/native/base/BlackberryMain.cpp +++ b/ext/native/base/BlackberryMain.cpp @@ -348,7 +348,7 @@ void BlackberryMain::runMain() { switchDisplay(screen_ui); } time_update(); - UpdateRunLoop(); + UpdateRunLoop(&input_state); // This handles VSync if (emulating) eglSwapBuffers(egl_disp[screen_emu], egl_surf[screen_emu]); diff --git a/ext/native/base/PCMain.cpp b/ext/native/base/PCMain.cpp index 2f0d1ad995..cead0d7713 100644 --- a/ext/native/base/PCMain.cpp +++ b/ext/native/base/PCMain.cpp @@ -859,7 +859,7 @@ int main(int argc, char *argv[]) { SimulateGamepad(keys, &input_state); input_state.pad_buttons = pad_buttons; UpdateInputState(&input_state, true); - UpdateRunLoop(); + UpdateRunLoop(&input_state); if (g_QuitRequested) break; #if defined(PPSSPP) && !defined(MOBILE_DEVICE) diff --git a/ext/native/base/QtMain.cpp b/ext/native/base/QtMain.cpp index 6cd15fdd84..cad9257f6a 100644 --- a/ext/native/base/QtMain.cpp +++ b/ext/native/base/QtMain.cpp @@ -360,7 +360,7 @@ void MainUI::paintGL() updateAccelerometer(); UpdateInputState(&input_state); time_update(); - UpdateRunLoop(); + UpdateRunLoop(&input_state); } void MainUI::updateAccelerometer() diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 2cf222d05a..806b9dcf06 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -82,8 +82,6 @@ bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &default void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } -InputState input_state; - int printUsage(const char *progname, const char *reason) { if (reason != NULL) diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 3c8d6ccd40..133e1fb268 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -48,8 +48,6 @@ #include "unittest/TestVertexJit.h" #include "unittest/UnitTest.h" -InputState input_state; - std::string System_GetProperty(SystemProperty prop) { return ""; } int System_GetPropertyInt(SystemProperty prop) { return -1; } void NativeMessageReceived(const char *message, const char *value) {}