diff --git a/source/title.cpp b/source/title.cpp index 637f0fe..c3228b5 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -138,15 +138,21 @@ void Title::init(bool demo, Uint8 subsection) if (!mInput->gameControllerFound()) { + mOptions->input[0].id = 0; + mOptions->input[0].name = "KEYBOARD"; mOptions->input[0].deviceType = INPUT_USE_KEYBOARD; + + mOptions->input[1].id = 0; + mOptions->input[1].name = "GAME CONTROLLER"; mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER; } - - checkInputDevices(); - mDeviceIndex[0] = 0; + checkInputDevices(); + + mDeviceIndex[0] = mAvailableInputDevices.size(); mDeviceIndex[1] = 0; + // Inicializa el bitmap de Coffee mCoffeeBitmap->init(mTitleTexture, mRenderer); mCoffeeBitmap->setId(0); @@ -917,24 +923,26 @@ void Title::runDemoGame() // Modifica las opciones para los controles de los jugadores bool Title::updatePlayerInputs(int numPlayer) { - const int numDevices = mInput->getNumControllers(); + const int numDevices = mAvailableInputDevices.size(); // Si no hay mandos se deja todo de manera prefijada - if (numDevices == 0) + if (!mInput->gameControllerFound()) { mDeviceIndex[0] = 0; mDeviceIndex[1] = 0; + mOptions->input[0].id = -1; mOptions->input[0].name = "KEYBOARD"; mOptions->input[0].deviceType = INPUT_USE_KEYBOARD; + mOptions->input[1].id = 0; - mOptions->input[0].name = "GAME CONTROLLER"; + mOptions->input[1].name = "GAME CONTROLLER"; mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER; return true; } else // Si hay mas de un dispositivo, se recorre el vector - { + { // Incrementa el indice if (mDeviceIndex[numPlayer] < numDevices - 1) mDeviceIndex[numPlayer]++; @@ -948,7 +956,7 @@ bool Title::updatePlayerInputs(int numPlayer) mDeviceIndex[0] = mDeviceIndex[1]; mDeviceIndex[1] = temp; } - + // Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador mOptions->input[0] = mAvailableInputDevices[mDeviceIndex[0]]; mOptions->input[1] = mAvailableInputDevices[mDeviceIndex[1]];