From cda4d3a566d4f430b53e691173388a52a24b2aa4 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 30 Aug 2021 22:24:16 +0200 Subject: [PATCH] added gamecontrollerdb.txt --- source/director.cpp | 5 ++++- source/input.cpp | 6 +++++- source/input.h | 3 ++- source/menu.cpp | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index eaea71c..86e106e 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -40,7 +40,7 @@ Director::Director(std::string path) } // Crea los objetos - mInput = new Input(); + mInput = new Input(mFileList[52]); //mInput2 = new Input(mOptions->input[1]); //mInput[0] = new Input(INPUT_USE_KEYBOARD); //mInput[1] = new Input(INPUT_USE_GAMECONTROLLER); @@ -269,6 +269,9 @@ void Director::setFileList() mFileList[49] = mExecutablePath + "/" + "../media/lang/es_ES.txt"; mFileList[50] = mExecutablePath + "/" + "../media/lang/en_UK.txt"; mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt"; + + // DATA + mFileList[52] = mExecutablePath + "/" + "../media/data/gamecontrollerdb.txt"; } // Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada diff --git a/source/input.cpp b/source/input.cpp index ef8ba36..945e7e2 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -3,8 +3,11 @@ #include // Constructor -Input::Input() +Input::Input(std::string file) { + // Fichero gamecontrollerdb.txt + mDBpath = file; + // Inicializa las variables for (int i = 0; i < 17; i++) { @@ -167,6 +170,7 @@ bool Input::discoverGameController() mGameController = mConnectedControllers[0]; SDL_GameControllerEventState(SDL_ENABLE); + SDL_GameControllerAddMappingsFromFile(mDBpath.c_str()); } return found; diff --git a/source/input.h b/source/input.h index cfd80f8..bf7a3ff 100644 --- a/source/input.h +++ b/source/input.h @@ -53,13 +53,14 @@ private: std::vector mConnectedControllers; std::vector mControllerNames; int mNumGamepads; + std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt // Comprueba si hay un mando conectado bool discoverGameController(); public: // Constructor - Input(); + Input(std::string file); // Destructor ~Input(); diff --git a/source/menu.cpp b/source/menu.cpp index 13b30fe..e609ea4 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -532,7 +532,7 @@ Uint16 Menu::findHeight() for (int i = 0; i < mTotalItems; i++) height += mItem[i].rect.h + mItem[i].hPaddingDown; - return height; + return height - mItem[mTotalItems - 1].hPaddingDown; } // Recoloca los elementos del menu en el eje Y