From 92aae07fd1221133e30cc8b58e2913fec141db73 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 23 May 2023 18:30:30 +0200 Subject: [PATCH] input: optimizado el constructor --- main.cpp | 6 ++---- units/input.cpp | 5 +++-- units/input.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 9391af4..68502ff 100644 --- a/main.cpp +++ b/main.cpp @@ -90,10 +90,8 @@ int main(int argc, char *argv[]) screen->addNotifier(asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav")); // Inicializa el objeto input - Input *input = new Input(asset->get("gamecontrollerdb.txt")); - input->setVerbose(options->console); - input->discoverGameController(); - string controllerName = input->getNumControllers() > 0 ? input->getControllerName(0) : ""; + Input *input = new Input(asset->get("gamecontrollerdb.txt"), options->console); + string controllerName = input->getControllerName(0); // Inicializa el texto Text *text = new Text(asset->get("smb2.txt"), asset->get("smb2.png"), renderer); diff --git a/units/input.cpp b/units/input.cpp index 22410ba..1a8f9f2 100644 --- a/units/input.cpp +++ b/units/input.cpp @@ -2,7 +2,7 @@ #include // Constructor -Input::Input(string file) +Input::Input(string file, bool verbose) { // Fichero gamecontrollerdb.txt dbPath = file; @@ -18,10 +18,11 @@ Input::Input(string file) gcb.active = false; gameControllerBindings.resize(INPUT_TOTAL, gcb); - verbose = true; + this->verbose = verbose; enabled = true; setDefaultBindings(); + discoverGameController(); } // Actualiza el estado del objeto diff --git a/units/input.h b/units/input.h index 7473b18..5bf073e 100644 --- a/units/input.h +++ b/units/input.h @@ -89,7 +89,7 @@ private: public: // Constructor - Input(string file); + Input(string file, bool verbose=true); // Actualiza el estado del objeto void update();