Added a low rate periodic update function to Qt input window to ensure that it stays synchronized with the state of the emulator input settings.

This commit is contained in:
Matthew Budd 2020-11-24 07:01:34 -05:00
parent c4a066c25c
commit fa18154ac3
2 changed files with 38 additions and 0 deletions

View File

@ -47,6 +47,10 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
pal = this->palette();
inputTimer = new QTimer( this );
connect( inputTimer, &QTimer::timeout, this, &InputConfDialog_t::updatePeriodic );
setWindowTitle("Input Configuration");
mainLayout = new QVBoxLayout();
@ -213,11 +217,14 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
connect( saveConfigButton, SIGNAL(clicked(void)), this, SLOT(openSavePresetFile(void)) );
updatePortLabels();
inputTimer->start( 500 ); // 2hz
}
//----------------------------------------------------------------------------
InputConfDialog_t::~InputConfDialog_t(void)
{
printf("Destroy Input Config Window\n");
inputTimer->stop();
if ( win == this )
{
@ -356,6 +363,8 @@ void InputConfDialog_t::port2MicChanged(int state)
//----------------------------------------------------------------------------
void InputConfDialog_t::openPortConfig(int portNum)
{
updatePortLabels();
switch ( curNesInput[portNum] )
{
default:
@ -493,3 +502,29 @@ void InputConfDialog_t::openSavePresetFile(void)
saveInputSettingsToFile( filename.toStdString().c_str() );
}
//----------------------------------------------------------------------------
void InputConfDialog_t::updatePeriodic(void)
{
bool updateNeeded = false;
int tmpCurInputType[3], tmpUsrInputType[3];
for (int i=0; i<3; i++)
{
getInputSelection( i, &tmpCurInputType[i], &tmpUsrInputType[i] );
if ( curNesInput[i] != tmpCurInputType[i] )
{
updateNeeded = true;
}
if ( usrNesInput[i] != tmpUsrInputType[i] )
{
updateNeeded = true;
}
}
if ( updateNeeded )
{
updatePortLabels();
updatePortComboBoxes();
}
}
//----------------------------------------------------------------------------

View File

@ -16,6 +16,7 @@
#include <QGroupBox>
#include <QTreeView>
#include <QTreeWidget>
#include <QTimer>
#include "Qt/main.h"
@ -30,6 +31,7 @@ class InputConfDialog_t : public QDialog
protected:
void closeEvent(QCloseEvent *event);
QTimer *inputTimer;
QCheckBox *fourScoreEna;
QCheckBox *port2Mic;
QLabel *nesPortLabel[2];
@ -63,6 +65,7 @@ class InputConfDialog_t : public QDialog
void port2MicChanged(int state);
void openLoadPresetFile(void);
void openSavePresetFile(void);
void updatePeriodic(void);
};