QT gamepad window in work.

This commit is contained in:
Matthew Budd 2020-06-26 12:46:48 -04:00
parent f1153bfc6b
commit ee02883ac7
5 changed files with 119 additions and 1 deletions

View File

@ -292,9 +292,11 @@ SOURCES += src/drivers/common/nes_ntsc.c
HEADERS += src/drivers/Qt/GameApp.h
HEADERS += src/drivers/Qt/GameViewer.h
HEADERS += src/drivers/Qt/GamePadConf.h
SOURCES += src/drivers/Qt/main.cpp
SOURCES += src/drivers/Qt/GameApp.cpp
SOURCES += src/drivers/Qt/GameViewer.cpp
SOURCES += src/drivers/Qt/GamePadConf.cpp
SOURCES += src/drivers/Qt/fceuWrapper.cpp
SOURCES += src/drivers/Qt/config.cpp
SOURCES += src/drivers/Qt/input.cpp

View File

@ -3,6 +3,7 @@
#include <QFileDialog>
#include "GameApp.h"
#include "GamePadConf.h"
#include "fceuWrapper.h"
#include "keyscan.h"
@ -54,9 +55,14 @@ void gameWin_t::keyReleaseEvent(QKeyEvent *event)
void gameWin_t::createMainMenu(void)
{
// This is needed for menu bar to show up on MacOS
menuBar()->setNativeMenuBar(false);
//-----------------------------------------------------------------------
// File
fileMenu = menuBar()->addMenu(tr("&File"));
// File -> Open ROM
openROM = new QAction(tr("&Open ROM"), this);
openROM->setShortcuts(QKeySequence::Open);
openROM->setStatusTip(tr("Open ROM File"));
@ -64,12 +70,37 @@ void gameWin_t::createMainMenu(void)
fileMenu->addAction(openROM);
// File -> Close ROM
closeROM = new QAction(tr("&Close ROM"), this);
closeROM->setShortcut( QKeySequence(tr("Ctrl+C")));
closeROM->setStatusTip(tr("Close Loaded ROM"));
connect(closeROM, SIGNAL(triggered()), this, SLOT(closeROMCB(void)) );
fileMenu->addAction(closeROM);
fileMenu->addSeparator();
// File -> Quit
quitAct = new QAction(tr("&Quit"), this);
quitAct->setStatusTip(tr("Quit the Application"));
connect(quitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
fileMenu->addAction(quitAct);
//-----------------------------------------------------------------------
// Options
optMenu = menuBar()->addMenu(tr("&Options"));
// Options -> GamePad Config
gamePadConfig = new QAction(tr("&GamePad Config"), this);
//gamePadConfig->setShortcut( QKeySequence(tr("Ctrl+C")));
gamePadConfig->setStatusTip(tr("GamePad Configure"));
connect(gamePadConfig, SIGNAL(triggered()), this, SLOT(openGamePadConfWin(void)) );
optMenu->addAction(gamePadConfig);
//-----------------------------------------------------------------------
// Help
helpMenu = menuBar()->addMenu(tr("&Help"));
aboutAct = new QAction(tr("&About"), this);
@ -83,7 +114,7 @@ void gameWin_t::openROMFile(void)
{
int ret;
QString filename;
QFileDialog dialog(this);
QFileDialog dialog(this, "Open ROM File");
dialog.setFileMode(QFileDialog::ExistingFile);
@ -126,6 +157,18 @@ void gameWin_t::openROMFile(void)
return;
}
void gameWin_t::closeROMCB(void)
{
CloseGame();
}
void gameWin_t::openGamePadConfWin(void)
{
printf("Open GamePad Config Window\n");
GamePadConfDialog_t gpConf(this);
}
void gameWin_t::aboutQPlot(void)
{
printf("About QPlot\n");

View File

@ -30,10 +30,13 @@ class gameWin_t : public QMainWindow
//
QMenu *fileMenu;
QMenu *optMenu;
QMenu *helpMenu;
QAction *openROM;
QAction *closeROM;
QAction *quitAct;
QAction *gamePadConfig;
QAction *aboutAct;
QTimer *gameTimer;
@ -47,7 +50,9 @@ class gameWin_t : public QMainWindow
private slots:
void openROMFile(void);
void closeROMCB(void);
void aboutQPlot(void);
void openGamePadConfWin(void);
void runGameFrame(void);
};

View File

@ -0,0 +1,40 @@
// GamePadConf.cpp
//
#include "GamePadConf.h"
//----------------------------------------------------
GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
: QDialog( parent )
{
QHBoxLayout *hbox1, *hbox2;
QCheckBox *efs_chkbox;
hbox1 = new QHBoxLayout();
QLabel *label = new QLabel(tr("Port:"));
portSel = new QComboBox();
hbox1->addWidget( label );
hbox1->addWidget( portSel );
hbox2 = new QHBoxLayout();
efs_chkbox = new QCheckBox("Enable Four Score");
hbox2->addWidget( efs_chkbox );
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addLayout( hbox1 );
mainLayout->addWidget( efs_chkbox );
//mainLayout->addLayout( hbox2 );
setLayout( mainLayout );
show();
exec();
}
//----------------------------------------------------
GamePadConfDialog_t::~GamePadConfDialog_t(void)
{
}
//----------------------------------------------------

View File

@ -0,0 +1,28 @@
// GamePadConf.h
//
#pragma once
#include <QWidget>
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QLabel>
class GamePadConfDialog_t : public QDialog
{
public:
GamePadConfDialog_t(QWidget *parent = 0);
~GamePadConfDialog_t(void);
protected:
QComboBox *portSel;
private slots:
};