Arreglos varios al codi
This commit is contained in:
@@ -1,41 +1,39 @@
|
||||
#include "input.h"
|
||||
#include <SDL2/SDL.h> // for SDL_INIT_GAMECONTROLLER, SDL_InitSubS...
|
||||
#include <SDL2/SDL_error.h> // for SDL_GetError
|
||||
#include <SDL2/SDL_events.h> // for SDL_ENABLE
|
||||
#include <SDL2/SDL_keyboard.h> // for SDL_GetKeyboardState
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, basi...
|
||||
#include <SDL2/SDL.h> // for SDL_INIT_GAMECONTROLLER, SDL_InitSubS...
|
||||
#include <SDL2/SDL_error.h> // for SDL_GetError
|
||||
#include <SDL2/SDL_events.h> // for SDL_ENABLE
|
||||
#include <SDL2/SDL_keyboard.h> // for SDL_GetKeyboardState
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, basi...
|
||||
|
||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||
Input *Input::input = nullptr;
|
||||
|
||||
// [SINGLETON] Crearemos el objeto input con esta función estática
|
||||
void Input::init(std::string file)
|
||||
void Input::init(std::string dbPath)
|
||||
{
|
||||
Input::input = new Input(file);
|
||||
Input::input = new Input(dbPath);
|
||||
}
|
||||
|
||||
// [SINGLETON] Destruiremos el objeto input con esta función estática
|
||||
void Input::destroy()
|
||||
{
|
||||
delete Input::input;
|
||||
delete Input::input;
|
||||
}
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto input y podemos trabajar con él
|
||||
Input *Input::get()
|
||||
{
|
||||
return Input::input;
|
||||
return Input::input;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Input::Input(std::string file)
|
||||
Input::Input(std::string dbPath)
|
||||
: dbPath(dbPath)
|
||||
{
|
||||
// Inicializa variables
|
||||
verbose = false;
|
||||
enabled = true;
|
||||
|
||||
// Fichero gamecontrollerdb.txt
|
||||
dbPath = file;
|
||||
|
||||
// Busca si hay mandos conectados
|
||||
discoverGameControllers();
|
||||
|
||||
@@ -75,7 +73,6 @@ Input::Input(std::string file)
|
||||
// Destructor
|
||||
Input::~Input()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Actualiza el estado del objeto
|
||||
@@ -171,7 +168,7 @@ bool Input::checkInput(inputs_e input, bool repeat, int device, int index)
|
||||
}
|
||||
}
|
||||
|
||||
if (gameControllerFound() && index < numGamepads)
|
||||
if (gameControllerFound() && index < numGamepads)
|
||||
if ((device == INPUT_USE_GAMECONTROLLER) || (device == INPUT_USE_ANY))
|
||||
{
|
||||
successGameController = checkAxisInput(input, index);
|
||||
|
||||
Reference in New Issue
Block a user