Mes recomanacions de cppcheck aplicades
Abans de tocar unes cosetes de strings buits
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
Input *Input::input_ = nullptr;
|
||||
|
||||
// [SINGLETON] Crearemos el objeto input con esta función estática
|
||||
void Input::init(std::string game_controller_db_path)
|
||||
void Input::init(const std::string &game_controller_db_path)
|
||||
{
|
||||
Input::input_ = new Input(game_controller_db_path);
|
||||
}
|
||||
@@ -27,12 +27,10 @@ Input *Input::get()
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Input::Input(std::string game_controller_db_path)
|
||||
: game_controller_db_path_(game_controller_db_path)
|
||||
Input::Input(const std::string &game_controller_db_path)
|
||||
: game_controller_db_path_(game_controller_db_path),
|
||||
enabled_(true)
|
||||
{
|
||||
// Inicializa variables
|
||||
enabled_ = true;
|
||||
|
||||
// Busca si hay mandos conectados
|
||||
discoverGameControllers();
|
||||
|
||||
@@ -434,12 +432,11 @@ bool Input::discoverGameControllers()
|
||||
for (int i = 0; i < num_gamepads_; i++)
|
||||
{
|
||||
// Abre el mando y lo añade a la lista
|
||||
SDL_GameController *pad = SDL_GameControllerOpen(i);
|
||||
auto pad = SDL_GameControllerOpen(i);
|
||||
if (SDL_GameControllerGetAttached(pad) == 1)
|
||||
{
|
||||
connected_controllers_.push_back(pad);
|
||||
const std::string separator(" #");
|
||||
std::string name = SDL_GameControllerNameForIndex(i);
|
||||
const std::string name = SDL_GameControllerNameForIndex(i);
|
||||
#ifdef VERBOSE
|
||||
{
|
||||
std::cout << name << std::endl;
|
||||
@@ -528,7 +525,7 @@ SDL_GameControllerButton Input::getControllerBinding(int controller_index, Input
|
||||
}
|
||||
|
||||
// Obtiene el indice a partir del nombre del mando
|
||||
int Input::getIndexByName(std::string name) const
|
||||
int Input::getIndexByName(const std::string &name) const
|
||||
{
|
||||
for (int i = 0; i < num_gamepads_; ++i)
|
||||
{
|
||||
@@ -572,7 +569,7 @@ std::string Input::to_string(InputType input) const
|
||||
}
|
||||
|
||||
// Convierte un std::string a InputType
|
||||
InputType Input::to_inputs_e(std::string name) const
|
||||
InputType Input::to_inputs_e(const std::string &name) const
|
||||
{
|
||||
if (name == "input_fire_left")
|
||||
{
|
||||
@@ -602,16 +599,6 @@ InputType Input::to_inputs_e(std::string name) const
|
||||
return InputType::NONE;
|
||||
}
|
||||
|
||||
// Activa todos los inputs. Sirve para evitar inputs sin repeticiones pero que ya vienen pulsados cuando checkInput no estaba monitorizando
|
||||
/*void Input::allActive(int controller_index)
|
||||
{
|
||||
for (int i = 0; i < (int)button_inputs_.size(); ++i)
|
||||
{
|
||||
controller_bindings_[controller_index][i].active = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Comprueba el eje del mando
|
||||
bool Input::checkAxisInput(InputType input, int controller_index) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user