bug fixes

This commit is contained in:
2021-09-01 14:04:34 +02:00
parent 0b996ea321
commit 658bb71441
7 changed files with 92 additions and 25 deletions

View File

@@ -136,7 +136,7 @@ void Title::init(bool demo, Uint8 subsection)
mFade->init(0x17, 0x17, 0x26);
mDemo = demo;
if (!mInput->gameControllerFound())
//if (!mInput->gameControllerFound())
{
mOptions->input[0].id = 0;
mOptions->input[0].name = "KEYBOARD";
@@ -152,6 +152,13 @@ void Title::init(bool demo, Uint8 subsection)
mDeviceIndex[0] = mAvailableInputDevices.size() - 1;
mDeviceIndex[1] = 0;
if (mInput->gameControllerFound())
{
mOptions->input[1].id = mAvailableInputDevices[mDeviceIndex[1]].id;
mOptions->input[1].name = mAvailableInputDevices[mDeviceIndex[1]].name;
mOptions->input[1].deviceType = mAvailableInputDevices[mDeviceIndex[1]].deviceType;
}
// Inicializa el bitmap de Coffee
mCoffeeBitmap->init(mTitleTexture, mRenderer);
mCoffeeBitmap->setId(0);
@@ -942,18 +949,29 @@ bool Title::updatePlayerInputs(int numPlayer)
}
else // Si hay mas de un dispositivo, se recorre el vector
{
printf("numplayer:%i\n",numPlayer);
printf("deviceindex:%i\n",mDeviceIndex[numPlayer]);
// Incrementa el indice
if (mDeviceIndex[numPlayer] < numDevices - 1)
mDeviceIndex[numPlayer]++;
else
mDeviceIndex[numPlayer] = 0;
printf("deviceindex:%i\n",mDeviceIndex[numPlayer]);
// Si coincide con el del otro jugador, se lo intercambian
if (mDeviceIndex[0] == mDeviceIndex[1])
{
const int temp = mDeviceIndex[0];
mDeviceIndex[0] = mDeviceIndex[1];
mDeviceIndex[1] = temp;
printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]);
//const int temp = mDeviceIndex[0];
//mDeviceIndex[0] = mDeviceIndex[1];
//mDeviceIndex[1] = temp;
const int theOtherPlayer = (numPlayer + 1) % 2;
mDeviceIndex[theOtherPlayer]--;
if (mDeviceIndex[theOtherPlayer] < 0)
mDeviceIndex[theOtherPlayer]=numDevices-1;
printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]);
}
// Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador