mirror of https://github.com/snes9xgit/snes9x.git
GTK: Allow one key for multi joypad assignments.
Lets you do stuff like Chrono Trigger L+R+A or all punch buttons in fighting games.
This commit is contained in:
parent
dfe66f57b3
commit
bdf0e426e0
|
@ -692,7 +692,7 @@ int Snes9xConfig::load_config_file ()
|
|||
void Snes9xConfig::rebind_keys()
|
||||
{
|
||||
s9xcommand_t cmd;
|
||||
char buf[256];
|
||||
std::string string;
|
||||
|
||||
S9xUnmapAllControls();
|
||||
|
||||
|
@ -702,13 +702,36 @@ void Snes9xConfig::rebind_keys ()
|
|||
|
||||
for (int button_i = 0; button_i < NUM_JOYPAD_LINKS; button_i++)
|
||||
{
|
||||
snprintf (buf,
|
||||
256,
|
||||
"Joypad%d %s",
|
||||
(joypad_i % 5) + 1,
|
||||
b_links[button_i].snes9x_name);
|
||||
int dupe;
|
||||
for (dupe = button_i + 1; dupe < NUM_JOYPAD_LINKS; dupe++)
|
||||
{
|
||||
if (bin[button_i].matches(bin[dupe]) && bin[button_i].hex() != 0)
|
||||
{
|
||||
printf("%d: %d matches %d\n", joypad_i, button_i, dupe);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dupe < NUM_JOYPAD_LINKS || bin[button_i].hex() == 0)
|
||||
continue;
|
||||
|
||||
cmd = S9xGetPortCommandT (buf);
|
||||
string += "Joypad" + std::to_string((joypad_i % 5) + 1) + " ";
|
||||
string += b_links[button_i].snes9x_name;
|
||||
|
||||
bool ismulti = false;
|
||||
for (dupe = button_i - 1; dupe > 0; dupe--)
|
||||
{
|
||||
if (bin[button_i].matches(bin[dupe]))
|
||||
{
|
||||
ismulti = true;
|
||||
string += ",Joypad" + std::to_string((joypad_i % 5) + 1) + " ";
|
||||
string += b_links[dupe].snes9x_name;
|
||||
}
|
||||
}
|
||||
|
||||
if (ismulti)
|
||||
string = std::string("{") + string + "}";
|
||||
|
||||
cmd = S9xGetPortCommandT(string.c_str());
|
||||
|
||||
S9xMapButton(bin[button_i].base_hex(), cmd, false);
|
||||
}
|
||||
|
@ -716,8 +739,7 @@ void Snes9xConfig::rebind_keys ()
|
|||
|
||||
for (int i = NUM_JOYPAD_LINKS; b_links[i].snes9x_name; i++)
|
||||
{
|
||||
snprintf (buf, 256, "%s", b_links[i].snes9x_name);
|
||||
cmd = S9xGetPortCommandT (buf);
|
||||
cmd = S9xGetPortCommandT(b_links[i].snes9x_name);
|
||||
S9xMapButton(shortcut[i - NUM_JOYPAD_LINKS].base_hex(),
|
||||
cmd,
|
||||
false);
|
||||
|
|
|
@ -1219,10 +1219,6 @@ Snes9xPreferences::store_binding (const char *string, Binding binding)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (pad_bindings[i].matches (binding))
|
||||
{
|
||||
pad_bindings[i].clear ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue