From 892c46fb372521dcc24c4f2342084aef7d66e1d8 Mon Sep 17 00:00:00 2001 From: Daniel Stuart Baxter Date: Tue, 2 Jun 2015 01:34:49 -0500 Subject: [PATCH] Use EmuWindow's PollEvents() in favor of CoreTiming for input polling --- src/citra/emu_window/emu_window_glfw.cpp | 3 +++ src/citra_qt/bootmanager.cpp | 3 +++ src/input_common/input_common.cpp | 25 ------------------------ src/input_common/sdl_input/sdl_input.h | 2 +- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index 341b48d2a..1dbd1a00d 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp @@ -12,6 +12,8 @@ #include "citra/emu_window/emu_window_glfw.h" +#include "input_common/input_common.h" + EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) { return static_cast(glfwGetWindowUserPointer(win)); } @@ -125,6 +127,7 @@ void EmuWindow_GLFW::SwapBuffers() { /// Polls window events void EmuWindow_GLFW::PollEvents() { glfwPollEvents(); + InputCommon::g_user_input->Poll(); } /// Makes the GLFW OpenGL context current for the caller thread diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 72b55e94d..998cb1b18 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -21,6 +21,8 @@ #include "citra_qt/version.h" +#include "input_common/input_common.h" + #define APP_NAME "citra" #define APP_VERSION "0.1-" VERSION #define APP_TITLE APP_NAME " " APP_VERSION @@ -159,6 +161,7 @@ void GRenderWindow::DoneCurrent() } void GRenderWindow::PollEvents() { + InputCommon::g_user_input->Poll(); } // On Qt 5.0+, this correctly gets the size of the framebuffer (pixels). diff --git a/src/input_common/input_common.cpp b/src/input_common/input_common.cpp index b8a8407ab..47df0babf 100644 --- a/src/input_common/input_common.cpp +++ b/src/input_common/input_common.cpp @@ -8,30 +8,11 @@ #include "input_common/sdl_input/sdl_input.h" #endif -#include "core/core_timing.h" -#include "core/settings.h" - namespace InputCommon { // User input system std::unique_ptr g_user_input; -// Event id for CoreTiming -static int input_event; - -// Ticks for CoreTiming event, same as VBlank in GPU -static u64 frame_ticks; - -/// Callback for CoreTiming -static void InputCallback(u64 userdata, int cycles_late) { - - // Call user input plugin Poll() - if (g_user_input) g_user_input->Poll(); - - // Reschedule recurrent event - CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event); -} - const std::string& InputBase::GetDeviceName() const { return device_name; } @@ -64,12 +45,6 @@ void Init(InputBackends backend) { Shutdown(); return; } - - // Setup CoreTiming - frame_ticks = 268123480 / Settings::values.gpu_refresh_rate / 16; - - input_event = CoreTiming::RegisterEvent("InputCommon::InputCallback", InputCallback); - CoreTiming::ScheduleEvent(frame_ticks, input_event); } void Shutdown() { diff --git a/src/input_common/sdl_input/sdl_input.h b/src/input_common/sdl_input/sdl_input.h index 050db1d7e..d1c8c5e4b 100644 --- a/src/input_common/sdl_input/sdl_input.h +++ b/src/input_common/sdl_input/sdl_input.h @@ -13,7 +13,7 @@ namespace InputCommon { class SDLController final : public InputBase { public: SDLController(); - ~SDLController(); + ~SDLController() override; /// Initializes input via SDL2 bool Init() override;