Game pad code cleanup.
This commit is contained in:
parent
da04bbdfc5
commit
3db85cd1d2
|
@ -26,7 +26,6 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
|
||||||
QPushButton *saveProfileButton;
|
QPushButton *saveProfileButton;
|
||||||
QPushButton *applyProfileButton;
|
QPushButton *applyProfileButton;
|
||||||
QPushButton *removeProfileButton;
|
QPushButton *removeProfileButton;
|
||||||
//QPushButton *loadDefaultButton;
|
|
||||||
QPushButton *clearAllButton;
|
QPushButton *clearAllButton;
|
||||||
QPushButton *closebutton;
|
QPushButton *closebutton;
|
||||||
QPushButton *clearButton[GAMEPAD_NUM_BUTTONS];
|
QPushButton *clearButton[GAMEPAD_NUM_BUTTONS];
|
||||||
|
@ -181,11 +180,9 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
|
||||||
}
|
}
|
||||||
updateCntrlrDpy();
|
updateCntrlrDpy();
|
||||||
|
|
||||||
//loadDefaultButton = new QPushButton(tr("Load Defaults"));
|
|
||||||
clearAllButton = new QPushButton(tr("Clear All"));
|
clearAllButton = new QPushButton(tr("Clear All"));
|
||||||
closebutton = new QPushButton(tr("Close"));
|
closebutton = new QPushButton(tr("Close"));
|
||||||
|
|
||||||
//hbox4->addWidget( loadDefaultButton );
|
|
||||||
hbox4->addWidget( clearAllButton );
|
hbox4->addWidget( clearAllButton );
|
||||||
hbox4->addWidget( closebutton );
|
hbox4->addWidget( closebutton );
|
||||||
|
|
||||||
|
@ -216,7 +213,6 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
|
||||||
connect(saveProfileButton , SIGNAL(clicked()), this, SLOT(saveProfileCallback(void)) );
|
connect(saveProfileButton , SIGNAL(clicked()), this, SLOT(saveProfileCallback(void)) );
|
||||||
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(deleteProfileCallback(void)) );
|
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(deleteProfileCallback(void)) );
|
||||||
|
|
||||||
//connect(loadDefaultButton, SIGNAL(clicked()), this, SLOT(loadDefaults(void)) );
|
|
||||||
connect(clearAllButton , SIGNAL(clicked()), this, SLOT(clearAllCallback(void)) );
|
connect(clearAllButton , SIGNAL(clicked()), this, SLOT(clearAllCallback(void)) );
|
||||||
connect(closebutton , SIGNAL(clicked()), this, SLOT(closeWindow(void)) );
|
connect(closebutton , SIGNAL(clicked()), this, SLOT(closeWindow(void)) );
|
||||||
|
|
||||||
|
@ -268,8 +264,11 @@ void GamePadConfDialog_t::loadMapList(void)
|
||||||
const char *baseDir = FCEUI_GetBaseDirectory();
|
const char *baseDir = FCEUI_GetBaseDirectory();
|
||||||
const char *guid;
|
const char *guid;
|
||||||
std::string path;
|
std::string path;
|
||||||
|
std::string prefix, mapName;
|
||||||
int index, devIdx;
|
int index, devIdx;
|
||||||
jsDev_t *js;
|
jsDev_t *js;
|
||||||
|
size_t n=0;
|
||||||
|
char stmp[256];
|
||||||
|
|
||||||
index = devSel->currentIndex();
|
index = devSel->currentIndex();
|
||||||
devIdx = devSel->itemData(index).toInt();
|
devIdx = devSel->itemData(index).toInt();
|
||||||
|
@ -299,8 +298,13 @@ void GamePadConfDialog_t::loadMapList(void)
|
||||||
|
|
||||||
fileList = dir.entryList( filters, QDir::Files, QDir::NoSort );
|
fileList = dir.entryList( filters, QDir::Files, QDir::NoSort );
|
||||||
|
|
||||||
|
sprintf( stmp, "SDL.Input.GamePad.%u.", portNum );
|
||||||
|
prefix = stmp;
|
||||||
|
|
||||||
|
g_config->getOption(prefix + "Profile", &mapName );
|
||||||
|
|
||||||
mapSel->clear();
|
mapSel->clear();
|
||||||
mapSel->addItem( tr("default"), 0 );
|
mapSel->addItem( tr("default"), 0 ); n=1;
|
||||||
|
|
||||||
for (size_t i=0; i < fileList.size(); i++)
|
for (size_t i=0; i < fileList.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +320,13 @@ void GamePadConfDialog_t::loadMapList(void)
|
||||||
|
|
||||||
if ( fileName.compare("default") == 0 ) continue;
|
if ( fileName.compare("default") == 0 ) continue;
|
||||||
|
|
||||||
mapSel->addItem( tr(fileName.c_str()), (int)i+1 );
|
mapSel->addItem( tr(fileName.c_str()), (int)i+1 );
|
||||||
|
|
||||||
|
if ( mapName.compare( fileName ) == 0 )
|
||||||
|
{
|
||||||
|
mapSel->setCurrentIndex(n);
|
||||||
|
}
|
||||||
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
@ -427,19 +437,9 @@ void GamePadConfDialog_t::changeButton(int padNo, int x)
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void GamePadConfDialog_t::clearButton( int padNo, int x )
|
void GamePadConfDialog_t::clearButton( int padNo, int x )
|
||||||
{
|
{
|
||||||
char buf[256];
|
|
||||||
std::string prefix;
|
|
||||||
|
|
||||||
GamePad[padNo].bmap[x].ButtonNum = -1;
|
GamePad[padNo].bmap[x].ButtonNum = -1;
|
||||||
|
|
||||||
keyName[x]->setText("");
|
keyName[x]->setText("");
|
||||||
|
|
||||||
snprintf (buf, sizeof(buf)-1, "SDL.Input.GamePad.%d.", padNo);
|
|
||||||
prefix = buf;
|
|
||||||
|
|
||||||
g_config->setOption (prefix + GamePadNames[x],
|
|
||||||
GamePad[padNo].bmap[x].ButtonNum);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void GamePadConfDialog_t::closeEvent(QCloseEvent *event)
|
void GamePadConfDialog_t::closeEvent(QCloseEvent *event)
|
||||||
|
@ -565,6 +565,20 @@ void GamePadConfDialog_t::clearAllCallback(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void GamePadConfDialog_t::saveConfig(void)
|
||||||
|
{
|
||||||
|
char stmp[256];
|
||||||
|
std::string prefix, mapName;
|
||||||
|
|
||||||
|
sprintf( stmp, "SDL.Input.GamePad.%u.", portNum );
|
||||||
|
prefix = stmp;
|
||||||
|
|
||||||
|
mapName = mapSel->currentText().toStdString();
|
||||||
|
|
||||||
|
g_config->setOption(prefix + "DeviceGUID", GamePad[portNum].getGUID() );
|
||||||
|
g_config->setOption(prefix + "Profile" , mapName.c_str() );
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void GamePadConfDialog_t::createNewProfile( const char *name )
|
void GamePadConfDialog_t::createNewProfile( const char *name )
|
||||||
{
|
{
|
||||||
printf("Creating: %s \n", name );
|
printf("Creating: %s \n", name );
|
||||||
|
@ -615,12 +629,7 @@ void GamePadConfDialog_t::loadProfileCallback(void)
|
||||||
}
|
}
|
||||||
if ( ret == 0 )
|
if ( ret == 0 )
|
||||||
{
|
{
|
||||||
std::string prefix;
|
saveConfig();
|
||||||
sprintf( stmp, "SDL.Input.GamePad.%u.", portNum );
|
|
||||||
prefix = stmp;
|
|
||||||
|
|
||||||
g_config->setOption(prefix + "DeviceGUID", GamePad[portNum].getGUID() );
|
|
||||||
g_config->setOption(prefix + "Profile" , mapName.c_str() );
|
|
||||||
|
|
||||||
sprintf( stmp, "Mapping Loaded: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() );
|
sprintf( stmp, "Mapping Loaded: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() );
|
||||||
}
|
}
|
||||||
|
@ -645,6 +654,8 @@ void GamePadConfDialog_t::saveProfileCallback(void)
|
||||||
|
|
||||||
if ( ret == 0 )
|
if ( ret == 0 )
|
||||||
{
|
{
|
||||||
|
saveConfig();
|
||||||
|
|
||||||
sprintf( stmp, "Mapping Saved: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() );
|
sprintf( stmp, "Mapping Saved: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -59,8 +59,9 @@ class GamePadConfDialog_t : public QDialog
|
||||||
void closeEvent(QCloseEvent *bar);
|
void closeEvent(QCloseEvent *bar);
|
||||||
private:
|
private:
|
||||||
void updateCntrlrDpy(void);
|
void updateCntrlrDpy(void);
|
||||||
void createNewProfile( const char *name );
|
void createNewProfile( const char *name );
|
||||||
void loadMapList(void);
|
void loadMapList(void);
|
||||||
|
void saveConfig(void);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeWindow(void);
|
void closeWindow(void);
|
||||||
|
@ -86,7 +87,6 @@ class GamePadConfDialog_t : public QDialog
|
||||||
void clearButton8(void);
|
void clearButton8(void);
|
||||||
void clearButton9(void);
|
void clearButton9(void);
|
||||||
void clearAllCallback(void);
|
void clearAllCallback(void);
|
||||||
//void loadDefaults(void);
|
|
||||||
void ena4score(int state);
|
void ena4score(int state);
|
||||||
void oppDirEna(int state);
|
void oppDirEna(int state);
|
||||||
void portSelect(int index);
|
void portSelect(int index);
|
||||||
|
|
Loading…
Reference in New Issue