Working on support for various controllers

This commit is contained in:
2021-08-31 21:30:55 +02:00
parent 42c0f19c68
commit cf072424c6

View File

@@ -138,15 +138,21 @@ void Title::init(bool demo, Uint8 subsection)
if (!mInput->gameControllerFound()) if (!mInput->gameControllerFound())
{ {
mOptions->input[0].id = 0;
mOptions->input[0].name = "KEYBOARD";
mOptions->input[0].deviceType = INPUT_USE_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; mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
} }
checkInputDevices(); checkInputDevices();
mDeviceIndex[0] = 0; mDeviceIndex[0] = mAvailableInputDevices.size();
mDeviceIndex[1] = 0; mDeviceIndex[1] = 0;
// Inicializa el bitmap de Coffee // Inicializa el bitmap de Coffee
mCoffeeBitmap->init(mTitleTexture, mRenderer); mCoffeeBitmap->init(mTitleTexture, mRenderer);
mCoffeeBitmap->setId(0); mCoffeeBitmap->setId(0);
@@ -917,18 +923,20 @@ void Title::runDemoGame()
// Modifica las opciones para los controles de los jugadores // Modifica las opciones para los controles de los jugadores
bool Title::updatePlayerInputs(int numPlayer) 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 // Si no hay mandos se deja todo de manera prefijada
if (numDevices == 0) if (!mInput->gameControllerFound())
{ {
mDeviceIndex[0] = 0; mDeviceIndex[0] = 0;
mDeviceIndex[1] = 0; mDeviceIndex[1] = 0;
mOptions->input[0].id = -1; mOptions->input[0].id = -1;
mOptions->input[0].name = "KEYBOARD"; mOptions->input[0].name = "KEYBOARD";
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD; mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
mOptions->input[1].id = 0; mOptions->input[1].id = 0;
mOptions->input[0].name = "GAME CONTROLLER"; mOptions->input[1].name = "GAME CONTROLLER";
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER; mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
return true; return true;