From 806dd5ff3dc66f243b3284a6f009fe2276a28879 Mon Sep 17 00:00:00 2001 From: Xele02 Date: Wed, 30 Jan 2013 02:10:57 +0100 Subject: [PATCH] Make the running thread wait if we are too fast. Jit is so fast in QT compared to SDL, it's not playable. --- Qt/EmuThread.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Qt/EmuThread.cpp b/Qt/EmuThread.cpp index e1f361e95d..f41e170287 100644 --- a/Qt/EmuThread.cpp +++ b/Qt/EmuThread.cpp @@ -1,6 +1,7 @@ #include "EmuThread.h" #include +#include #include "Core/HLE/sceCtrl.h" #include "Core/Config.h" @@ -97,8 +98,12 @@ void EmuThread::run() #endif host->BootDone(); + QElapsedTimer timer; + while(running) { //UpdateGamepad(*input_state); + timer.start(); + UpdateInputState(input_state); static const int mapping[12][2] = { @@ -144,7 +149,15 @@ void EmuThread::run() if (coreState == CORE_NEXTFRAME) { // set back to running for the next frame coreState = CORE_RUNNING; + + qint64 time = timer.elapsed(); + const int frameTime = (1.0f/60.0f) * 1000; + if(time < frameTime) + { + msleep(frameTime-time); + } } + timer.start(); fbo_unbind();