Use EmuWindow's PollEvents() in favor of CoreTiming for input polling

This commit is contained in:
Daniel Stuart Baxter 2015-06-02 01:34:49 -05:00
parent 8ac1bb3b04
commit 892c46fb37
4 changed files with 7 additions and 26 deletions

View file

@ -12,6 +12,8 @@
#include "citra/emu_window/emu_window_glfw.h" #include "citra/emu_window/emu_window_glfw.h"
#include "input_common/input_common.h"
EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) { EmuWindow_GLFW* EmuWindow_GLFW::GetEmuWindow(GLFWwindow* win) {
return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win)); return static_cast<EmuWindow_GLFW*>(glfwGetWindowUserPointer(win));
} }
@ -125,6 +127,7 @@ void EmuWindow_GLFW::SwapBuffers() {
/// Polls window events /// Polls window events
void EmuWindow_GLFW::PollEvents() { void EmuWindow_GLFW::PollEvents() {
glfwPollEvents(); glfwPollEvents();
InputCommon::g_user_input->Poll();
} }
/// Makes the GLFW OpenGL context current for the caller thread /// Makes the GLFW OpenGL context current for the caller thread

View file

@ -21,6 +21,8 @@
#include "citra_qt/version.h" #include "citra_qt/version.h"
#include "input_common/input_common.h"
#define APP_NAME "citra" #define APP_NAME "citra"
#define APP_VERSION "0.1-" VERSION #define APP_VERSION "0.1-" VERSION
#define APP_TITLE APP_NAME " " APP_VERSION #define APP_TITLE APP_NAME " " APP_VERSION
@ -159,6 +161,7 @@ void GRenderWindow::DoneCurrent()
} }
void GRenderWindow::PollEvents() { void GRenderWindow::PollEvents() {
InputCommon::g_user_input->Poll();
} }
// On Qt 5.0+, this correctly gets the size of the framebuffer (pixels). // On Qt 5.0+, this correctly gets the size of the framebuffer (pixels).

View file

@ -8,30 +8,11 @@
#include "input_common/sdl_input/sdl_input.h" #include "input_common/sdl_input/sdl_input.h"
#endif #endif
#include "core/core_timing.h"
#include "core/settings.h"
namespace InputCommon { namespace InputCommon {
// User input system // User input system
std::unique_ptr<InputBase> g_user_input; std::unique_ptr<InputBase> 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 { const std::string& InputBase::GetDeviceName() const {
return device_name; return device_name;
} }
@ -64,12 +45,6 @@ void Init(InputBackends backend) {
Shutdown(); Shutdown();
return; 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() { void Shutdown() {

View file

@ -13,7 +13,7 @@ namespace InputCommon {
class SDLController final : public InputBase { class SDLController final : public InputBase {
public: public:
SDLController(); SDLController();
~SDLController(); ~SDLController() override;
/// Initializes input via SDL2 /// Initializes input via SDL2
bool Init() override; bool Init() override;