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")
{
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);
}
if (controllerButton_restart.size() < 1)
{
controllerButton_restart.push_back(SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
}
}
void Game::savestats()
@@ -4789,6 +4802,12 @@ void Game::savestats()
msg->LinkEndChild(doc.NewText(help.String((int) controllerButton_esc[i]).c_str()));
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->LinkEndChild( doc.NewText( help.String(controllerSensitivity).c_str()));