Pequeños cambios en las librerias comunes
This commit is contained in:
@@ -97,7 +97,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
{
|
||||
if (repeat)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||
{
|
||||
successGameController = true;
|
||||
}
|
||||
@@ -108,11 +108,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gameControllerBindings[input].active)
|
||||
if (!gameControllerBindings.at(input).active)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||
{
|
||||
gameControllerBindings[input].active = true;
|
||||
gameControllerBindings.at(input).active = true;
|
||||
successGameController = true;
|
||||
}
|
||||
else
|
||||
@@ -122,9 +122,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) == 0)
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0)
|
||||
{
|
||||
gameControllerBindings[input].active = false;
|
||||
gameControllerBindings.at(input).active = false;
|
||||
successGameController = false;
|
||||
}
|
||||
else
|
||||
@@ -138,6 +138,44 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
return (successKeyboard || successGameController);
|
||||
}
|
||||
|
||||
// Comprueba si hay almenos un input activo
|
||||
bool Input::checkAnyInput(int device, int index)
|
||||
{
|
||||
if (device == INPUT_USE_ANY)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||
{
|
||||
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
for (int i = 0; i < (int)keyBindings.size(); ++i)
|
||||
{
|
||||
if (mKeystates[keyBindings.at(i).scancode] != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gameControllerFound())
|
||||
{
|
||||
if (device == INPUT_USE_GAMECONTROLLER || device == INPUT_USE_ANY)
|
||||
{
|
||||
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(i).button) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Comprueba si hay un mando conectado
|
||||
bool Input::discoverGameController()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user