Working on support for various controllers

This commit is contained in:
2021-08-31 13:56:03 +02:00
parent 8e6d546b97
commit ad5fb0fc22
6 changed files with 41 additions and 31 deletions

View File

@@ -1,7 +1,11 @@
#include "input.h"
//#include <stdio.h>
#include <iostream>
// Contestar cuantos joystics ha detectado
// Preguntarlepor los joystics que ha encontrado para ir poniendolos en la variable de opciones
// Constructor
Input::Input(std::string file)
{
@@ -24,9 +28,6 @@ Input::Input(std::string file)
// Destructor
Input::~Input()
{
//SDL_GameControllerClose(mGameController);
//if (mGameController)
//mGameController = nullptr;
for (int i = 0; i < mNumGamepads; i++)
mConnectedControllers[i] = nullptr;
}
@@ -49,6 +50,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
bool successKeyboard = false;
bool successGameController = false;
if (device == INPUT_USE_ANY)
index = 0;
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
{
const Uint8 *mKeystates = SDL_GetKeyboardState(NULL);