Service Menu: afegides opcions per als mandos
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user