mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-24 14:51:04 +00:00
Use CoreTiming for input polling, sync to vblank
This commit is contained in:
parent
9dcbb07840
commit
614da6bc17
@ -5,8 +5,6 @@
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
|
||||
#include "input_common/input_common.h"
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
|
||||
@ -62,8 +60,6 @@ int Init() {
|
||||
g_sys_core = new ARM_DynCom(USER32MODE);
|
||||
g_app_core = new ARM_DynCom(USER32MODE);
|
||||
|
||||
InputCommon::Init(InputCommon::SDL2_JOY);
|
||||
|
||||
LOG_DEBUG(Core, "Initialized OK");
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
#include "input_common/input_common.h"
|
||||
|
||||
namespace System {
|
||||
|
||||
void Init(EmuWindow* emu_window) {
|
||||
@ -22,9 +24,11 @@ void Init(EmuWindow* emu_window) {
|
||||
Kernel::Init();
|
||||
HLE::Init();
|
||||
VideoCore::Init(emu_window);
|
||||
InputCommon::Init(InputCommon::SDL2_JOY);
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
//InputCommon::Shutdown();
|
||||
VideoCore::Shutdown();
|
||||
HLE::Shutdown();
|
||||
Kernel::Shutdown();
|
||||
|
@ -5,11 +5,32 @@
|
||||
#include "input_common/input_common.h"
|
||||
#include "input_common/sdl_input/sdl_input.h"
|
||||
|
||||
#include "core/core_timing.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
namespace InputCommon {
|
||||
|
||||
//Set to nullptr until initialized by a backend
|
||||
ControllerBase* g_user_input = nullptr;
|
||||
|
||||
//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 != nullptr) {
|
||||
g_user_input->Poll();
|
||||
}
|
||||
|
||||
// Reschedule recurrent event
|
||||
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event);
|
||||
}
|
||||
|
||||
std::string ControllerBase::GetDeviceName() const {
|
||||
return device_name;
|
||||
}
|
||||
@ -30,6 +51,12 @@ void Init(ControllerBackends backend) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Setup CoreTiming
|
||||
frame_ticks = 268123480 / Settings::values.gpu_refresh_rate;
|
||||
|
||||
input_event = CoreTiming::RegisterEvent("InputCommon::InputCallback", InputCallback);
|
||||
CoreTiming::ScheduleEvent(frame_ticks, input_event);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user