Corregit bug en el text a l'hora d'intercanviar els mandos. Apareixia el nom del mando que te guardat a la configuració pero no estava connectat

This commit is contained in:
2024-10-03 19:26:32 +02:00
parent fb74733f2c
commit c07fd62037
6 changed files with 33 additions and 29 deletions

View File

@@ -454,8 +454,6 @@ bool Input::discoverGameControllers()
connectedControllers.push_back(pad);
const std::string separator(" #");
std::string name = SDL_GameControllerNameForIndex(i);
// name.resize(25);
// name = name + separator + std::to_string(i);
if (verbose)
{
std::cout << name << std::endl;
@@ -484,13 +482,13 @@ bool Input::gameControllerFound()
}
// Obten el nombre de un mando de juego
std::string Input::getControllerName(int index)
std::string Input::getControllerName(int index) const
{
return numGamepads > 0 ? controllerNames[index] : "";
}
// Obten el número de mandos conectados
int Input::getNumControllers()
int Input::getNumControllers() const
{
return numGamepads;
}
@@ -516,7 +514,7 @@ void Input::enable()
}
// Obtiene el indice del controlador a partir de un event.id
int Input::getJoyIndex(int id)
int Input::getJoyIndex(int id) const
{
for (int i = 0; i < numJoysticks; ++i)
{
@@ -529,7 +527,7 @@ int Input::getJoyIndex(int id)
}
// Muestra por consola los controles asignados
void Input::printBindings(int device, int index)
void Input::printBindings(int device, int index) const
{
if (device == INPUT_USE_ANY || device == INPUT_USE_KEYBOARD)
{
@@ -556,13 +554,13 @@ void Input::printBindings(int device, int index)
}
// Obtiene el SDL_GameControllerButton asignado a un input
SDL_GameControllerButton Input::getControllerBinding(int index, inputs_e input)
SDL_GameControllerButton Input::getControllerBinding(int index, inputs_e input) const
{
return gameControllerBindings[index][input].button;
}
// Obtiene el indice a partir del nombre del mando
int Input::getIndexByName(std::string name)
int Input::getIndexByName(std::string name) const
{
for (int i = 0; i < numGamepads; ++i)
{
@@ -575,7 +573,7 @@ int Input::getIndexByName(std::string name)
}
// Convierte un inputs_e a std::string
std::string Input::to_string(inputs_e input)
std::string Input::to_string(inputs_e input) const
{
if (input == input_fire_left)
{
@@ -606,7 +604,7 @@ std::string Input::to_string(inputs_e input)
}
// Convierte un std::string a inputs_e
inputs_e Input::to_inputs_e(std::string name)
inputs_e Input::to_inputs_e(std::string name) const
{
if (name == "input_fire_left")
{
@@ -646,7 +644,7 @@ void Input::allActive(int index)
}
// Comprueba el eje del mando
bool Input::checkAxisInput(inputs_e input, int index)
bool Input::checkAxisInput(inputs_e input, int index) const
{
bool success = false;