1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Added ability to bind restart to a controller.

This commit is contained in:
Nichole Mattera 2020-08-08 18:41:59 -04:00 committed by Ethan Lee
parent af88aee7c0
commit 1376e65b5d
4 changed files with 82 additions and 3 deletions

View file

@ -4544,6 +4544,15 @@ void Game::loadstats(int *width, int *height, bool *vsync)
} }
} }
if (pKey == "restartButton")
{
SDL_GameControllerButton newButton;
if (GetButtonFromString(pText, &newButton))
{
controllerButton_restart.push_back(newButton);
}
}
if (pKey == "controllerSensitivity") if (pKey == "controllerSensitivity")
{ {
controllerSensitivity = help.Int(pText); controllerSensitivity = help.Int(pText);
@ -4571,6 +4580,10 @@ void Game::loadstats(int *width, int *height, bool *vsync)
{ {
controllerButton_esc.push_back(SDL_CONTROLLER_BUTTON_B); controllerButton_esc.push_back(SDL_CONTROLLER_BUTTON_B);
} }
if (controllerButton_restart.size() < 1)
{
controllerButton_restart.push_back(SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
}
} }
void Game::savestats() void Game::savestats()
@ -4789,6 +4802,12 @@ void Game::savestats()
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_esc[i]).c_str())); msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_esc[i]).c_str()));
dataNode->LinkEndChild(msg); dataNode->LinkEndChild(msg);
} }
for (size_t i = 0; i < controllerButton_restart.size(); i += 1)
{
msg = doc.NewElement("restartButton");
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_restart[i]).c_str()));
dataNode->LinkEndChild(msg);
}
msg = doc.NewElement( "controllerSensitivity" ); msg = doc.NewElement( "controllerSensitivity" );
msg->LinkEndChild( doc.NewText( help.String(controllerSensitivity).c_str())); msg->LinkEndChild( doc.NewText( help.String(controllerSensitivity).c_str()));

View file

@ -374,6 +374,7 @@ public:
std::vector<SDL_GameControllerButton> controllerButton_map; std::vector<SDL_GameControllerButton> controllerButton_map;
std::vector<SDL_GameControllerButton> controllerButton_flip; std::vector<SDL_GameControllerButton> controllerButton_flip;
std::vector<SDL_GameControllerButton> controllerButton_esc; std::vector<SDL_GameControllerButton> controllerButton_esc;
std::vector<SDL_GameControllerButton> controllerButton_restart;
bool skipfakeload; bool skipfakeload;
bool ghostsenabled; bool ghostsenabled;

View file

@ -52,6 +52,13 @@ void updatebuttonmappings(int bind)
game.controllerButton_esc.erase(game.controllerButton_esc.begin() + j); game.controllerButton_esc.erase(game.controllerButton_esc.begin() + j);
} }
} }
for (size_t j = 0; j < game.controllerButton_restart.size(); j += 1)
{
if (i == game.controllerButton_restart[j])
{
game.controllerButton_restart.erase(game.controllerButton_restart.begin() + j);
}
}
} }
if (bind == 2) if (bind == 2)
{ {
@ -81,6 +88,13 @@ void updatebuttonmappings(int bind)
game.controllerButton_esc.erase(game.controllerButton_esc.begin() + j); game.controllerButton_esc.erase(game.controllerButton_esc.begin() + j);
} }
} }
for (size_t j = 0; j < game.controllerButton_restart.size(); j += 1)
{
if (i == game.controllerButton_restart[j])
{
game.controllerButton_restart.erase(game.controllerButton_restart.begin() + j);
}
}
} }
if (bind == 3) if (bind == 3)
{ {
@ -110,6 +124,49 @@ void updatebuttonmappings(int bind)
game.controllerButton_map.erase(game.controllerButton_map.begin() + j); game.controllerButton_map.erase(game.controllerButton_map.begin() + j);
} }
} }
for (size_t j = 0; j < game.controllerButton_restart.size(); j += 1)
{
if (i == game.controllerButton_restart[j])
{
game.controllerButton_restart.erase(game.controllerButton_restart.begin() + j);
}
}
}
if (bind == 4)
{
for (size_t j = 0; j < game.controllerButton_restart.size(); j += 1)
{
if (i == game.controllerButton_restart[j])
{
dupe = true;
}
}
if (!dupe)
{
game.controllerButton_restart.push_back(i);
music.playef(11);
}
for (size_t j = 0; j < game.controllerButton_flip.size(); j += 1)
{
if (i == game.controllerButton_flip[j])
{
game.controllerButton_flip.erase(game.controllerButton_flip.begin() + j);
}
}
for (size_t j = 0; j < game.controllerButton_map.size(); j += 1)
{
if (i == game.controllerButton_map[j])
{
game.controllerButton_map.erase(game.controllerButton_map.begin() + j);
}
}
for (size_t j = 0; j < game.controllerButton_esc.size(); j += 1)
{
if (i == game.controllerButton_esc[j])
{
game.controllerButton_esc.erase(game.controllerButton_esc.begin() + j);
}
}
} }
} }
} }
@ -1200,7 +1257,7 @@ void menuactionpress()
} }
break; break;
case 4: case 5:
music.playef(11); music.playef(11);
game.returnmenu(); game.returnmenu();
break; break;
@ -1635,7 +1692,7 @@ void titleinput()
} }
if ( game.currentmenuname == Menu::controller && if ( game.currentmenuname == Menu::controller &&
game.currentmenuoption > 0 && game.currentmenuoption > 0 &&
game.currentmenuoption < 4 && game.currentmenuoption < 5 &&
key.controllerButtonDown() ) key.controllerButtonDown() )
{ {
updatebuttonmappings(game.currentmenuoption); updatebuttonmappings(game.currentmenuoption);
@ -1899,7 +1956,7 @@ void gameinput()
} }
} }
if (key.keymap[SDLK_r] && !game.nodeathmode)// && map.custommode) //Have fun glitchrunners! if ((key.isDown(SDLK_r) || key.isDown(game.controllerButton_restart)) && !game.nodeathmode)// && map.custommode) //Have fun glitchrunners!
{ {
game.deathseq = 30; game.deathseq = 30;
} }

View file

@ -415,9 +415,11 @@ void menurender()
case 1: case 1:
case 2: case 2:
case 3: case 3:
case 4:
graphics.Print( -1, 85, "Flip is bound to: " + std::string(help.GCString(game.controllerButton_flip)) , tr, tg, tb, true); graphics.Print( -1, 85, "Flip is bound to: " + std::string(help.GCString(game.controllerButton_flip)) , tr, tg, tb, true);
graphics.Print( -1, 95, "Enter is bound to: " + std::string(help.GCString(game.controllerButton_map)), tr, tg, tb, true); graphics.Print( -1, 95, "Enter is bound to: " + std::string(help.GCString(game.controllerButton_map)), tr, tg, tb, true);
graphics.Print( -1, 105, "Menu is bound to: " + std::string(help.GCString(game.controllerButton_esc)) , tr, tg, tb, true); graphics.Print( -1, 105, "Menu is bound to: " + std::string(help.GCString(game.controllerButton_esc)) , tr, tg, tb, true);
graphics.Print( -1, 115, "Restart is bound to: " + std::string(help.GCString(game.controllerButton_restart)) , tr, tg, tb, true);
break; break;
} }