Added logic to increase/decrease emulation speed via hotkeys using QTimer system. Bug fix for = key Qt to SDL mapping.

This commit is contained in:
Matthew Budd 2020-07-03 21:52:27 -04:00
parent 72141845f0
commit c496c0f281
5 changed files with 31 additions and 8 deletions

View File

@ -40,6 +40,14 @@ gameWin_t::~gameWin_t(void)
delete viewport;
}
void gameWin_t::setCyclePeriodms( int ms )
{
// If timer is already running, it will be restarted.
gameTimer->start( ms );
//printf("Period Set to: %i ms \n", ms );
}
void gameWin_t::closeEvent(QCloseEvent *event)
{
//printf("Main Window Close Event\n");

View File

@ -30,6 +30,8 @@ class gameWin_t : public QMainWindow
gameViewGL_t *viewport;
//gameViewSDL_t *viewport;
void setCyclePeriodms( int ms );
protected:
QMenu *fileMenu;
QMenu *optMenu;
@ -65,4 +67,6 @@ class gameWin_t : public QMainWindow
};
extern gameWin_t *gameWindow;
#endif

View File

@ -758,7 +758,7 @@ SDL_Keycode convQtKey2SDLKeyCode( Qt::Key q )
s = SDLK_LESS;
break;
case Key_Equal:
s = SDLK_LESS;
s = SDLK_EQUALS;
break;
case Key_Greater:
s = SDLK_GREATER;

View File

@ -3,17 +3,20 @@
#include "Qt/GameApp.h"
#include "Qt/fceuWrapper.h"
gameWin_t *gameWindow = NULL;
int main( int argc, char *argv[] )
{
QApplication app(argc, argv);
gameWin_t win;
gameWindow = new gameWin_t();
fceuWrapperInit( argc, argv );
win.resize( 512, 512 );
win.show();
gameWindow->resize( 512, 512 );
gameWindow->show();
win.viewport->init();
gameWindow->viewport->init();
return app.exec();
}

View File

@ -3,6 +3,7 @@
#include "Qt/sdl.h"
#include "Qt/throttle.h"
#include "Qt/GameApp.h"
static const double Slowest = 0.015625; // 1/64x speed (around 1 fps on NTSC)
static const double Fastest = 32; // 32x speed (around 1920 fps on NTSC)
@ -10,7 +11,7 @@ static const double Normal = 1.0; // 1x speed (around 60 fps on NTSC)
static uint64 Lasttime, Nexttime;
static double desired_frametime = (1.0 / 60.099823);
static int InFrame;
static int InFrame = 0;
double g_fpsScale = Normal; // used by sdl.cpp
bool MaxSpeed = false;
@ -32,12 +33,19 @@ RefreshThrottleFPS()
{
double hz;
int32_t fps = FCEUI_GetDesiredFPS(); // Do >> 24 to get in Hz
int32_t T;
hz = ( ((double)fps) / 16777216.0 );
desired_frametime = 1.0 / ( hz * g_fpsScale );
printf("FrameTime: %llu %llu %f %lf \n", fps, fps >> 24, hz, desired_frametime );
T = (int32_t)( desired_frametime * 1000.0 );
if ( T < 0 ) T = 1;
//printf("FrameTime: %llu %llu %f %lf \n", fps, fps >> 24, hz, desired_frametime );
gameWindow->setCyclePeriodms( T );
Lasttime=0;
Nexttime=0;