feat(input): carrega gamecontrollerdb i corregeix l'ordre d'assignació de mandos
This commit is contained in:
1 parent
4f1a3260a5
commit
c77f90f6b6
5 files changed
+2276
-16
No files matched your search
@@ -150,10 +150,15 @@ void GamepadManager::init() {
|
||||
return;
|
||||
}
|
||||
// `gamecontrollerdb.txt` és opcional. Si no existeix, SDL retorna -1 i
|
||||
// continuem amb les definicions internes del sistema.
|
||||
const int ADDED = SDL_AddGamepadMappingsFromFile("data/input/gamecontrollerdb.txt");
|
||||
if (ADDED > 0) {
|
||||
std::cout << "GamepadManager: " << ADDED << " mappings de gamecontrollerdb.txt\n";
|
||||
// continuem amb les definicions internes del sistema. Sempre informem
|
||||
// del resultat per facilitar el diagnòstic de mandos no reconeguts.
|
||||
static constexpr const char* DB_PATH = "data/input/gamecontrollerdb.txt";
|
||||
const int ADDED = SDL_AddGamepadMappingsFromFile(DB_PATH);
|
||||
if (ADDED < 0) {
|
||||
std::cout << "GamepadManager: no s'ha pogut carregar " << DB_PATH
|
||||
<< ": " << SDL_GetError() << '\n';
|
||||
} else {
|
||||
std::cout << "GamepadManager: " << ADDED << " mappings carregats de " << DB_PATH << '\n';
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
@@ -164,6 +169,7 @@ void GamepadManager::init() {
|
||||
}
|
||||
SDL_free(ids);
|
||||
}
|
||||
std::cout << "GamepadManager: " << entries_.size() << " mando(s) detectat(s) a l'inici\n";
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
@@ -262,6 +268,15 @@ void GamepadManager::assignToPlayer(int player_id, const std::string& name, cons
|
||||
}
|
||||
}
|
||||
}
|
||||
// Traç de l'assignació persistida (vinculada o pendent) perquè quede
|
||||
// visible a la consola igual que les autoassignacions.
|
||||
if (a.pad != nullptr) {
|
||||
std::cout << "GamepadManager: assignat " << a.name
|
||||
<< " → P" << (player_id + 1) << '\n';
|
||||
} else {
|
||||
std::cout << "GamepadManager: P" << (player_id + 1) << " pendent ("
|
||||
<< (a.name.empty() ? a.path : a.name) << " no connectat)\n";
|
||||
}
|
||||
}
|
||||
|
||||
void GamepadManager::unassignFromPlayer(int player_id) {
|
||||
|
||||
Reference in new issue
Block a user