Added code to escape keyboard gamepad bindings if the key name interferes with the config file syntax. Fixes save/load of comma key gamepad bindings. For issue #443
This commit is contained in:
parent
94eab8f8ef
commit
97e509b8ef
|
@ -282,6 +282,10 @@ int nesGamePadMap_t::parseMapping(const char *map)
|
||||||
|
|
||||||
while ((map[i] != 0) && (map[i] != ','))
|
while ((map[i] != 0) && (map[i] != ','))
|
||||||
{
|
{
|
||||||
|
if ( map[i] == '\\' )
|
||||||
|
{ // next character should be interpretted literally
|
||||||
|
i++;
|
||||||
|
}
|
||||||
val[k][j] = map[i];
|
val[k][j] = map[i];
|
||||||
i++;
|
i++;
|
||||||
j++;
|
j++;
|
||||||
|
@ -924,7 +928,24 @@ int GamePad_t::saveCurrentMapToFile(const char *name)
|
||||||
{
|
{
|
||||||
if (bmap[c][i].ButtType == BUTTC_KEYBOARD)
|
if (bmap[c][i].ButtType == BUTTC_KEYBOARD)
|
||||||
{
|
{
|
||||||
sprintf(stmp, "k%s", SDL_GetKeyName(bmap[c][i].ButtonNum));
|
int j=0,k=0; const char *keyName;
|
||||||
|
|
||||||
|
keyName = SDL_GetKeyName(bmap[c][i].ButtonNum);
|
||||||
|
|
||||||
|
stmp[k] = 'k'; k++;
|
||||||
|
|
||||||
|
// Write keyname in with necessary escape characters.
|
||||||
|
while ( keyName[j] != 0 )
|
||||||
|
{
|
||||||
|
if ( (keyName[j] == '\\') || (keyName[j] == ',') )
|
||||||
|
{
|
||||||
|
stmp[k] = '\\'; k++;
|
||||||
|
}
|
||||||
|
stmp[k] = keyName[j]; k++; j++;
|
||||||
|
}
|
||||||
|
stmp[k] = 0;
|
||||||
|
|
||||||
|
//sprintf(stmp, "k%s", SDL_GetKeyName(bmap[c][i].ButtonNum));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue