Game Pad calibration page still in work.

This commit is contained in:
Matthew Budd 2020-06-26 21:56:26 -04:00
parent cb664b44a0
commit 1980dd8c5b
5 changed files with 66 additions and 11 deletions

View File

@ -56,6 +56,8 @@ void gameWin_t::closeEvent(QCloseEvent *event)
gamePadConfWin->closeWindow();
}
event->accept();
closeApp();
}
void gameWin_t::keyPressEvent(QKeyEvent *event)
@ -70,6 +72,7 @@ void gameWin_t::keyReleaseEvent(QKeyEvent *event)
pushKeyEvent( event, 0 );
}
//---------------------------------------------------------------------------
void gameWin_t::createMainMenu(void)
{
// This is needed for menu bar to show up on MacOS
@ -100,7 +103,7 @@ void gameWin_t::createMainMenu(void)
// File -> Quit
quitAct = new QAction(tr("&Quit"), this);
quitAct->setStatusTip(tr("Quit the Application"));
connect(quitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(quitAct, SIGNAL(triggered()), this, SLOT(closeApp()));
fileMenu->addAction(quitAct);
@ -126,6 +129,21 @@ void gameWin_t::createMainMenu(void)
helpMenu->addAction(aboutAct);
};
//---------------------------------------------------------------------------
void gameWin_t::closeApp(void)
{
fceuWrapperClose();
// LoadGame() checks for an IP and if it finds one begins a network session
// clear the NetworkIP field so this doesn't happen unintentionally
g_config->setOption ("SDL.NetworkIP", "");
g_config->save ();
//SDL_Quit (); // Already called by fceuWrapperClose
//qApp::quit();
qApp->quit();
}
//---------------------------------------------------------------------------
void gameWin_t::openROMFile(void)
{

View File

@ -53,6 +53,7 @@ class gameWin_t : public QMainWindow
void createMainMenu(void);
private slots:
void closeApp(void);
void openROMFile(void);
void closeROMCB(void);
void aboutQPlot(void);

View File

@ -18,6 +18,7 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
QPushButton *closebutton;
portNum = 0;
configNo = 0;
buttonConfigStatus = 1;
setWindowTitle("GamePad Config");
@ -56,7 +57,6 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
for (int i=0; i<10; i++)
{
char text[64];
const char *keyNameStr;
QLabel *buttonName;
sprintf( text, "%s:", GamePadNames[i] );
@ -65,16 +65,16 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
//hbox2->setAlignment(Qt::AlignCenter);
keyNameStr = ButtonName( &GamePadConfig[portNum][i], portNum );
buttonName = new QLabel(tr(text));
keyName[i] = new QLabel(tr(keyNameStr));
keyName[i] = new QLabel();
button[i] = new GamePadConfigButton_t(i);
grid->addWidget( buttonName, i, 0, Qt::AlignCenter );
grid->addWidget( keyName[i], i, 1, Qt::AlignCenter );
grid->addWidget( button[i] , i, 2, Qt::AlignCenter );
}
updateCntrlrDpy();
closebutton = new QPushButton(tr("Close"));
connect(button[0], SIGNAL(clicked()), this, SLOT(changeButton0(void)) );
@ -89,6 +89,7 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
connect(button[9], SIGNAL(clicked()), this, SLOT(changeButton9(void)) );
connect(closebutton, SIGNAL(clicked()), this, SLOT(closeWindow(void)) );
connect(portSel , SIGNAL(activated(int)), this, SLOT(controllerSelect(int)) );
connect(efs_chkbox , SIGNAL(stateChanged(int)), this, SLOT(ena4score(int)) );
connect(udlr_chkbox, SIGNAL(stateChanged(int)), this, SLOT(oppDirEna(int)) );
@ -121,6 +122,32 @@ void GamePadConfDialog_t::keyReleaseEvent(QKeyEvent *event)
pushKeyEvent( event, 0 );
}
//----------------------------------------------------
void GamePadConfDialog_t::updateCntrlrDpy(void)
{
char keyNameStr[128];
for (int i=0; i<10; i++)
{
if (GamePadConfig[portNum][i].ButtType[configNo] == BUTTC_KEYBOARD)
{
snprintf( keyNameStr, sizeof (keyNameStr), "%s",
SDL_GetKeyName (GamePadConfig[portNum][i].ButtonNum[configNo]));
}
else
{
strcpy( keyNameStr, ButtonName( &GamePadConfig[portNum][i], configNo ) );
}
keyName[i]->setText( tr(keyNameStr) );
}
}
//----------------------------------------------------
void GamePadConfDialog_t::controllerSelect(int index)
{
printf("Port Number:%i \n", index);
portNum = index;
updateCntrlrDpy();
}
//----------------------------------------------------
void GamePadConfDialog_t::ena4score(int state)
{
int value = (state == Qt::Unchecked) ? 0 : 1;
@ -137,7 +164,6 @@ void GamePadConfDialog_t::oppDirEna(int state)
//----------------------------------------------------
void GamePadConfDialog_t::changeButton(int padNo, int x)
{
int configNo = 0;
char buf[256];
std::string prefix;
const char *keyNameStr;
@ -175,7 +201,7 @@ void GamePadConfDialog_t::changeButton(int padNo, int x)
g_config->setOption (prefix + "DeviceNum",
GamePadConfig[padNo][x].DeviceNum[configNo]);
keyNameStr = ButtonName( &GamePadConfig[padNo][x], padNo );
keyNameStr = ButtonName( &GamePadConfig[padNo][x], configNo );
keyName[x]->setText( keyNameStr );
button[x]->setText("Change");

View File

@ -40,12 +40,15 @@ class GamePadConfDialog_t : public QDialog
GamePadConfigButton_t *button[10];
int portNum;
int configNo;
int buttonConfigStatus;
void changeButton( int port, int button );
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *bar);
private:
void updateCntrlrDpy(void);
public slots:
void closeWindow(void);
@ -62,5 +65,6 @@ class GamePadConfDialog_t : public QDialog
void changeButton9(void);
void ena4score(int state);
void oppDirEna(int state);
void controllerSelect(int index);
};

View File

@ -1566,6 +1566,8 @@ const char * ButtonName (const ButtConfig * bc, int which)
{
static char name[256];
name[0] = 0;
switch (bc->ButtType[which])
{
case BUTTC_KEYBOARD:
@ -1649,6 +1651,13 @@ int DWaitButton (const uint8 * text, ButtConfig * bc, int wb, int *buttonConfigS
}
}
// Purge all pending events, so that this next button press
// will be the one we want.
while (SDL_PollEvent (&event))
{
}
while (1)
{
int done = 0;
@ -1662,10 +1671,7 @@ int DWaitButton (const uint8 * text, ButtConfig * bc, int wb, int *buttonConfigS
}
QCoreApplication::processEvents();
//#ifdef _GTK
// while (gtk_events_pending ())
// gtk_main_iteration_do (FALSE);
//#endif
while (SDL_PollEvent (&event))
{
done++;