forked from jaildesigner-jailgames/jaildoctors_dilemma
Añadidos parametros al programa
This commit is contained in:
@@ -18,17 +18,19 @@ Input::Input(std::string file)
|
||||
gcb.active = false;
|
||||
gameControllerBindings.resize(17, gcb);
|
||||
|
||||
verbose = true;
|
||||
|
||||
// Comprueba si hay un mando conectado
|
||||
discoverGameController();
|
||||
}
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
// Asigna inputs a teclas
|
||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
||||
{
|
||||
keyBindings.at(input).scancode = code;
|
||||
}
|
||||
|
||||
// Asigna uno de los posibles inputs a un botón del mando
|
||||
// Asigna inputs a botones del mando
|
||||
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
||||
{
|
||||
gameControllerBindings.at(input).button = button;
|
||||
@@ -41,7 +43,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
bool successGameController = false;
|
||||
|
||||
if (device == INPUT_USE_ANY)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||
{
|
||||
@@ -183,7 +187,10 @@ bool Input::discoverGameController()
|
||||
|
||||
if (SDL_GameControllerAddMappingsFromFile(dbPath.c_str()) < 0)
|
||||
{
|
||||
std::cout << "Error, could not load " << dbPath.c_str() << " file: " << SDL_GetError() << std::endl;
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "Error, could not load " << dbPath.c_str() << " file: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
const int nJoysticks = SDL_NumJoysticks();
|
||||
@@ -198,8 +205,11 @@ bool Input::discoverGameController()
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "\nChecking for game controllers...\n";
|
||||
std::cout << nJoysticks << " joysticks found, " << numGamepads << " are gamepads\n";
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "\nChecking for game controllers...\n";
|
||||
std::cout << nJoysticks << " joysticks found, " << numGamepads << " are gamepads\n";
|
||||
}
|
||||
|
||||
if (numGamepads > 0)
|
||||
{
|
||||
@@ -216,12 +226,18 @@ bool Input::discoverGameController()
|
||||
std::string name = SDL_GameControllerNameForIndex(i);
|
||||
name.resize(25);
|
||||
name = name + separator + std::to_string(i);
|
||||
std::cout << name << std::endl;
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << name << std::endl;
|
||||
}
|
||||
controllerNames.push_back(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,4 +277,10 @@ std::string Input::getControllerName(int index)
|
||||
int Input::getNumControllers()
|
||||
{
|
||||
return numGamepads;
|
||||
}
|
||||
|
||||
// Establece si ha de mostrar mensajes
|
||||
void Input::setVerbose(bool value)
|
||||
{
|
||||
verbose = value;
|
||||
}
|
||||
Reference in New Issue
Block a user