make controllerdb

nom del mando trimmed
This commit is contained in:
2026-04-15 16:16:49 +02:00
parent f9b0f64b81
commit 517bc2caa1
2 changed files with 28 additions and 3 deletions

View File

@@ -155,11 +155,20 @@ bool Input::checkAnyInput(int device, int index) {
return false;
}
// Construye el nombre visible de un mando
// Construye el nombre visible de un mando.
// Recorta des del primer '(' o '[' (per a evitar coses tipus
// "Retroid Controller (vendor: 1001) ...") i talla a 25 caràcters.
std::string Input::buildControllerName(SDL_Gamepad *pad, int padIndex) {
(void)padIndex;
const char *padName = SDL_GetGamepadName(pad);
std::string name = padName ? padName : "Unknown";
const auto pos = name.find_first_of("([");
if (pos != std::string::npos) {
name.erase(pos);
}
while (!name.empty() && name.back() == ' ') {
name.pop_back();
}
if (name.size() > 25) {
name.resize(25);
}