Added code to allow for deletion of game pad profiles.
This commit is contained in:
parent
b71630379a
commit
8afeb43759
|
@ -201,9 +201,10 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
|
|||
connect(clearButton[8], SIGNAL(clicked()), this, SLOT(clearButton8(void)) );
|
||||
connect(clearButton[9], SIGNAL(clicked()), this, SLOT(clearButton9(void)) );
|
||||
|
||||
connect(newProfileButton , SIGNAL(clicked()), this, SLOT(newProfileCallback(void)) );
|
||||
connect(applyProfileButton, SIGNAL(clicked()), this, SLOT(loadProfileCallback(void)) );
|
||||
connect(saveProfileButton , SIGNAL(clicked()), this, SLOT(saveProfileCallback(void)) );
|
||||
connect(newProfileButton , SIGNAL(clicked()), this, SLOT(newProfileCallback(void)) );
|
||||
connect(applyProfileButton , SIGNAL(clicked()), this, SLOT(loadProfileCallback(void)) );
|
||||
connect(saveProfileButton , SIGNAL(clicked()), this, SLOT(saveProfileCallback(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)) );
|
||||
|
@ -301,6 +302,9 @@ void GamePadConfDialog_t::loadMapList(void)
|
|||
fileName.erase( suffixIdx );
|
||||
|
||||
//printf("File: %s \n", fileName.c_str() );
|
||||
//
|
||||
|
||||
if ( fileName.compare("default") == 0 ) continue;
|
||||
|
||||
mapSel->addItem( tr(fileName.c_str()), (int)i+1 );
|
||||
}
|
||||
|
@ -692,6 +696,29 @@ void GamePadConfDialog_t::saveProfileCallback(void)
|
|||
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void GamePadConfDialog_t::deleteProfileCallback(void)
|
||||
{
|
||||
int ret;
|
||||
std::string mapName;
|
||||
char stmp[256];
|
||||
|
||||
mapName = mapSel->currentText().toStdString();
|
||||
|
||||
ret = GamePad[portNum].deleteMapping( mapName.c_str() );
|
||||
|
||||
if ( ret == 0 )
|
||||
{
|
||||
sprintf( stmp, "Mapping Deleted: %s/%s \n", GamePad[portNum].getGUID(), mapName.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( stmp, "Error: Failed to Delete Mapping: %s \n", mapName.c_str() );
|
||||
}
|
||||
mapMsg->setText( tr(stmp) );
|
||||
|
||||
loadMapList();
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void GamePadConfDialog_t::updatePeriodic(void)
|
||||
{
|
||||
for (int i=0; i<GAMEPAD_NUM_BUTTONS; i++)
|
||||
|
|
|
@ -94,6 +94,7 @@ class GamePadConfDialog_t : public QDialog
|
|||
void newProfileCallback(void);
|
||||
void loadProfileCallback(void);
|
||||
void saveProfileCallback(void);
|
||||
void deleteProfileCallback(void);
|
||||
void updatePeriodic(void);
|
||||
|
||||
};
|
||||
|
|
|
@ -250,6 +250,7 @@ GamePad_t::GamePad_t(void)
|
|||
bmap[i].ButtType = BUTTC_KEYBOARD;
|
||||
bmap[i].DeviceNum = -1;
|
||||
bmap[i].ButtonNum = -1;
|
||||
bmap[i].state = 0;
|
||||
}
|
||||
}
|
||||
//********************************************************************************
|
||||
|
@ -661,6 +662,38 @@ int GamePad_t::createProfile( const char *name )
|
|||
return 0;
|
||||
}
|
||||
//********************************************************************************
|
||||
int GamePad_t::deleteMapping( const char *name )
|
||||
{
|
||||
const char *guid = NULL;
|
||||
const char *baseDir = FCEUI_GetBaseDirectory();
|
||||
std::string path;
|
||||
|
||||
if ( baseDir[0] == 0 )
|
||||
{
|
||||
printf("Error: Invalid base directory\n");
|
||||
return -1;
|
||||
}
|
||||
if ( devIdx >= 0 )
|
||||
{
|
||||
if ( !jsDev[devIdx].isConnected() )
|
||||
{
|
||||
printf("Error: JS%i Not Connected\n", devIdx );
|
||||
return -1;
|
||||
}
|
||||
guid = jsDev[devIdx].getGUID();
|
||||
}
|
||||
else
|
||||
{
|
||||
guid = "keyboard";
|
||||
}
|
||||
path = std::string(baseDir) + "/input/" + std::string(guid) +
|
||||
"/" + std::string(name) + ".txt";
|
||||
|
||||
//printf("File: '%s'\n", path.c_str() );
|
||||
|
||||
return remove( path.c_str() );
|
||||
}
|
||||
//********************************************************************************
|
||||
jsDev_t *getJoystickDevice( int devNum )
|
||||
{
|
||||
if ( (devNum >= 0) && (devNum < MAX_JOYSTICKS) )
|
||||
|
@ -803,7 +836,7 @@ int AddJoystick( int which )
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("Added Joystick: %i \n", which );
|
||||
//printf("Added Joystick: %i \n", which );
|
||||
jsDev[which].init(which);
|
||||
//jsDev[which].print();
|
||||
//printJoystick( s_Joysticks[which] );
|
||||
|
@ -820,7 +853,7 @@ int AddJoystick( int which )
|
|||
}
|
||||
else
|
||||
{
|
||||
printf("Added Joystick: %i \n", which );
|
||||
//printf("Added Joystick: %i \n", which );
|
||||
jsDev[which].init(which);
|
||||
//jsDev[which].print();
|
||||
//printJoystick( s_Joysticks[which] );
|
||||
|
|
|
@ -74,6 +74,7 @@ class GamePad_t
|
|||
int getDefaultMap( char *out, const char *guid = NULL );
|
||||
int saveMappingToFile( const char *filename, const char *txtMap );
|
||||
int saveCurrentMapToFile( const char *filename );
|
||||
int deleteMapping( const char *name );
|
||||
};
|
||||
|
||||
extern GamePad_t GamePad[4];
|
||||
|
|
Loading…
Reference in New Issue