Changed Qt advanced gamepad bindings to be stored separately for each individual gamepad port.
This commit is contained in:
parent
c85cd6cb03
commit
56f1794b57
|
@ -645,7 +645,7 @@ void GamePadConfDialog_t::refreshKeyBindTree( bool reset )
|
|||
|
||||
i=0;
|
||||
|
||||
for (it=gpKeySeqList.begin(); it!=gpKeySeqList.end(); it++)
|
||||
for (it=GamePad[portNum].gpKeySeqList.begin(); it!=GamePad[portNum].gpKeySeqList.end(); it++)
|
||||
{
|
||||
binding = *it;
|
||||
|
||||
|
@ -747,6 +747,8 @@ void GamePadConfDialog_t::portSelect(int index)
|
|||
}
|
||||
|
||||
loadMapList();
|
||||
|
||||
refreshKeyBindTree(true);
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void GamePadConfDialog_t::deviceSelect(int index)
|
||||
|
@ -1199,7 +1201,7 @@ void GamePadConfDialog_t::promptToSave(void)
|
|||
//----------------------------------------------------
|
||||
void GamePadConfDialog_t::newKeyBindingCallback(void)
|
||||
{
|
||||
GamePadFuncConfigDialog *dialog = new GamePadFuncConfigDialog( NULL, this );
|
||||
GamePadFuncConfigDialog *dialog = new GamePadFuncConfigDialog( portNum, NULL, this );
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
|
@ -1222,14 +1224,14 @@ void GamePadConfDialog_t::editKeyBindingCallback(void)
|
|||
row = keyBindTree->indexOfTopLevelItem(item);
|
||||
|
||||
i=0;
|
||||
for (it=gpKeySeqList.begin(); it!=gpKeySeqList.end(); it++)
|
||||
for (it=GamePad[portNum].gpKeySeqList.begin(); it!=GamePad[portNum].gpKeySeqList.end(); it++)
|
||||
{
|
||||
if ( i == row )
|
||||
{
|
||||
k = *it; break;
|
||||
}
|
||||
}
|
||||
GamePadFuncConfigDialog *dialog = new GamePadFuncConfigDialog( k, this );
|
||||
GamePadFuncConfigDialog *dialog = new GamePadFuncConfigDialog( portNum, k, this );
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
|
@ -1252,12 +1254,12 @@ void GamePadConfDialog_t::delKeyBindingCallback(void)
|
|||
row = keyBindTree->indexOfTopLevelItem(item);
|
||||
|
||||
i=0;
|
||||
for (it=gpKeySeqList.begin(); it!=gpKeySeqList.end(); it++)
|
||||
for (it=GamePad[portNum].gpKeySeqList.begin(); it!=GamePad[portNum].gpKeySeqList.end(); it++)
|
||||
{
|
||||
if ( i == row )
|
||||
{
|
||||
k = *it;
|
||||
gpKeySeqList.erase(it);
|
||||
GamePad[portNum].gpKeySeqList.erase(it);
|
||||
delete k;
|
||||
break;
|
||||
}
|
||||
|
@ -1725,7 +1727,7 @@ void GamePadView_t::paintEvent(QPaintEvent *event)
|
|||
//----------------------------------------------------
|
||||
// Game Pad Function Config
|
||||
//----------------------------------------------------
|
||||
GamePadFuncConfigDialog::GamePadFuncConfigDialog( gamepad_function_key_t *fk, QWidget *parent )
|
||||
GamePadFuncConfigDialog::GamePadFuncConfigDialog( int portNumIn, gamepad_function_key_t *fk, QWidget *parent )
|
||||
: QDialog(parent)
|
||||
{
|
||||
QHBoxLayout *hbox;
|
||||
|
@ -1737,6 +1739,8 @@ GamePadFuncConfigDialog::GamePadFuncConfigDialog( gamepad_function_key_t *fk, QW
|
|||
QPushButton *clearButton[4];
|
||||
const char *keyNameStr;
|
||||
|
||||
portNum = portNumIn;
|
||||
|
||||
if ( fk == NULL )
|
||||
{
|
||||
editMode = false;
|
||||
|
@ -1877,7 +1881,7 @@ GamePadFuncConfigDialog::~GamePadFuncConfigDialog(void)
|
|||
{
|
||||
if ( !editMode )
|
||||
{
|
||||
gpKeySeqList.push_back( k );
|
||||
GamePad[portNum].gpKeySeqList.push_back( k );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -83,7 +83,7 @@ class GamePadFuncConfigDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GamePadFuncConfigDialog( gamepad_function_key_t *fk, QWidget *parent = 0);
|
||||
GamePadFuncConfigDialog( int portNum, gamepad_function_key_t *fk, QWidget *parent = 0);
|
||||
~GamePadFuncConfigDialog(void);
|
||||
|
||||
protected:
|
||||
|
@ -98,6 +98,7 @@ protected:
|
|||
GamePadConfigHotKey_t *hk[2];
|
||||
gamepad_function_key_t *k;
|
||||
|
||||
int portNum;
|
||||
int buttonConfigStatus;
|
||||
bool editMode;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static int buttonConfigInProgress = 0;
|
|||
extern int gametype;
|
||||
static int DTestButton(ButtConfig *bc);
|
||||
|
||||
std::list<gamepad_function_key_t *> gpKeySeqList;
|
||||
//std::list<gamepad_function_key_t *> gpKeySeqList;
|
||||
|
||||
/**
|
||||
* Necessary for proper GUI functioning (configuring when a game isn't loaded).
|
||||
|
@ -463,6 +463,8 @@ gamepad_function_key_t::gamepad_function_key_t(void)
|
|||
}
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
bmap[i].ButtType = -1;
|
||||
bmap[i].DeviceNum = -1;
|
||||
bmap[i].ButtonNum = -1;
|
||||
bmap[i].state = 0;
|
||||
}
|
||||
|
@ -1537,15 +1539,18 @@ static void updateGamePadKeyMappings(void)
|
|||
{
|
||||
std::list<gamepad_function_key_t *>::iterator it;
|
||||
|
||||
if (gpKeySeqList.size() == 0)
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
return;
|
||||
if (GamePad[i].gpKeySeqList.size() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (it = gpKeySeqList.begin(); it != gpKeySeqList.end(); it++)
|
||||
for (it = GamePad[i].gpKeySeqList.begin(); it != GamePad[i].gpKeySeqList.end(); it++)
|
||||
{
|
||||
(*it)->updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -112,7 +112,7 @@ struct gamepad_function_key_t
|
|||
void updateStatus(void);
|
||||
};
|
||||
|
||||
extern std::list <gamepad_function_key_t*> gpKeySeqList;
|
||||
//extern std::list <gamepad_function_key_t*> gpKeySeqList;
|
||||
|
||||
#define FCFGD_GAMEPAD 1
|
||||
#define FCFGD_POWERPAD 2
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QDir>
|
||||
#include "Qt/sdl.h"
|
||||
#include "Qt/sdl-joystick.h"
|
||||
#include "Qt/config.h"
|
||||
|
||||
#include <cstdlib>
|
||||
//#include <unistd.h>
|
||||
|
@ -727,10 +728,11 @@ int GamePad_t::loadProfile(const char *name, const char *guid)
|
|||
int GamePad_t::saveCurrentMapToFile(const char *name)
|
||||
{
|
||||
int i;
|
||||
char stmp[64];
|
||||
char stmp[256];
|
||||
const char *guid = NULL;
|
||||
const char *baseDir = FCEUI_GetBaseDirectory();
|
||||
std::string path, output;
|
||||
std::list <gamepad_function_key_t*>::iterator it;
|
||||
QDir dir;
|
||||
|
||||
if (devIdx >= 0)
|
||||
|
@ -789,6 +791,77 @@ int GamePad_t::saveCurrentMapToFile(const char *name)
|
|||
output.append(",");
|
||||
}
|
||||
|
||||
for (it=gpKeySeqList.begin(); it!=gpKeySeqList.end(); it++)
|
||||
{
|
||||
gamepad_function_key_t *fk = *it;
|
||||
|
||||
printf("hk[0]=%i hk[1]=%i keySeq[0]=%s keySeq[1]=%s bmap[0].buttType=%i bmap[1].buttType=%i\n",
|
||||
fk->hk[0], fk->hk[1], fk->keySeq[0].name.c_str(), fk->keySeq[1].name.c_str(),
|
||||
fk->bmap[0].ButtType, fk->bmap[1].ButtType );
|
||||
|
||||
if ( fk->bmap[1].ButtType >= 0 )
|
||||
{
|
||||
output.append("\nhotkey,");
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if ( fk->bmap[i].ButtType >= 0 )
|
||||
{
|
||||
if (fk->bmap[i].ButtType == BUTTC_KEYBOARD)
|
||||
{
|
||||
sprintf(stmp, "k%s", SDL_GetKeyName(fk->bmap[i].ButtonNum));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fk->bmap[i].ButtonNum & 0x2000)
|
||||
{
|
||||
/* Hat "button" */
|
||||
sprintf(stmp, "h%i.%i",
|
||||
(fk->bmap[i].ButtonNum >> 8) & 0x1F, fk->bmap[i].ButtonNum & 0xFF);
|
||||
}
|
||||
else if (fk->bmap[i].ButtonNum & 0x8000)
|
||||
{
|
||||
/* Axis "button" */
|
||||
sprintf(stmp, "%ca%i",
|
||||
(fk->bmap[i].ButtonNum & 0x4000) ? '-' : '+', fk->bmap[i].ButtonNum & 0x3FFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Button */
|
||||
sprintf(stmp, "b%i", fk->bmap[i].ButtonNum);
|
||||
}
|
||||
}
|
||||
if ( i == 0 )
|
||||
{
|
||||
output.append("modifier:");
|
||||
output.append(stmp);
|
||||
output.append(",");
|
||||
}
|
||||
else
|
||||
{
|
||||
output.append("button:");
|
||||
output.append(stmp);
|
||||
output.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
const char *nameStr, *keySeqStr;
|
||||
|
||||
if ( fk->hk[i] >= 0 )
|
||||
{
|
||||
getHotKeyConfig( fk->hk[i], &nameStr, &keySeqStr );
|
||||
|
||||
output.append( i ? "release" : "press");
|
||||
output.append(":");
|
||||
output.append(nameStr);
|
||||
output.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return saveMappingToFile(path.c_str(), output.c_str());
|
||||
}
|
||||
//********************************************************************************
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
int saveCurrentMapToFile(const char *filename);
|
||||
int deleteMapping(const char *name);
|
||||
|
||||
std::list <gamepad_function_key_t*> gpKeySeqList;
|
||||
private:
|
||||
int devIdx;
|
||||
int portNum;
|
||||
|
|
Loading…
Reference in New Issue