permet escollir driver de gpu o no escollir-ne cap
This commit is contained in:
@@ -72,6 +72,7 @@ static void printHelp() {
|
||||
SDL_Log(" UPSCALE [NEAREST|LINEAR] SS upscale filter (toggle if no arg)");
|
||||
SDL_Log(" DOWNSCALE [BILINEAR|LANCZOS2|LANCZOS3] SS downscale algorithm");
|
||||
SDL_Log(" VSYNC [ON|OFF] Vertical sync");
|
||||
SDL_Log(" DRIVER [LIST|AUTO|NONE|<name>] GPU driver (restart to apply)");
|
||||
SDL_Log(" PALETTE [NEXT|PREV] Color palette (F5/F6)");
|
||||
#ifdef _DEBUG
|
||||
SDL_Log(" DEBUG Toggle debug overlay (F12)");
|
||||
@@ -215,6 +216,62 @@ static const std::vector<ConsoleCommand> COMMANDS = {
|
||||
Options::video.vertical_sync,
|
||||
Screen::get()->toggleVSync())},
|
||||
|
||||
// DRIVER [LIST|AUTO|<nombre>] — Driver GPU (aplica en el próximo arranque)
|
||||
{.keyword = "DRIVER", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||
// Sin argumentos: muestra el driver activo (permitido en kiosk)
|
||||
if (args.empty()) {
|
||||
const auto& driver = Screen::get()->getGPUDriver();
|
||||
return "GPU: " + (driver.empty() ? std::string("sdl") : driver);
|
||||
}
|
||||
// LIST: lista drivers disponibles marcando el activo con * (permitido en kiosk)
|
||||
if (args[0] == "LIST") {
|
||||
const int COUNT = SDL_GetNumGPUDrivers();
|
||||
if (COUNT <= 0) { return "No GPU drivers found"; }
|
||||
const std::string& active = Screen::get()->getGPUDriver();
|
||||
std::string result = "Drivers:";
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
const char* name = SDL_GetGPUDriver(i);
|
||||
if (name != nullptr) {
|
||||
result += ' ';
|
||||
result += name;
|
||||
if (active == name) { result += '*'; }
|
||||
}
|
||||
}
|
||||
SDL_Log("SDL GPU drivers: %s", result.c_str());
|
||||
return result;
|
||||
}
|
||||
// Cambiar driver: bloqueado en kiosk salvo PLEASE
|
||||
const bool HAS_PLEASE = std::ranges::find(args, std::string("PLEASE")) != args.end();
|
||||
if (Options::kiosk.enabled && !HAS_PLEASE) {
|
||||
return "Not allowed in kiosk mode";
|
||||
}
|
||||
if (args[0] == "AUTO") {
|
||||
Options::video.gpu_preferred_driver.clear();
|
||||
Options::saveToFile();
|
||||
return "Driver: auto (restart)";
|
||||
}
|
||||
if (args[0] == "NONE") {
|
||||
Options::video.gpu_preferred_driver = "none";
|
||||
Options::saveToFile();
|
||||
return "Driver: none (SDL fallback, restart)";
|
||||
}
|
||||
std::string driver_lower = args[0];
|
||||
std::ranges::transform(driver_lower, driver_lower.begin(), ::tolower);
|
||||
// Validar que el nombre existe en la lista de drivers SDL
|
||||
const int COUNT = SDL_GetNumGPUDrivers();
|
||||
bool found = false;
|
||||
for (int i = 0; i < COUNT && !found; ++i) {
|
||||
const char* name = SDL_GetGPUDriver(i);
|
||||
if (name != nullptr && driver_lower == name) { found = true; }
|
||||
}
|
||||
if (!found) {
|
||||
return "Unknown driver: " + driver_lower + ". Use DRIVER LIST or NONE";
|
||||
}
|
||||
Options::video.gpu_preferred_driver = driver_lower;
|
||||
Options::saveToFile();
|
||||
return "Driver: " + driver_lower + " (restart)";
|
||||
}},
|
||||
|
||||
// PALETTE NEXT/PREV — Paleta de colores (F5/F6)
|
||||
{.keyword = "PALETTE", .execute = [](const std::vector<std::string>& args) -> std::string {
|
||||
if (args.empty()) { return "Usage: PALETTE [NEXT|PREV]"; }
|
||||
|
||||
Reference in New Issue
Block a user