cppcheck
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, basi...
|
||||
#include <algorithm> // for any_of
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, basi...
|
||||
|
||||
// Emscripten-only: SDL 3.4+ ja no casa el GUID dels mandos de Chrome Android
|
||||
// amb gamecontrollerdb (el gamepad.id d'Android no porta Vendor/Product, el
|
||||
@@ -57,10 +58,12 @@ auto Input::get() -> Input * {
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Input::Input(std::string file) {
|
||||
// Fichero gamecontrollerdb.txt
|
||||
dbPath = file;
|
||||
|
||||
Input::Input(const std::string &file)
|
||||
: numGamepads(0),
|
||||
dbPath(file),
|
||||
verbose(true),
|
||||
disabledUntil(d_notDisabled),
|
||||
enabled(true) {
|
||||
// Inicializa las variables
|
||||
keyBindings_t kb;
|
||||
kb.scancode = 0;
|
||||
@@ -71,10 +74,6 @@ Input::Input(std::string file) {
|
||||
gcb.button = SDL_GAMEPAD_BUTTON_INVALID;
|
||||
gcb.active = false;
|
||||
gameControllerBindings.resize(input_number_of_inputs, gcb);
|
||||
|
||||
numGamepads = 0;
|
||||
verbose = true;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -311,10 +310,8 @@ bool Input::handleGamepadAdded(SDL_JoystickID jid, std::string &outName) {
|
||||
}
|
||||
|
||||
// Si el mando ya está registrado no hace nada (ej. evento retroactivo tras el scan inicial)
|
||||
for (SDL_JoystickID existing : connectedControllerIds) {
|
||||
if (existing == jid) {
|
||||
return false;
|
||||
}
|
||||
if (std::any_of(connectedControllerIds.begin(), connectedControllerIds.end(), [jid](SDL_JoystickID existing) { return existing == jid; })) {
|
||||
return false;
|
||||
}
|
||||
|
||||
installWebStandardMapping(jid);
|
||||
|
||||
@@ -80,7 +80,7 @@ class Input {
|
||||
std::string buildControllerName(SDL_Gamepad *pad, int padIndex);
|
||||
|
||||
// Constructor privado (usar Input::init)
|
||||
Input(std::string file);
|
||||
explicit Input(const std::string &file);
|
||||
|
||||
// Instancia única
|
||||
static Input *instance;
|
||||
|
||||
Reference in New Issue
Block a user