Service Menu: afegides opcions per als mandos

This commit is contained in:
2025-08-05 13:12:48 +02:00
parent 12e3226f17
commit 3bb5e5d604
7 changed files with 89 additions and 4 deletions

View File

@@ -138,6 +138,15 @@ auto Input::gameControllerFound() const -> bool { return !gamepads_.empty(); }
// Obten el nombre de un mando de juego
auto Input::getControllerName(std::shared_ptr<Gamepad> gamepad) const -> std::string { return gamepad == nullptr ? std::string() : gamepad->name; }
// Obtiene la lista de nombres de mandos
auto Input::getControllerNames() const -> std::vector<std::string> {
std::vector<std::string> names;
for (const auto &gamepad : gamepads_) {
names.push_back(gamepad->name);
}
return names;
}
// Obten el número de mandos conectados
auto Input::getNumGamepads() const -> int { return gamepads_.size(); }
@@ -151,6 +160,15 @@ std::shared_ptr<Input::Gamepad> Input::getGamepad(SDL_JoystickID id) const {
return nullptr;
}
std::shared_ptr<Input::Gamepad> Input::getGamepadByName(const std::string &name) const {
for (const auto &gamepad : gamepads_) {
if (gamepad && gamepad->name == name) {
return gamepad;
}
}
return nullptr;
}
// Obtiene el SDL_GamepadButton asignado a un input
auto Input::getControllerBinding(std::shared_ptr<Gamepad> gamepad, Action input) const -> SDL_GamepadButton {
return gamepad->bindings[input].button;