Ya se pueden definir los botones para cada jugador. Falta guardarlos en el fichero de configuración
This commit is contained in:
@@ -246,12 +246,15 @@ bool Input::discoverGameController()
|
||||
}
|
||||
}
|
||||
|
||||
const int nJoysticks = SDL_NumJoysticks();
|
||||
numJoysticks = SDL_NumJoysticks();
|
||||
numGamepads = 0;
|
||||
|
||||
// Cuenta el numero de mandos
|
||||
for (int i = 0; i < nJoysticks; ++i)
|
||||
// Cuenta el número de mandos
|
||||
joysticks.clear();
|
||||
for (int i = 0; i < numJoysticks; ++i)
|
||||
{
|
||||
SDL_Joystick *joy = SDL_JoystickOpen(i);
|
||||
joysticks.push_back(joy);
|
||||
if (SDL_IsGameController(i))
|
||||
{
|
||||
numGamepads++;
|
||||
@@ -261,7 +264,7 @@ bool Input::discoverGameController()
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "\nChecking for game controllers...\n";
|
||||
std::cout << nJoysticks << " joysticks found, " << numGamepads << " are gamepads\n";
|
||||
std::cout << numJoysticks << " joysticks found, " << numGamepads << " are gamepads\n";
|
||||
}
|
||||
|
||||
if (numGamepads > 0)
|
||||
@@ -326,7 +329,7 @@ std::string Input::getControllerName(int index)
|
||||
}
|
||||
}
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
// Obten el número de mandos conectados
|
||||
int Input::getNumControllers()
|
||||
{
|
||||
return numGamepads;
|
||||
@@ -350,4 +353,13 @@ void Input::enable()
|
||||
{
|
||||
enabled = true;
|
||||
disabledUntil = d_notDisabled;
|
||||
}
|
||||
|
||||
// Obtiene el indice del controlador a partir de un event.id
|
||||
int Input::getJoyIndex(int id)
|
||||
{
|
||||
for (int i = 0; i < numJoysticks; ++i)
|
||||
if (SDL_JoystickInstanceID(joysticks[i]) == id)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user