Corregit bug en el text a l'hora d'intercanviar els mandos. Apareixia el nom del mando que te guardat a la configuració pero no estava connectat
This commit is contained in:
@@ -197,10 +197,13 @@ void Director::initInput()
|
||||
for (int i = 0; i < numGamePads; ++i)
|
||||
for (int index = 0; index < (int)options.controller.size(); ++index)
|
||||
if (Input::get()->getControllerName(i) == options.controller[index].name)
|
||||
{
|
||||
options.controller[index].plugged = true;
|
||||
for (int j = 0; j < (int)options.controller[index].inputs.size(); ++j)
|
||||
{
|
||||
Input::get()->bindGameControllerButton(i, options.controller[index].inputs[j], options.controller[index].buttons[j]);
|
||||
}
|
||||
}
|
||||
|
||||
// Asigna botones a inputs desde otros inputs
|
||||
for (int i = 0; i < numGamePads; ++i)
|
||||
|
||||
@@ -454,8 +454,6 @@ bool Input::discoverGameControllers()
|
||||
connectedControllers.push_back(pad);
|
||||
const std::string separator(" #");
|
||||
std::string name = SDL_GameControllerNameForIndex(i);
|
||||
// name.resize(25);
|
||||
// name = name + separator + std::to_string(i);
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << name << std::endl;
|
||||
@@ -484,13 +482,13 @@ bool Input::gameControllerFound()
|
||||
}
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string Input::getControllerName(int index)
|
||||
std::string Input::getControllerName(int index) const
|
||||
{
|
||||
return numGamepads > 0 ? controllerNames[index] : "";
|
||||
}
|
||||
|
||||
// Obten el número de mandos conectados
|
||||
int Input::getNumControllers()
|
||||
int Input::getNumControllers() const
|
||||
{
|
||||
return numGamepads;
|
||||
}
|
||||
@@ -516,7 +514,7 @@ void Input::enable()
|
||||
}
|
||||
|
||||
// Obtiene el indice del controlador a partir de un event.id
|
||||
int Input::getJoyIndex(int id)
|
||||
int Input::getJoyIndex(int id) const
|
||||
{
|
||||
for (int i = 0; i < numJoysticks; ++i)
|
||||
{
|
||||
@@ -529,7 +527,7 @@ int Input::getJoyIndex(int id)
|
||||
}
|
||||
|
||||
// Muestra por consola los controles asignados
|
||||
void Input::printBindings(int device, int index)
|
||||
void Input::printBindings(int device, int index) const
|
||||
{
|
||||
if (device == INPUT_USE_ANY || device == INPUT_USE_KEYBOARD)
|
||||
{
|
||||
@@ -556,13 +554,13 @@ void Input::printBindings(int device, int index)
|
||||
}
|
||||
|
||||
// Obtiene el SDL_GameControllerButton asignado a un input
|
||||
SDL_GameControllerButton Input::getControllerBinding(int index, inputs_e input)
|
||||
SDL_GameControllerButton Input::getControllerBinding(int index, inputs_e input) const
|
||||
{
|
||||
return gameControllerBindings[index][input].button;
|
||||
}
|
||||
|
||||
// Obtiene el indice a partir del nombre del mando
|
||||
int Input::getIndexByName(std::string name)
|
||||
int Input::getIndexByName(std::string name) const
|
||||
{
|
||||
for (int i = 0; i < numGamepads; ++i)
|
||||
{
|
||||
@@ -575,7 +573,7 @@ int Input::getIndexByName(std::string name)
|
||||
}
|
||||
|
||||
// Convierte un inputs_e a std::string
|
||||
std::string Input::to_string(inputs_e input)
|
||||
std::string Input::to_string(inputs_e input) const
|
||||
{
|
||||
if (input == input_fire_left)
|
||||
{
|
||||
@@ -606,7 +604,7 @@ std::string Input::to_string(inputs_e input)
|
||||
}
|
||||
|
||||
// Convierte un std::string a inputs_e
|
||||
inputs_e Input::to_inputs_e(std::string name)
|
||||
inputs_e Input::to_inputs_e(std::string name) const
|
||||
{
|
||||
if (name == "input_fire_left")
|
||||
{
|
||||
@@ -646,7 +644,7 @@ void Input::allActive(int index)
|
||||
}
|
||||
|
||||
// Comprueba el eje del mando
|
||||
bool Input::checkAxisInput(inputs_e input, int index)
|
||||
bool Input::checkAxisInput(inputs_e input, int index) const
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ private:
|
||||
bool enabled; // Indica si está habilitado
|
||||
|
||||
// Comprueba el eje del mando
|
||||
bool checkAxisInput(inputs_e input, int index = 0);
|
||||
bool checkAxisInput(inputs_e input, int index = 0) const;
|
||||
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
@@ -144,10 +144,10 @@ public:
|
||||
bool gameControllerFound();
|
||||
|
||||
// Obten el número de mandos conectados
|
||||
int getNumControllers();
|
||||
int getNumControllers() const;
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string getControllerName(int index);
|
||||
std::string getControllerName(int index) const;
|
||||
|
||||
// Establece si ha de mostrar mensajes
|
||||
void setVerbose(bool value);
|
||||
@@ -159,22 +159,22 @@ public:
|
||||
void enable();
|
||||
|
||||
// Obtiene el indice del controlador a partir de un event.id
|
||||
int getJoyIndex(int id);
|
||||
int getJoyIndex(int id) const;
|
||||
|
||||
// Muestra por consola los controles asignados
|
||||
void printBindings(int device = INPUT_USE_KEYBOARD, int index = 0);
|
||||
void printBindings(int device = INPUT_USE_KEYBOARD, int index = 0) const;
|
||||
|
||||
// Obtiene el SDL_GameControllerButton asignado a un input
|
||||
SDL_GameControllerButton getControllerBinding(int index, inputs_e input);
|
||||
SDL_GameControllerButton getControllerBinding(int index, inputs_e input) const;
|
||||
|
||||
// Convierte un inputs_e a std::string
|
||||
std::string to_string(inputs_e input);
|
||||
std::string to_string(inputs_e input) const;
|
||||
|
||||
// Convierte un std::string a inputs_e
|
||||
inputs_e to_inputs_e(std::string name);
|
||||
inputs_e to_inputs_e(std::string name) const;
|
||||
|
||||
// Obtiene el indice a partir del nombre del mando
|
||||
int getIndexByName(std::string name);
|
||||
int getIndexByName(std::string name) const;
|
||||
|
||||
// Activa todos los inputs. Sirve para evitar inputs sin repeticiones pero que ya vienen pulsados cuando checkInput no estaba monitorizando
|
||||
void allActive(int index);
|
||||
|
||||
@@ -61,6 +61,7 @@ void initOptions()
|
||||
c.playerId = index + 1;
|
||||
c.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
c.name = "NO NAME";
|
||||
c.plugged = false;
|
||||
|
||||
// Inputs que se guardan en las opciones y, por tanto, a disco
|
||||
c.inputs.clear();
|
||||
|
||||
@@ -378,7 +378,8 @@ void Title::swapControllers()
|
||||
for (int i = 0; i < MAX_CONTROLLERS; ++i)
|
||||
{
|
||||
const int index = playerControllerIndex[i];
|
||||
if (options.controller[index].name != "NO NAME")
|
||||
//if (options.controller[index].name != "NO NAME")
|
||||
if (options.controller[index].plugged)
|
||||
{
|
||||
text[i] = "Jugador " + std::to_string(i + 1) + ": " + options.controller[index].name;
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ struct op_controller_t
|
||||
int playerId; // Jugador asociado al mando
|
||||
Uint8 deviceType; // Indica si se utilizará teclado o mando o ambos
|
||||
std::string name; // Nombre del dispositivo
|
||||
bool plugged; // Indica si el mando se encuentra conectado
|
||||
std::vector<inputs_e> inputs; // Listado de inputs
|
||||
std::vector<SDL_GameControllerButton> buttons; // Listado de botones asignados a cada input
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user