Ya se guardan las asignaciones de los botones en el fichero de configuración
This commit is contained in:
@@ -404,18 +404,38 @@ void Input::printBindings(int device, int index)
|
||||
}
|
||||
|
||||
// Muestra el nombre del mando
|
||||
std::cout << "\n" << controllerNames[index] << std::endl;
|
||||
std::cout << "\n"
|
||||
<< controllerNames[index] << std::endl;
|
||||
|
||||
// Muestra los botones asignados
|
||||
for (auto bi : buttonInputs)
|
||||
{
|
||||
std::cout << to_String(bi) << " : " << gameControllerBindings[index][bi].button << std::endl;
|
||||
std::cout << to_string(bi) << " : " << gameControllerBindings[index][bi].button << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene el SDL_GameControllerButton asignado a un input
|
||||
SDL_GameControllerButton Input::getControllerBinding(int index, inputs_e input)
|
||||
{
|
||||
return gameControllerBindings[index][input].button;
|
||||
}
|
||||
|
||||
// Obtiene el indice a partir del nombre del mando
|
||||
int Input::getIndexByName(std::string name)
|
||||
{
|
||||
for (int i = 0; i < numGamepads; ++i)
|
||||
{
|
||||
if (controllerNames[i] == name)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Convierte un inputs_e a std::string
|
||||
std::string Input::to_String(inputs_e input)
|
||||
std::string Input::to_string(inputs_e input)
|
||||
{
|
||||
if (input == input_fire_left)
|
||||
{
|
||||
@@ -438,4 +458,30 @@ std::string Input::to_String(inputs_e input)
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// Convierte un std::string a inputs_e
|
||||
inputs_e Input::to_inputs_e(std::string name)
|
||||
{
|
||||
if (name == "input_fire_left")
|
||||
{
|
||||
return input_fire_left;
|
||||
}
|
||||
|
||||
if (name == "input_fire_center")
|
||||
{
|
||||
return input_fire_center;
|
||||
}
|
||||
|
||||
if (name == "input_fire_right")
|
||||
{
|
||||
return input_fire_right;
|
||||
}
|
||||
|
||||
if (name == "input_start")
|
||||
{
|
||||
return input_start;
|
||||
}
|
||||
|
||||
return input_null;
|
||||
}
|
||||
Reference in New Issue
Block a user