working on game controller input
This commit is contained in:
@@ -125,7 +125,7 @@ bool Director::initSDL()
|
||||
bool success = true;
|
||||
|
||||
// Inicializa SDL
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_HAPTIC) < 0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER| SDL_INIT_AUDIO | SDL_INIT_HAPTIC) < 0)
|
||||
{
|
||||
printf("SDL could not initialize!\nSDL Error: %s\n", SDL_GetError());
|
||||
success = false;
|
||||
|
||||
@@ -186,16 +186,37 @@ bool Input::checkInput(Uint8 input, bool repeat)
|
||||
// Comprueba si hay un mando conectado
|
||||
bool Input::discoverGameController()
|
||||
{
|
||||
/*if (SDL_NumJoysticks() < 1)
|
||||
for (int i = 0; i < SDL_NumJoysticks(); ++i)
|
||||
{
|
||||
if (SDL_IsGameController(i))
|
||||
{
|
||||
char *mapping;
|
||||
SDL_Log("Index \'%i\' is a compatible controller, named \'%s\'", i, SDL_GameControllerNameForIndex(i));
|
||||
mGameController = SDL_GameControllerOpen(i);
|
||||
mapping = SDL_GameControllerMapping(mGameController);
|
||||
SDL_Log("Controller %i is mapped as \"%s\".", i, mapping);
|
||||
SDL_free(mapping);
|
||||
mGameControllerFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Log("Index \'%i\' is not a compatible controller.", i);
|
||||
mGameControllerFound = false;
|
||||
}
|
||||
}
|
||||
return mGameController;
|
||||
}
|
||||
/*if (SDL_NumJoysticks() < 1)
|
||||
{
|
||||
printf("Warning: No joysticks connected!\n");
|
||||
mGameControllerFound = false;
|
||||
std::cout << "Warning: No joysticks connected!\n";
|
||||
}
|
||||
else*/
|
||||
{
|
||||
// Carga el mando
|
||||
mGameController = SDL_GameControllerOpen(0);
|
||||
else
|
||||
{*/
|
||||
// Carga el mando
|
||||
|
||||
/*mGameController = SDL_GameControllerOpen(0);
|
||||
|
||||
if (mGameController == NULL)
|
||||
{
|
||||
@@ -225,9 +246,9 @@ bool Input::discoverGameController()
|
||||
{
|
||||
printf("Warning: Unable to initialize rumble!\nSDL Error: %s\n", SDL_GetError());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mGameControllerFound;
|
||||
}
|
||||
return mGameControllerFound;
|
||||
}*/
|
||||
Reference in New Issue
Block a user