Merge pull request #245 from mjbudd77/master
For Qt GUI, added an input config window
This commit is contained in:
commit
521846cf97
|
@ -25,6 +25,10 @@ echo '****************************************'
|
|||
echo '*** Installing Package Dependencies ***'
|
||||
echo '****************************************'
|
||||
echo '****************************************'
|
||||
echo '****************************************'
|
||||
echo 'Install Dependency Updates'
|
||||
echo '****************************************'
|
||||
sudo apt-get --assume-yes update
|
||||
# Install Lua-5.1 development package
|
||||
echo '****************************************'
|
||||
echo 'Install Dependency lua5.1-dev'
|
||||
|
|
|
@ -427,6 +427,7 @@ set(SRC_DRIVERS_SDL
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleWindow.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleViewerGL.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleViewerSDL.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/InputConf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/GamePadConf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/HotKeyConf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/PaletteConf.cpp
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "Qt/dface.h"
|
||||
#include "Qt/input.h"
|
||||
#include "Qt/ConsoleWindow.h"
|
||||
#include "Qt/InputConf.h"
|
||||
#include "Qt/GamePadConf.h"
|
||||
#include "Qt/HotKeyConf.h"
|
||||
#include "Qt/PaletteConf.h"
|
||||
|
@ -347,6 +348,14 @@ void consoleWin_t::createMainMenu(void)
|
|||
// Options
|
||||
optMenu = menuBar()->addMenu(tr("Options"));
|
||||
|
||||
// Options -> Input Config
|
||||
gamePadConfig = new QAction(tr("Input Config"), this);
|
||||
//gamePadConfig->setShortcut( QKeySequence(tr("Ctrl+C")));
|
||||
gamePadConfig->setStatusTip(tr("Input Configure"));
|
||||
connect(gamePadConfig, SIGNAL(triggered()), this, SLOT(openInputConfWin(void)) );
|
||||
|
||||
optMenu->addAction(gamePadConfig);
|
||||
|
||||
// Options -> GamePad Config
|
||||
gamePadConfig = new QAction(tr("GamePad Config"), this);
|
||||
//gamePadConfig->setShortcut( QKeySequence(tr("Ctrl+C")));
|
||||
|
@ -1174,6 +1183,13 @@ void consoleWin_t::loadLua(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void consoleWin_t::openInputConfWin(void)
|
||||
{
|
||||
//printf("Open Input Config Window\n");
|
||||
|
||||
openInputConfWindow(this);
|
||||
}
|
||||
|
||||
void consoleWin_t::openGamePadConfWin(void)
|
||||
{
|
||||
//printf("Open GamePad Config Window\n");
|
||||
|
|
|
@ -130,6 +130,7 @@ class consoleWin_t : public QMainWindow
|
|||
public slots:
|
||||
void openDebugWindow(void);
|
||||
void openHexEditor(void);
|
||||
void openGamePadConfWin(void);
|
||||
private slots:
|
||||
void closeApp(void);
|
||||
void openROMFile(void);
|
||||
|
@ -141,7 +142,7 @@ class consoleWin_t : public QMainWindow
|
|||
void closeROMCB(void);
|
||||
void aboutFCEUX(void);
|
||||
void aboutQt(void);
|
||||
void openGamePadConfWin(void);
|
||||
void openInputConfWin(void);
|
||||
void openGameSndConfWin(void);
|
||||
void openGameVideoConfWin(void);
|
||||
void openHotkeyConfWin(void);
|
||||
|
|
|
@ -70,7 +70,7 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
|
|||
QHBoxLayout *hbox, *hbox1, *hbox2, *hbox3, *hbox4, *hbox5;
|
||||
QVBoxLayout *vbox, *vbox1, *vbox2;
|
||||
QGridLayout *grid;
|
||||
QCheckBox *efs_chkbox, *udlr_chkbox;
|
||||
QCheckBox *udlr_chkbox;
|
||||
QGroupBox *frame1, *frame2;
|
||||
QLabel *label;
|
||||
QPushButton *newProfileButton;
|
||||
|
@ -910,6 +910,13 @@ void GamePadConfDialog_t::updatePeriodic(void)
|
|||
keyName[i]->setStyleSheet("color: black;");
|
||||
}
|
||||
}
|
||||
|
||||
int fourScore;
|
||||
g_config->getOption("SDL.FourScore", &fourScore);
|
||||
if ( fourScore != efs_chkbox->isChecked() )
|
||||
{
|
||||
efs_chkbox->setChecked( fourScore );
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
GamePadConfigButton_t::GamePadConfigButton_t(int i)
|
||||
|
|
|
@ -43,6 +43,7 @@ class GamePadConfDialog_t : public QDialog
|
|||
QComboBox *devSel;
|
||||
QComboBox *mapSel;
|
||||
QComboBox *profSel;
|
||||
QCheckBox *efs_chkbox;
|
||||
QLabel *guidLbl;
|
||||
QLabel *mapMsg;
|
||||
QLabel *keyName[GAMEPAD_NUM_BUTTONS];
|
||||
|
|
|
@ -0,0 +1,562 @@
|
|||
// InputConf.cpp
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <QHeaderView>
|
||||
#include <QCloseEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QGroupBox>
|
||||
|
||||
#include "Qt/main.h"
|
||||
#include "Qt/dface.h"
|
||||
#include "Qt/input.h"
|
||||
#include "Qt/config.h"
|
||||
#include "Qt/keyscan.h"
|
||||
#include "Qt/fceuWrapper.h"
|
||||
#include "Qt/ConsoleWindow.h"
|
||||
#include "Qt/ConsoleUtilities.h"
|
||||
#include "Qt/InputConf.h"
|
||||
|
||||
static InputConfDialog_t *win = NULL;
|
||||
//----------------------------------------------------------------------------
|
||||
void openInputConfWindow( QWidget *parent )
|
||||
{
|
||||
if ( win != NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
win = new InputConfDialog_t(parent);
|
||||
|
||||
win->show();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
InputConfDialog_t::InputConfDialog_t(QWidget *parent)
|
||||
: QDialog( parent )
|
||||
{
|
||||
QVBoxLayout *mainLayout, *vbox1, *vbox;
|
||||
QHBoxLayout *hbox;
|
||||
QGroupBox *nesInputFrame, *port1Frame, *port2Frame;
|
||||
QGroupBox *presetFrame, *expansionPortFrame;
|
||||
QPalette pal;
|
||||
QColor color;
|
||||
char stmp[256];
|
||||
int fourscore, autoInputPreset;
|
||||
|
||||
pal = this->palette();
|
||||
|
||||
inputTimer = new QTimer( this );
|
||||
|
||||
connect( inputTimer, &QTimer::timeout, this, &InputConfDialog_t::updatePeriodic );
|
||||
|
||||
setWindowTitle("Input Configuration");
|
||||
|
||||
mainLayout = new QVBoxLayout();
|
||||
|
||||
nesInputFrame = new QGroupBox( tr("NES-Style Input Ports") );
|
||||
vbox1 = new QVBoxLayout();
|
||||
hbox = new QHBoxLayout();
|
||||
fourScoreEna = new QCheckBox( tr("Attach 4-Score (Implies four gamepads)") );
|
||||
port2Mic = new QCheckBox( tr("Replace Port 2 Start with Microphone") );
|
||||
autoPreset = new QCheckBox( tr("Auto Load/Save Presets at ROM Open/Close") );
|
||||
|
||||
g_config->getOption("SDL.FourScore", &fourscore);
|
||||
fourScoreEna->setChecked( fourscore );
|
||||
port2Mic->setChecked( replaceP2StartWithMicrophone );
|
||||
|
||||
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset );
|
||||
autoPreset->setChecked( autoInputPreset );
|
||||
|
||||
hbox->addWidget( fourScoreEna );
|
||||
hbox->addWidget( port2Mic );
|
||||
vbox1->addLayout( hbox );
|
||||
|
||||
hbox = new QHBoxLayout();
|
||||
port1Frame = new QGroupBox( tr("Port 1:") );
|
||||
port2Frame = new QGroupBox( tr("Port 2:") );
|
||||
|
||||
hbox->addWidget( port1Frame );
|
||||
hbox->addWidget( port2Frame );
|
||||
vbox1->addLayout( hbox );
|
||||
|
||||
nesPortComboxBox[0] = new QComboBox();
|
||||
nesPortComboxBox[1] = new QComboBox();
|
||||
expPortComboxBox = new QComboBox();
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
hbox = new QHBoxLayout();
|
||||
|
||||
vbox->addLayout( hbox );
|
||||
hbox->addWidget( nesPortLabel[0] = new QLabel( tr("<None>") ) );
|
||||
hbox->addWidget( nesPortConfButton[0] = new QPushButton( tr("Configure") ) );
|
||||
vbox->addWidget( nesPortComboxBox[0] );
|
||||
|
||||
port1Frame->setLayout( vbox );
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
hbox = new QHBoxLayout();
|
||||
|
||||
vbox->addLayout( hbox );
|
||||
hbox->addWidget( nesPortLabel[1] = new QLabel( tr("<None>") ) );
|
||||
hbox->addWidget( nesPortConfButton[1] = new QPushButton( tr("Configure") ) );
|
||||
vbox->addWidget( nesPortComboxBox[1] );
|
||||
|
||||
port2Frame->setLayout( vbox );
|
||||
|
||||
nesInputFrame->setLayout( vbox1 );
|
||||
nesPortConfButton[0]->setEnabled(false);
|
||||
nesPortConfButton[1]->setEnabled(false);
|
||||
|
||||
mainLayout->addWidget( nesInputFrame );
|
||||
|
||||
hbox = new QHBoxLayout();
|
||||
presetFrame = new QGroupBox( tr("Input Presets:") );
|
||||
expansionPortFrame = new QGroupBox( tr("Famicom Expansion Port:") );
|
||||
|
||||
hbox->addWidget( presetFrame );
|
||||
hbox->addWidget( expansionPortFrame );
|
||||
|
||||
mainLayout->addLayout( hbox );
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
hbox = new QHBoxLayout();
|
||||
vbox->addLayout( hbox );
|
||||
hbox->addWidget( autoPreset );
|
||||
|
||||
hbox = new QHBoxLayout();
|
||||
vbox->addLayout( hbox );
|
||||
hbox->addWidget( loadConfigButton = new QPushButton( tr("Load") ) );
|
||||
hbox->addWidget( saveConfigButton = new QPushButton( tr("Save") ) );
|
||||
|
||||
presetFrame->setLayout( vbox );
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
hbox = new QHBoxLayout();
|
||||
|
||||
vbox->addLayout( hbox );
|
||||
hbox->addWidget( expPortLabel = new QLabel( tr("<None>") ) );
|
||||
hbox->addWidget( expPortConfButton = new QPushButton( tr("Configure") ) );
|
||||
vbox->addWidget( expPortComboxBox );
|
||||
|
||||
expPortConfButton->setEnabled(false);
|
||||
expansionPortFrame->setLayout( vbox );
|
||||
|
||||
color = pal.color(QPalette::WindowText);
|
||||
|
||||
sprintf( stmp, "border: 2px solid #%02X%02X%02X", color.red(), color.green(), color.blue() );
|
||||
|
||||
//printf("%s\n", stmp);
|
||||
nesPortLabel[0]->setAlignment(Qt::AlignCenter);
|
||||
nesPortLabel[1]->setAlignment(Qt::AlignCenter);
|
||||
expPortLabel->setAlignment(Qt::AlignCenter);
|
||||
nesPortLabel[0]->setStyleSheet( stmp );
|
||||
nesPortLabel[1]->setStyleSheet( stmp );
|
||||
expPortLabel->setStyleSheet( stmp );
|
||||
|
||||
setLayout( mainLayout );
|
||||
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
getInputSelection( i, &curNesInput[i], &usrNesInput[i] );
|
||||
nesPortComboxBox[i]->addItem( tr("<None>") , SI_NONE );
|
||||
nesPortComboxBox[i]->addItem( tr("Gamepad") , SI_GAMEPAD );
|
||||
nesPortComboxBox[i]->addItem( tr("Zapper") , SI_ZAPPER );
|
||||
nesPortComboxBox[i]->addItem( tr("Power Pad A") , SI_POWERPADA );
|
||||
nesPortComboxBox[i]->addItem( tr("Power Pad B") , SI_POWERPADB );
|
||||
nesPortComboxBox[i]->addItem( tr("Arkanoid Paddle") , SI_ARKANOID );
|
||||
|
||||
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
|
||||
{
|
||||
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
|
||||
{
|
||||
nesPortComboxBox[i]->setCurrentIndex( j );
|
||||
}
|
||||
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
|
||||
{
|
||||
nesPortLabel[i]->setText( nesPortComboxBox[i]->itemText(j) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getInputSelection( 2, &curNesInput[2], &usrNesInput[2] );
|
||||
expPortComboxBox->addItem( tr("<None>") , SIFC_NONE );
|
||||
expPortComboxBox->addItem( tr("Arkanoid Paddle") , SIFC_ARKANOID );
|
||||
expPortComboxBox->addItem( tr("Shadow") , SIFC_SHADOW );
|
||||
expPortComboxBox->addItem( tr("Hyper Shot Gun") , SIFC_HYPERSHOT );
|
||||
expPortComboxBox->addItem( tr("Family Keyboard") , SIFC_FKB );
|
||||
expPortComboxBox->addItem( tr("Mahjong") , SIFC_MAHJONG );
|
||||
expPortComboxBox->addItem( tr("Quiz King Buzzers"), SIFC_QUIZKING );
|
||||
expPortComboxBox->addItem( tr("Family Trainer A") , SIFC_FTRAINERA );
|
||||
expPortComboxBox->addItem( tr("Family Trainer B") , SIFC_FTRAINERB );
|
||||
expPortComboxBox->addItem( tr("Oeka Kids Tablet") , SIFC_OEKAKIDS );
|
||||
expPortComboxBox->addItem( tr("Top Rider") , SIFC_TOPRIDER );
|
||||
|
||||
for (int j=0; j<expPortComboxBox->count(); j++)
|
||||
{
|
||||
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
|
||||
{
|
||||
expPortComboxBox->setCurrentIndex( j );
|
||||
}
|
||||
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
|
||||
{
|
||||
expPortLabel->setText( expPortComboxBox->itemText(j) );
|
||||
}
|
||||
}
|
||||
|
||||
connect( fourScoreEna, SIGNAL(stateChanged(int)), this, SLOT(fourScoreChanged(int)) );
|
||||
connect( port2Mic , SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int)) );
|
||||
connect( autoPreset , SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int)));
|
||||
|
||||
connect( nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)) );
|
||||
connect( nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)) );
|
||||
connect( expPortComboxBox , SIGNAL(activated(int)), this, SLOT(expSelect(int)) );
|
||||
|
||||
connect( nesPortConfButton[0], SIGNAL(clicked(void)), this, SLOT(port1Configure(void)) );
|
||||
connect( nesPortConfButton[1], SIGNAL(clicked(void)), this, SLOT(port2Configure(void)) );
|
||||
|
||||
connect( loadConfigButton, SIGNAL(clicked(void)), this, SLOT(openLoadPresetFile(void)) );
|
||||
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 )
|
||||
{
|
||||
win = NULL;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
printf("Hot Key Close Window Event\n");
|
||||
done(0);
|
||||
deleteLater();
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::closeWindow(void)
|
||||
{
|
||||
//printf("Close Window\n");
|
||||
done(0);
|
||||
deleteLater();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::setInputs(void)
|
||||
{
|
||||
int idx[3];
|
||||
ESI port[2];
|
||||
ESIFC fcexp;
|
||||
int fourscore = false, microphone = false;
|
||||
|
||||
g_config->getOption("SDL.FourScore", &fourscore);
|
||||
|
||||
microphone = port2Mic->isChecked();
|
||||
|
||||
idx[0] = nesPortComboxBox[0]->currentIndex();
|
||||
idx[1] = nesPortComboxBox[1]->currentIndex();
|
||||
idx[2] = expPortComboxBox->currentIndex();
|
||||
|
||||
port[0] = (ESI)nesPortComboxBox[0]->itemData( idx[0] ).toInt();
|
||||
port[1] = (ESI)nesPortComboxBox[1]->itemData( idx[1] ).toInt();
|
||||
fcexp = (ESIFC)expPortComboxBox->itemData( idx[2] ).toInt();
|
||||
|
||||
FCEUD_SetInput( fourscore, microphone, port[0], port[1], fcexp );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::updatePortLabels(void)
|
||||
{
|
||||
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
getInputSelection( i, &curNesInput[i], &usrNesInput[i] );
|
||||
|
||||
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
|
||||
{
|
||||
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
|
||||
{
|
||||
nesPortLabel[i]->setText( nesPortComboxBox[i]->itemText(j) );
|
||||
}
|
||||
}
|
||||
|
||||
nesPortConfButton[i]->setEnabled( curNesInput[i] == SI_GAMEPAD );
|
||||
}
|
||||
|
||||
getInputSelection( 2, &curNesInput[2], &usrNesInput[2] );
|
||||
|
||||
for (int j=0; j<expPortComboxBox->count(); j++)
|
||||
{
|
||||
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
|
||||
{
|
||||
expPortLabel->setText( expPortComboxBox->itemText(j) );
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::updatePortComboBoxes(void)
|
||||
{
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
getInputSelection( i, &curNesInput[i], &usrNesInput[i] );
|
||||
|
||||
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
|
||||
{
|
||||
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
|
||||
{
|
||||
nesPortComboxBox[i]->setCurrentIndex( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getInputSelection( 2, &curNesInput[2], &usrNesInput[2] );
|
||||
|
||||
for (int j=0; j<expPortComboxBox->count(); j++)
|
||||
{
|
||||
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
|
||||
{
|
||||
expPortComboxBox->setCurrentIndex( j );
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::port1Select(int index)
|
||||
{
|
||||
//printf("Port 1 Number:%i \n", index);
|
||||
setInputs();
|
||||
updatePortLabels();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::port2Select(int index)
|
||||
{
|
||||
//printf("Port 2 Number:%i \n", index);
|
||||
setInputs();
|
||||
updatePortLabels();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::expSelect(int index)
|
||||
{
|
||||
//printf("Expansion Port Number:%i \n", index);
|
||||
setInputs();
|
||||
updatePortLabels();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::fourScoreChanged(int state)
|
||||
{
|
||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||
printf("Set 'SDL.FourScore' = %i\n", value);
|
||||
g_config->setOption("SDL.FourScore", value);
|
||||
|
||||
setInputs();
|
||||
updatePortLabels();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::port2MicChanged(int state)
|
||||
{
|
||||
setInputs();
|
||||
updatePortLabels();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::autoPresetChanged(int state)
|
||||
{
|
||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||
//printf("Set 'SDL.AutoInputPreset' = %i\n", value);
|
||||
g_config->setOption("SDL.AutoInputPreset", value);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::openPortConfig(int portNum)
|
||||
{
|
||||
updatePortLabels();
|
||||
|
||||
switch ( curNesInput[portNum] )
|
||||
{
|
||||
default:
|
||||
case SI_NONE:
|
||||
case SI_ZAPPER:
|
||||
// Do Nothing
|
||||
break;
|
||||
case SI_GAMEPAD:
|
||||
consoleWindow->openGamePadConfWin();
|
||||
break;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::port1Configure(void)
|
||||
{
|
||||
openPortConfig(0);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::port2Configure(void)
|
||||
{
|
||||
openPortConfig(1);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::openLoadPresetFile(void)
|
||||
{
|
||||
int ret, useNativeFileDialogVal;
|
||||
QString filename;
|
||||
std::string last;
|
||||
std::string path;
|
||||
const char *baseDir;
|
||||
QFileDialog dialog(this, tr("Load Preset From File") );
|
||||
QDir dir;
|
||||
|
||||
baseDir = FCEUI_GetBaseDirectory();
|
||||
|
||||
path = std::string(baseDir) + "/input/presets/";
|
||||
|
||||
dir.mkpath( QString::fromStdString(path) );
|
||||
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
dialog.setNameFilter(tr("Preset File (*.pre *.PRE) ;; All files (*)"));
|
||||
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
|
||||
dialog.setLabelText( QFileDialog::Accept, tr("Load") );
|
||||
|
||||
dialog.setDirectory( tr(path.c_str()) );
|
||||
|
||||
// Check config option to use native file dialog or not
|
||||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
QStringList fileList;
|
||||
fileList = dialog.selectedFiles();
|
||||
|
||||
if ( fileList.size() > 0 )
|
||||
{
|
||||
filename = fileList[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( filename.isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
qDebug() << "selected file path : " << filename.toUtf8();
|
||||
|
||||
fceuWrapperLock();
|
||||
loadInputSettingsFromFile( filename.toStdString().c_str() );
|
||||
fceuWrapperUnLock();
|
||||
|
||||
updatePortLabels();
|
||||
updatePortComboBoxes();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::openSavePresetFile(void)
|
||||
{
|
||||
int ret, useNativeFileDialogVal;
|
||||
QString filename;
|
||||
std::string path;
|
||||
const char *baseDir, *romFile;
|
||||
QFileDialog dialog(this, tr("Save Preset to File") );
|
||||
QDir dir;
|
||||
|
||||
baseDir = FCEUI_GetBaseDirectory();
|
||||
|
||||
path = std::string(baseDir) + "/input/presets/";
|
||||
|
||||
dir.mkpath( QString::fromStdString(path) );
|
||||
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
dialog.setNameFilter(tr("Preset Files (*.pre *.PRE) ;; All files (*)"));
|
||||
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
dialog.setFilter( QDir::AllEntries | QDir::AllDirs | QDir::Hidden );
|
||||
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
|
||||
dialog.setDefaultSuffix( tr(".pre") );
|
||||
|
||||
romFile = getRomFile();
|
||||
|
||||
if ( romFile != NULL )
|
||||
{
|
||||
char dirStr[256], base[256];
|
||||
|
||||
parseFilepath( romFile, dirStr, base );
|
||||
|
||||
strcat( base, ".pre");
|
||||
|
||||
dialog.selectFile( tr(base) );
|
||||
}
|
||||
|
||||
dialog.setDirectory( tr(path.c_str()) );
|
||||
|
||||
// Check config option to use native file dialog or not
|
||||
g_config->getOption ("SDL.UseNativeFileDialog", &useNativeFileDialogVal);
|
||||
|
||||
dialog.setOption(QFileDialog::DontUseNativeDialog, !useNativeFileDialogVal);
|
||||
|
||||
dialog.show();
|
||||
ret = dialog.exec();
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
QStringList fileList;
|
||||
fileList = dialog.selectedFiles();
|
||||
|
||||
if ( fileList.size() > 0 )
|
||||
{
|
||||
filename = fileList[0];
|
||||
}
|
||||
}
|
||||
|
||||
if ( filename.isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
qDebug() << "selected file path : " << filename.toUtf8();
|
||||
|
||||
saveInputSettingsToFile( filename.toStdString().c_str() );
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::updatePeriodic(void)
|
||||
{
|
||||
bool updateNeeded = false;
|
||||
int tmpCurInputType[3], tmpUsrInputType[3];
|
||||
int fourScoreValue;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
g_config->getOption("SDL.FourScore", &fourScoreValue);
|
||||
|
||||
if ( fourScoreValue != fourScoreEna->isChecked() )
|
||||
{
|
||||
fourScoreEna->setChecked( fourScoreValue );
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
|
@ -0,0 +1,73 @@
|
|||
// InputConf.h
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
#include <QTreeView>
|
||||
#include <QTreeWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include "Qt/main.h"
|
||||
|
||||
class InputConfDialog_t : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputConfDialog_t(QWidget *parent = 0);
|
||||
~InputConfDialog_t(void);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
QTimer *inputTimer;
|
||||
QCheckBox *fourScoreEna;
|
||||
QCheckBox *port2Mic;
|
||||
QCheckBox *autoPreset;
|
||||
QLabel *nesPortLabel[2];
|
||||
QPushButton *nesPortConfButton[2];
|
||||
QComboBox *nesPortComboxBox[2];
|
||||
QLabel *expPortLabel;
|
||||
QPushButton *expPortConfButton;
|
||||
QComboBox *expPortComboxBox;
|
||||
QPushButton *loadConfigButton;
|
||||
QPushButton *saveConfigButton;
|
||||
|
||||
int curNesInput[3];
|
||||
int usrNesInput[3];
|
||||
|
||||
private:
|
||||
void setInputs(void);
|
||||
void updatePortLabels(void);
|
||||
void updatePortComboBoxes(void);
|
||||
void openPortConfig(int portNum);
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
private slots:
|
||||
void port1Configure(void);
|
||||
void port2Configure(void);
|
||||
void port1Select(int index);
|
||||
void port2Select(int index);
|
||||
void expSelect(int index);
|
||||
void fourScoreChanged(int state);
|
||||
void port2MicChanged(int state);
|
||||
void autoPresetChanged(int state);
|
||||
void openLoadPresetFile(void);
|
||||
void openSavePresetFile(void);
|
||||
void updatePeriodic(void);
|
||||
|
||||
};
|
||||
|
||||
void openInputConfWindow( QWidget *parent );
|
|
@ -1147,7 +1147,7 @@ void RamWatchDialog_t::saveWatchFile (const char *filename, int append )
|
|||
void RamWatchDialog_t::loadWatchFile (const char *filename, int append )
|
||||
{
|
||||
FILE *fp;
|
||||
int i, j, a, t, s, isSep, literal;
|
||||
int i, j, a, t, s, isSep, literal=0;
|
||||
char line[512], stmp[512];
|
||||
ramWatch_t *rw;
|
||||
|
||||
|
|
|
@ -241,6 +241,8 @@ InitConfig()
|
|||
config->addOption("input3", "SDL.Input.2", "Gamepad.2");
|
||||
config->addOption("input4", "SDL.Input.3", "Gamepad.3");
|
||||
|
||||
config->addOption("autoInputPreset", "SDL.AutoInputPreset", 0);
|
||||
|
||||
// allow for input configuration
|
||||
//config->addOption('i', "inputcfg", "SDL.InputCfg", InputCfg);
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ int reloadLastGame(void)
|
|||
*/
|
||||
int LoadGame(const char *path, bool silent)
|
||||
{
|
||||
int gg_enabled, autoLoadDebug, autoOpenDebugger;
|
||||
int gg_enabled, autoLoadDebug, autoOpenDebugger, autoInputPreset;
|
||||
|
||||
if (isloaded){
|
||||
CloseGame();
|
||||
|
@ -267,12 +267,19 @@ int LoadGame(const char *path, bool silent)
|
|||
|
||||
CDLoggerROMChanged();
|
||||
|
||||
int state_to_load;
|
||||
g_config->getOption("SDL.AutoLoadState", &state_to_load);
|
||||
if (state_to_load >= 0 && state_to_load < 10){
|
||||
FCEUI_SelectState(state_to_load, 0);
|
||||
FCEUI_LoadState(NULL, false);
|
||||
}
|
||||
int state_to_load;
|
||||
g_config->getOption("SDL.AutoLoadState", &state_to_load);
|
||||
if (state_to_load >= 0 && state_to_load < 10){
|
||||
FCEUI_SelectState(state_to_load, 0);
|
||||
FCEUI_LoadState(NULL, false);
|
||||
}
|
||||
|
||||
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset );
|
||||
|
||||
if ( autoInputPreset )
|
||||
{
|
||||
loadInputSettingsFromFile();
|
||||
}
|
||||
|
||||
ParseGIInput(GameInfo);
|
||||
RefreshThrottleFPS();
|
||||
|
@ -321,12 +328,21 @@ CloseGame(void)
|
|||
debugSymbolTable.clear();
|
||||
CDLoggerROMClosed();
|
||||
|
||||
int state_to_save;
|
||||
g_config->getOption("SDL.AutoSaveState", &state_to_save);
|
||||
if (state_to_save < 10 && state_to_save >= 0){
|
||||
FCEUI_SelectState(state_to_save, 0);
|
||||
FCEUI_SaveState(NULL, false);
|
||||
}
|
||||
int state_to_save;
|
||||
g_config->getOption("SDL.AutoSaveState", &state_to_save);
|
||||
if (state_to_save < 10 && state_to_save >= 0){
|
||||
FCEUI_SelectState(state_to_save, 0);
|
||||
FCEUI_SaveState(NULL, false);
|
||||
}
|
||||
|
||||
int autoInputPreset;
|
||||
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset );
|
||||
|
||||
if ( autoInputPreset )
|
||||
{
|
||||
saveInputSettingsToFile();
|
||||
}
|
||||
|
||||
FCEUI_CloseGame();
|
||||
|
||||
DriverKill();
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "Qt/input.h"
|
||||
#include "Qt/config.h"
|
||||
#include "Qt/ConsoleWindow.h"
|
||||
|
||||
#include "Qt/ConsoleUtilities.h"
|
||||
|
||||
#include "Qt/sdl.h"
|
||||
#include "Qt/sdl-video.h"
|
||||
|
@ -98,6 +98,22 @@ ParseGIInput (FCEUGI * gi)
|
|||
cspec = gi->cspecial;
|
||||
}
|
||||
|
||||
int getInputSelection( int port, int *cur, int *usr )
|
||||
{
|
||||
if ( (port >= 0) && (port < 3) )
|
||||
{
|
||||
if ( cur )
|
||||
{
|
||||
*cur = CurInputType[port];
|
||||
}
|
||||
if ( usr )
|
||||
{
|
||||
*usr = UsrInputType[port];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static uint8 QuizKingData = 0;
|
||||
static uint8 HyperShotData = 0;
|
||||
|
@ -1973,214 +1989,360 @@ int DWaitButton (const uint8_t * text, ButtConfig * bc, int *buttonConfigStatus
|
|||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes in button inputs until either it sees two of
|
||||
* the same button presses in a row or gets four inputs and then saves
|
||||
* the total number of button presses. Each of the keys pressed is
|
||||
* used as input for the specified button, thus allowing up to four
|
||||
* possible settings for each input button.
|
||||
*/
|
||||
// void
|
||||
//ConfigButton (char *text, ButtConfig * bc)
|
||||
//{
|
||||
// uint8 buf[256];
|
||||
// int wc;
|
||||
//
|
||||
// for (wc = 0; wc < MAXBUTTCONFIG; wc++)
|
||||
// {
|
||||
// sprintf ((char *) buf, "%s (%d)", text, wc + 1);
|
||||
// DWaitButton (buf, bc, wc, NULL);
|
||||
//
|
||||
// if (wc &&
|
||||
// bc->ButtType[wc] == bc->ButtType[wc - 1] &&
|
||||
// bc->DeviceNum[wc] == bc->DeviceNum[wc - 1] &&
|
||||
// bc->ButtonNum[wc] == bc->ButtonNum[wc - 1])
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* Update the button configuration for a specified device.
|
||||
*/
|
||||
extern Config *g_config;
|
||||
|
||||
//void ConfigDevice (int which, int arg)
|
||||
//{
|
||||
// char buf[256];
|
||||
// int x;
|
||||
// std::string prefix;
|
||||
// const char *str[10] =
|
||||
// { "A", "B", "SELECT", "START", "UP", "DOWN", "LEFT", "RIGHT", "Rapid A",
|
||||
// "Rapid B"
|
||||
// };
|
||||
//
|
||||
// // XXX soules - set the configuration options so that later calls
|
||||
// // don't override these. This is a temp hack until I
|
||||
// // can clean up this file.
|
||||
//
|
||||
// ButtonConfigBegin ();
|
||||
// switch (which)
|
||||
// {
|
||||
// case FCFGD_QUIZKING:
|
||||
// prefix = "SDL.Input.QuizKing.";
|
||||
// for (x = 0; x < 6; x++)
|
||||
// {
|
||||
// sprintf (buf, "Quiz King Buzzer #%d", x + 1);
|
||||
// ConfigButton (buf, &QuizKingButtons[x]);
|
||||
//
|
||||
// g_config->setOption (prefix + QuizKingNames[x],
|
||||
// QuizKingButtons[x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (QuizKingButtons[0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (QuizKingButtons[0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// QuizKingButtons[0].DeviceNum);
|
||||
// break;
|
||||
// case FCFGD_HYPERSHOT:
|
||||
// prefix = "SDL.Input.HyperShot.";
|
||||
// for (x = 0; x < 4; x++)
|
||||
// {
|
||||
// sprintf (buf, "Hyper Shot %d: %s",
|
||||
// ((x & 2) >> 1) + 1, (x & 1) ? "JUMP" : "RUN");
|
||||
// ConfigButton (buf, &HyperShotButtons[x]);
|
||||
//
|
||||
// g_config->setOption (prefix + HyperShotNames[x],
|
||||
// HyperShotButtons[x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (HyperShotButtons[0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (HyperShotButtons[0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// HyperShotButtons[0].DeviceNum);
|
||||
// break;
|
||||
// case FCFGD_POWERPAD:
|
||||
// snprintf (buf, 256, "SDL.Input.PowerPad.%d", (arg & 1));
|
||||
// prefix = buf;
|
||||
// for (x = 0; x < 12; x++)
|
||||
// {
|
||||
// sprintf (buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11);
|
||||
// ConfigButton (buf, &powerpadsc[arg & 1][x]);
|
||||
//
|
||||
// g_config->setOption (prefix + PowerPadNames[x],
|
||||
// powerpadsc[arg & 1][x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (powerpadsc[arg & 1][0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (powerpadsc[arg & 1][0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// powerpadsc[arg & 1][0].DeviceNum);
|
||||
// break;
|
||||
//
|
||||
// case FCFGD_GAMEPAD:
|
||||
// snprintf (buf, 256, "SDL.Input.GamePad.%d", arg);
|
||||
// prefix = buf;
|
||||
// for (x = 0; x < 10; x++)
|
||||
// {
|
||||
// sprintf (buf, "GamePad #%d: %s", arg + 1, str[x]);
|
||||
// ConfigButton (buf, &GamePadConfig[arg][x]);
|
||||
//
|
||||
// g_config->setOption (prefix + GamePadNames[x],
|
||||
// GamePadConfig[arg][x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (GamePadConfig[arg][0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (GamePadConfig[arg][0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// GamePadConfig[arg][0].DeviceNum);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// ButtonConfigEnd ();
|
||||
//}
|
||||
static const char *stdPortInputEncode( int v )
|
||||
{
|
||||
const char *s;
|
||||
|
||||
switch ( v )
|
||||
{
|
||||
default:
|
||||
case SI_NONE:
|
||||
s = "SI_NONE";
|
||||
break;
|
||||
case SI_GAMEPAD:
|
||||
s = "SI_GAMEPAD";
|
||||
break;
|
||||
case SI_ZAPPER:
|
||||
s = "SI_ZAPPER";
|
||||
break;
|
||||
case SI_POWERPADA:
|
||||
s = "SI_POWERPADA";
|
||||
break;
|
||||
case SI_POWERPADB:
|
||||
s = "SI_POWERPADB";
|
||||
break;
|
||||
case SI_ARKANOID:
|
||||
s = "SI_ARKANOID";
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the button configuration for a device, specified by a text string.
|
||||
*/
|
||||
//void InputCfg (const std::string & text)
|
||||
//{
|
||||
//
|
||||
// if (noGui)
|
||||
// {
|
||||
// if (text.find ("gamepad") != std::string::npos)
|
||||
// {
|
||||
// int device = (text[strlen ("gamepad")] - '1');
|
||||
// if (device < 0 || device > 3)
|
||||
// {
|
||||
// FCEUD_PrintError
|
||||
// ("Invalid gamepad device specified; must be one of gamepad1 through gamepad4");
|
||||
// exit (-1);
|
||||
// }
|
||||
// ConfigDevice (FCFGD_GAMEPAD, device);
|
||||
// }
|
||||
// else if (text.find ("powerpad") != std::string::npos)
|
||||
// {
|
||||
// int device = (text[strlen ("powerpad")] - '1');
|
||||
// if (device < 0 || device > 1)
|
||||
// {
|
||||
// FCEUD_PrintError
|
||||
// ("Invalid powerpad device specified; must be powerpad1 or powerpad2");
|
||||
// exit (-1);
|
||||
// }
|
||||
// ConfigDevice (FCFGD_POWERPAD, device);
|
||||
// }
|
||||
// else if (text.find ("hypershot") != std::string::npos)
|
||||
// {
|
||||
// ConfigDevice (FCFGD_HYPERSHOT, 0);
|
||||
// }
|
||||
// else if (text.find ("quizking") != std::string::npos)
|
||||
// {
|
||||
// ConfigDevice (FCFGD_QUIZKING, 0);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// printf ("Please run \"fceux --nogui\" before using --inputcfg\n");
|
||||
//
|
||||
//}
|
||||
static int stdPortInputDecode( const char *s )
|
||||
{
|
||||
int ret = SI_NONE;
|
||||
|
||||
if ( s[0] == 0 )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ( isdigit(s[0]) )
|
||||
{
|
||||
ret = atoi(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strcmp( s, "SI_GAMEPAD" ) == 0 )
|
||||
{
|
||||
ret = SI_GAMEPAD;
|
||||
}
|
||||
else if ( strcmp( s, "SI_ZAPPER" ) == 0 )
|
||||
{
|
||||
ret = SI_ZAPPER;
|
||||
}
|
||||
else if ( strcmp( s, "SI_POWERPADA" ) == 0 )
|
||||
{
|
||||
ret = SI_POWERPADA;
|
||||
}
|
||||
else if ( strcmp( s, "SI_POWERPADB" ) == 0 )
|
||||
{
|
||||
ret = SI_POWERPADB;
|
||||
}
|
||||
else if ( strcmp( s, "SI_ARKANOID" ) == 0 )
|
||||
{
|
||||
ret = SI_ARKANOID;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char *expPortInputEncode( int v )
|
||||
{
|
||||
const char *s;
|
||||
|
||||
switch ( v )
|
||||
{
|
||||
default:
|
||||
case SIFC_NONE:
|
||||
s = "SIFC_NONE";
|
||||
break;
|
||||
case SIFC_ARKANOID:
|
||||
s = "SIFC_ARKANOID";
|
||||
break;
|
||||
case SIFC_SHADOW:
|
||||
s = "SIFC_SHADOW";
|
||||
break;
|
||||
case SIFC_HYPERSHOT:
|
||||
s = "SIFC_HYPERSHOT";
|
||||
break;
|
||||
case SIFC_FKB:
|
||||
s = "SIFC_FKB";
|
||||
break;
|
||||
case SIFC_MAHJONG:
|
||||
s = "SIFC_MAHJONG";
|
||||
break;
|
||||
case SIFC_QUIZKING:
|
||||
s = "SIFC_QUIZKING";
|
||||
break;
|
||||
case SIFC_FTRAINERA:
|
||||
s = "SIFC_FTRAINERA";
|
||||
break;
|
||||
case SIFC_FTRAINERB:
|
||||
s = "SIFC_FTRAINERB";
|
||||
break;
|
||||
case SIFC_OEKAKIDS:
|
||||
s = "SIFC_OEKAKIDS";
|
||||
break;
|
||||
case SIFC_TOPRIDER:
|
||||
s = "SIFC_TOPRIDER";
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static int expPortInputDecode( const char *s )
|
||||
{
|
||||
int ret = SIFC_NONE;
|
||||
|
||||
if ( s[0] == 0 )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ( isdigit(s[0]) )
|
||||
{
|
||||
ret = atoi(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strcmp( s, "SIFC_ARKANOID" ) == 0 )
|
||||
{
|
||||
ret = SIFC_ARKANOID;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_SHADOW" ) == 0 )
|
||||
{
|
||||
ret = SIFC_SHADOW;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_HYPERSHOT" ) == 0 )
|
||||
{
|
||||
ret = SIFC_HYPERSHOT;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_FKB" ) == 0 )
|
||||
{
|
||||
ret = SIFC_FKB;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_MAHJONG" ) == 0 )
|
||||
{
|
||||
ret = SIFC_MAHJONG;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_QUIZKING" ) == 0 )
|
||||
{
|
||||
ret = SIFC_QUIZKING;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_FTRAINERA" ) == 0 )
|
||||
{
|
||||
ret = SIFC_FTRAINERA;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_FTRAINERB" ) == 0 )
|
||||
{
|
||||
ret = SIFC_FTRAINERB;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_OEKAKIDS" ) == 0 )
|
||||
{
|
||||
ret = SIFC_OEKAKIDS;
|
||||
}
|
||||
else if ( strcmp( s, "SIFC_TOPRIDER" ) == 0 )
|
||||
{
|
||||
ret = SIFC_TOPRIDER;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool boolDecode( const char *s )
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if ( isdigit(s[0]) )
|
||||
{
|
||||
ret = atoi(s) != 0;
|
||||
}
|
||||
else if ( strcasecmp( s, "true" ) == 0 )
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int saveInputSettingsToFile( const char *filename )
|
||||
{
|
||||
QDir dir;
|
||||
std::string path;
|
||||
const char *baseDir = FCEUI_GetBaseDirectory();
|
||||
char base[256];
|
||||
|
||||
path = std::string(baseDir) + "/input/presets/";
|
||||
|
||||
dir.mkpath( QString::fromStdString(path) );
|
||||
|
||||
if ( filename != NULL )
|
||||
{
|
||||
getFileBaseName( filename, base, NULL );
|
||||
|
||||
path += std::string(base) + ".pre";
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *romFile = getRomFile();
|
||||
|
||||
if ( romFile == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
getFileBaseName( romFile, base, NULL );
|
||||
|
||||
path += std::string(base) + ".pre";
|
||||
}
|
||||
|
||||
FILE *fp = fopen( path.c_str(), "w");
|
||||
|
||||
if ( fp == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
fprintf( fp, "# Input Port Settings\n");
|
||||
fprintf( fp, "InputTypePort1 = %s \n", stdPortInputEncode( CurInputType[0] ) );
|
||||
fprintf( fp, "InputTypePort2 = %s \n", stdPortInputEncode( CurInputType[1] ) );
|
||||
fprintf( fp, "InputTypeExpPort = %s \n", expPortInputEncode( CurInputType[2] ) );
|
||||
fprintf( fp, "Enable4Score = %i \n", (eoptions & EO_FOURSCORE) ? 1 : 0 );
|
||||
fprintf( fp, "EnableMicPort2 = %i \n", replaceP2StartWithMicrophone );
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int loadInputSettingsFromFile( const char *filename )
|
||||
{
|
||||
QDir dir;
|
||||
std::string path;
|
||||
const char *baseDir = FCEUI_GetBaseDirectory();
|
||||
char base[256], line[256];
|
||||
char id[128], val[128];
|
||||
int i, j;
|
||||
|
||||
path = std::string(baseDir) + "/input/presets/";
|
||||
|
||||
dir.mkpath( QString::fromStdString(path) );
|
||||
|
||||
if ( filename != NULL )
|
||||
{
|
||||
getFileBaseName( filename, base, NULL );
|
||||
|
||||
path += std::string(base) + ".pre";
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *romFile = getRomFile();
|
||||
|
||||
if ( romFile == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
getFileBaseName( romFile, base, NULL );
|
||||
|
||||
path += std::string(base) + ".pre";
|
||||
}
|
||||
|
||||
FILE *fp = fopen( path.c_str(), "r");
|
||||
|
||||
if ( fp == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ( fgets( line, sizeof(line)-1, fp ) != 0 )
|
||||
{
|
||||
i=0;
|
||||
while ( line[i] != 0 )
|
||||
{
|
||||
if ( line[i] == '#' )
|
||||
{
|
||||
line[i] = 0; break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
i=0;
|
||||
while ( isspace(line[i]) ) i++;
|
||||
|
||||
j=0;
|
||||
while ( isalnum(line[i]) || (line[i] == '_') )
|
||||
{
|
||||
id[j] = line[i]; i++; j++;
|
||||
}
|
||||
id[j] = 0;
|
||||
|
||||
if ( j == 0 ) continue;
|
||||
|
||||
while ( isspace(line[i]) ) i++;
|
||||
|
||||
if ( line[i] == '=' ) i++;
|
||||
|
||||
while ( isspace(line[i]) ) i++;
|
||||
|
||||
j=0;
|
||||
while ( line[i] && !isspace(line[i]) )
|
||||
{
|
||||
val[j] = line[i]; i++; j++;
|
||||
}
|
||||
val[j] = 0;
|
||||
|
||||
if ( j == 0 )
|
||||
{
|
||||
printf("Warning: No Value Specified for Token ID: '%s'\n", id );
|
||||
continue;
|
||||
}
|
||||
//printf("ID: '%s' Val: '%s' \n", id, val );
|
||||
|
||||
if ( strcmp( id, "InputTypePort1" ) == 0 )
|
||||
{
|
||||
CurInputType[0] = UsrInputType[0] = stdPortInputDecode( val );
|
||||
}
|
||||
else if ( strcmp( id, "InputTypePort2" ) == 0 )
|
||||
{
|
||||
CurInputType[1] = UsrInputType[1] = stdPortInputDecode( val );
|
||||
}
|
||||
else if ( strcmp( id, "InputTypeExpPort" ) == 0 )
|
||||
{
|
||||
CurInputType[2] = UsrInputType[2] = expPortInputDecode( val );
|
||||
}
|
||||
else if ( strcmp( id, "Enable4Score" ) == 0 )
|
||||
{
|
||||
if ( boolDecode( val ) )
|
||||
{
|
||||
eoptions &= ~EO_FOURSCORE;
|
||||
}
|
||||
else
|
||||
{
|
||||
eoptions |= EO_FOURSCORE;
|
||||
}
|
||||
}
|
||||
else if ( strcmp( id, "EnableMicPort2" ) == 0 )
|
||||
{
|
||||
replaceP2StartWithMicrophone = boolDecode( val );
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hack to map the new configuration onto the existing button
|
||||
|
|
|
@ -78,5 +78,10 @@ void UpdateInput(Config *config);
|
|||
|
||||
std::string GetUserText(const char* title);
|
||||
const char* ButtonName(const ButtConfig* bc);
|
||||
|
||||
int getInputSelection( int port, int *cur, int *usr );
|
||||
int saveInputSettingsToFile( const char *fileBase = NULL );
|
||||
int loadInputSettingsFromFile( const char *filename = NULL );
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue