Trabajando en el marcador
This commit is contained in:
@@ -130,6 +130,43 @@ 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)
|
||||
{
|
||||
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);
|
||||
|
||||
for (int i = 0; i < 17; i++)
|
||||
{
|
||||
if (mKeystates[keyBindings[i].scancode] != 0)
|
||||
{
|
||||
successKeyboard |= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gameControllerFound())
|
||||
if ((device == INPUT_USE_GAMECONTROLLER) || (device == INPUT_USE_ANY))
|
||||
{
|
||||
for (int i = 0; i < 17; i++)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[i].button) != 0)
|
||||
{
|
||||
successGameController |= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (successKeyboard || successGameController);
|
||||
}
|
||||
|
||||
// Comprueba si hay un mando conectado
|
||||
bool Input::discoverGameController()
|
||||
{
|
||||
@@ -174,7 +211,7 @@ bool Input::discoverGameController()
|
||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||
}
|
||||
|
||||
//mGameController = connectedControllers[0];
|
||||
// mGameController = connectedControllers[0];
|
||||
SDL_GameControllerEventState(SDL_ENABLE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user