migrant input: ja es poden redefinir els botons. Falta rebindar les accions a accions
This commit is contained in:
@@ -141,14 +141,14 @@ auto Input::getControllerName(std::shared_ptr<Gamepad> gamepad) const -> std::st
|
||||
// Obten el número de mandos conectados
|
||||
auto Input::getNumGamepads() const -> int { return gamepads_.size(); }
|
||||
|
||||
// Obtiene el indice del controlador a partir de un event.id
|
||||
auto Input::getJoyIndex(SDL_JoystickID id) const -> int {
|
||||
// for (int i = 0; i < num_joysticks_; ++i) {
|
||||
// if (SDL_GetJoystickID(joysticks_[i]) == id) {
|
||||
// return i;
|
||||
// }
|
||||
// }
|
||||
return -1;
|
||||
// Obtiene el gamepad a partir de un event.id
|
||||
std::shared_ptr<Input::Gamepad> Input::getGamepad(SDL_JoystickID id) const {
|
||||
for (const auto& gamepad : gamepads_) {
|
||||
if (gamepad->instance_id == id) {
|
||||
return gamepad;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Obtiene el SDL_GamepadButton asignado a un input
|
||||
@@ -437,27 +437,26 @@ bool Input::removeGamepadConfig(const std::string &gamepadName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Input::Gamepad> Input::findAvailableGamepadByName(const std::string &gamepad_name)
|
||||
{
|
||||
std::shared_ptr<Input::Gamepad> Input::findAvailableGamepadByName(const std::string &gamepad_name) {
|
||||
// Si no hay gamepads disponibles, devolver gamepad por defecto
|
||||
if (gamepads_.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Buscar por nombre
|
||||
for (const auto& gamepad : gamepads_) {
|
||||
for (const auto &gamepad : gamepads_) {
|
||||
if (gamepad && gamepad->name == gamepad_name) {
|
||||
return gamepad;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Si no se encuentra por nombre, devolver el primer gamepad válido
|
||||
for (const auto& gamepad : gamepads_) {
|
||||
for (const auto &gamepad : gamepads_) {
|
||||
if (gamepad) {
|
||||
return gamepad;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Si llegamos aquí, no hay gamepads válidos
|
||||
return nullptr;
|
||||
}
|
||||
Reference in New Issue
Block a user