From 8c19cb525784043dbf80bdcd48ad0738274b25c8 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Sun, 1 Aug 2021 21:05:08 -0400 Subject: [PATCH] Added detected screen refresh rate display to Qt video config window. Minor memory fixes. --- src/drivers/Qt/ConsoleDebugger.cpp | 1 - src/drivers/Qt/ConsoleVideoConf.cpp | 24 ++++++++++++++++++++---- src/drivers/Qt/ConsoleVideoConf.h | 1 + src/drivers/Qt/ConsoleWindow.cpp | 2 ++ src/drivers/Qt/ConsoleWindow.h | 3 +++ src/drivers/Qt/sdl-joystick.cpp | 7 ++++++- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/drivers/Qt/ConsoleDebugger.cpp b/src/drivers/Qt/ConsoleDebugger.cpp index 134df039..806cb578 100644 --- a/src/drivers/Qt/ConsoleDebugger.cpp +++ b/src/drivers/Qt/ConsoleDebugger.cpp @@ -1092,7 +1092,6 @@ void ConsoleDebugger::buildPpuListDisplay(void) ppuStatContainerWidget = new QWidget(this); ppuStatContainerWidget->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); - vbox1 = new QVBoxLayout(); ppuFrame = new QFrame(); grid = new QGridLayout(); diff --git a/src/drivers/Qt/ConsoleVideoConf.cpp b/src/drivers/Qt/ConsoleVideoConf.cpp index 07819a15..4c71aec8 100644 --- a/src/drivers/Qt/ConsoleVideoConf.cpp +++ b/src/drivers/Qt/ConsoleVideoConf.cpp @@ -37,8 +37,8 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) : QDialog( parent ) { - QVBoxLayout *main_vbox, *vbox1, *vbox2; - QHBoxLayout *main_hbox, *hbox1; + QVBoxLayout *main_vbox, *vbox1, *vbox2, *vbox; + QHBoxLayout *main_hbox, *hbox1, *hbox; QLabel *lbl; QPushButton *button; QStyle *style; @@ -46,6 +46,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) QGridLayout *grid; QFont font; int opt, fontCharWidth; + char stmp[128]; font.setFamily("Courier New"); font.setStyle( QFont::StyleNormal ); @@ -412,10 +413,25 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) setCheckBoxFromProperty( cursorVisCbx, "SDL.CursorVis" ); grid->addWidget( cursorVisCbx, 1, 0, 2, 1, Qt::AlignLeft); - //grid->addWidget( drawInputAidsCbx, 2, 0, 2, 1, Qt::AlignLeft); - connect(cursorVisCbx , SIGNAL(stateChanged(int)), this, SLOT(cursorVisChanged(int)) ); + vbox = new QVBoxLayout(); + hbox = new QHBoxLayout(); + gbox = new QGroupBox( tr("Screen") ); + gbox->setLayout( vbox ); + + scrRateReadout = new QLineEdit(); + scrRateReadout->setFont( font ); + scrRateReadout->setReadOnly(true); + scrRateReadout->setAlignment(Qt::AlignCenter); + sprintf( stmp, "%.3f", consoleWindow->getRefreshRate() ); + scrRateReadout->setText( tr(stmp) ); + + hbox->addWidget( new QLabel( tr("Refresh Rate (Hz):") ) ); + hbox->addWidget( scrRateReadout ); + vbox->addLayout( hbox ); + + vbox2->addWidget( gbox ); vbox2->addStretch( 5 ); setLayout( main_vbox ); diff --git a/src/drivers/Qt/ConsoleVideoConf.h b/src/drivers/Qt/ConsoleVideoConf.h index 337f771b..ad84febf 100644 --- a/src/drivers/Qt/ConsoleVideoConf.h +++ b/src/drivers/Qt/ConsoleVideoConf.h @@ -59,6 +59,7 @@ class ConsoleVideoConfDialog_t : public QDialog QSpinBox *pal_end; QLineEdit *winSizeReadout; QLineEdit *vpSizeReadout; + QLineEdit *scrRateReadout; void setCheckBoxFromProperty( QCheckBox *cbx, const char *property ); void setComboBoxFromProperty( QComboBox *cbx, const char *property ); diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index b6e2b8db..071124b6 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -214,6 +214,7 @@ consoleWin_t::consoleWin_t(QWidget *parent) this->showFullScreen(); } + refreshRate = 0.0; updateCounter = 0; recentRomMenuReset = false; @@ -369,6 +370,7 @@ void consoleWin_t::winScreenChanged(QScreen *scr) { return; } + refreshRate = scr->refreshRate(); //printf("Screen Refresh Rate: %f\n", scr->refreshRate() ); //printf("Screen Changed: %p\n", scr ); diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index 0ab7eeb1..0dc31509 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -152,6 +152,8 @@ class consoleWin_t : public QMainWindow int loadVideoDriver( int driverId ); + double getRefreshRate(void){ return refreshRate; } + emulatorThread_t *emulatorThread; AviRecordDiskThread_t *aviDiskThread; @@ -258,6 +260,7 @@ class consoleWin_t : public QMainWindow std::vector afActList; autoFireMenuAction *afActCustom; + double refreshRate; unsigned int updateCounter; protected: void resizeEvent(QResizeEvent *event) override; diff --git a/src/drivers/Qt/sdl-joystick.cpp b/src/drivers/Qt/sdl-joystick.cpp index ef0a50c7..b1f5aece 100644 --- a/src/drivers/Qt/sdl-joystick.cpp +++ b/src/drivers/Qt/sdl-joystick.cpp @@ -460,6 +460,11 @@ int GamePad_t::convText2ButtConfig( const char *txt, ButtConfig *bmap ) bmap->DeviceNum = -1; bmap->ButtonNum = -1; + if (txt[0] == 0 ) + { + return 0; + } + if (txt[0] == 'k') { SDL_Keycode key; @@ -718,7 +723,7 @@ int GamePad_t::loadHotkeyMapFromFile(const char *filename) char line[256]; char id[128]; char val[128]; - bool lineIsHotKey; + bool lineIsHotKey = false; char modBtn[32], priBtn[32]; char onPressAct[64], onReleaseAct[64];