Support for true fullscreen

This commit is contained in:
kalaposfos13 2025-01-02 11:16:03 +01:00
parent 8b66e9f78d
commit 0f336f6782
7 changed files with 67 additions and 9 deletions

View File

@ -33,6 +33,7 @@ namespace Config {
static bool isNeo = false; static bool isNeo = false;
static bool isFullscreen = false; static bool isFullscreen = false;
static std::string fullscreenMode = "borderless";
static bool playBGM = false; static bool playBGM = false;
static bool isTrophyPopupDisabled = false; static bool isTrophyPopupDisabled = false;
static int BGMvolume = 50; static int BGMvolume = 50;
@ -104,10 +105,14 @@ bool isNeoMode() {
return isNeo; return isNeo;
} }
bool isFullscreenMode() { bool getIsFullscreen() {
return isFullscreen; return isFullscreen;
} }
std::string getFullscreenMode() {
return fullscreenMode;
}
bool getisTrophyPopupDisabled() { bool getisTrophyPopupDisabled() {
return isTrophyPopupDisabled; return isTrophyPopupDisabled;
} }
@ -304,10 +309,14 @@ void setVblankDiv(u32 value) {
vblankDivider = value; vblankDivider = value;
} }
void setFullscreenMode(bool enable) { void setIsFullscreen(bool enable) {
isFullscreen = enable; isFullscreen = enable;
} }
void setFullscreenMode(std::string mode) {
fullscreenMode = mode;
}
void setisTrophyPopupDisabled(bool disable) { void setisTrophyPopupDisabled(bool disable) {
isTrophyPopupDisabled = disable; isTrophyPopupDisabled = disable;
} }
@ -566,6 +575,7 @@ void load(const std::filesystem::path& path) {
isNeo = toml::find_or<bool>(general, "isPS4Pro", false); isNeo = toml::find_or<bool>(general, "isPS4Pro", false);
isFullscreen = toml::find_or<bool>(general, "Fullscreen", false); isFullscreen = toml::find_or<bool>(general, "Fullscreen", false);
fullscreenMode = toml::find_or<std::string>(general, "FullscreenMode", "borderless");
playBGM = toml::find_or<bool>(general, "playBGM", false); playBGM = toml::find_or<bool>(general, "playBGM", false);
isTrophyPopupDisabled = toml::find_or<bool>(general, "isTrophyPopupDisabled", false); isTrophyPopupDisabled = toml::find_or<bool>(general, "isTrophyPopupDisabled", false);
BGMvolume = toml::find_or<int>(general, "BGMvolume", 50); BGMvolume = toml::find_or<int>(general, "BGMvolume", 50);
@ -691,6 +701,7 @@ void save(const std::filesystem::path& path) {
data["General"]["isPS4Pro"] = isNeo; data["General"]["isPS4Pro"] = isNeo;
data["General"]["Fullscreen"] = isFullscreen; data["General"]["Fullscreen"] = isFullscreen;
data["General"]["FullscreenMode"] = fullscreenMode;
data["General"]["isTrophyPopupDisabled"] = isTrophyPopupDisabled; data["General"]["isTrophyPopupDisabled"] = isTrophyPopupDisabled;
data["General"]["playBGM"] = playBGM; data["General"]["playBGM"] = playBGM;
data["General"]["BGMvolume"] = BGMvolume; data["General"]["BGMvolume"] = BGMvolume;

View File

@ -19,7 +19,8 @@ std::string getTrophyKey();
void setTrophyKey(std::string key); void setTrophyKey(std::string key);
bool isNeoMode(); bool isNeoMode();
bool isFullscreenMode(); bool getIsFullscreen();
std::string getFullscreenMode();
bool getPlayBGM(); bool getPlayBGM();
int getBGMvolume(); int getBGMvolume();
bool getisTrophyPopupDisabled(); bool getisTrophyPopupDisabled();
@ -65,7 +66,8 @@ void setVblankDiv(u32 value);
void setGpuId(s32 selectedGpuId); void setGpuId(s32 selectedGpuId);
void setScreenWidth(u32 width); void setScreenWidth(u32 width);
void setScreenHeight(u32 height); void setScreenHeight(u32 height);
void setFullscreenMode(bool enable); void setIsFullscreen(bool enable);
void setFullscreenMode(std::string mode);
void setisTrophyPopupDisabled(bool disable); void setisTrophyPopupDisabled(bool disable);
void setPlayBGM(bool enable); void setPlayBGM(bool enable);
void setBGMvolume(int volume); void setBGMvolume(int volume);

View File

@ -86,7 +86,7 @@ int main(int argc, char* argv[]) {
exit(1); exit(1);
} }
// Set fullscreen mode without saving it to config file // Set fullscreen mode without saving it to config file
Config::setFullscreenMode(is_fullscreen); Config::setIsFullscreen(is_fullscreen);
}}, }},
{"--fullscreen", [&](int& i) { arg_map["-f"](i); }}, {"--fullscreen", [&](int& i) { arg_map["-f"](i); }},
{"--add-game-folder", {"--add-game-folder",

View File

@ -97,7 +97,7 @@ int main(int argc, char* argv[]) {
exit(1); exit(1);
} }
// Set fullscreen mode without saving it to config file // Set fullscreen mode without saving it to config file
Config::setFullscreenMode(is_fullscreen); Config::setIsFullscreen(is_fullscreen);
}}, }},
{"--fullscreen", [&](int& i) { arg_map["-f"](i); }}, {"--fullscreen", [&](int& i) { arg_map["-f"](i); }},
{"--add-game-folder", {"--add-game-folder",

View File

@ -300,6 +300,8 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->discordRPCCheckbox->setChecked( ui->discordRPCCheckbox->setChecked(
toml::find_or<bool>(data, "General", "enableDiscordRPC", true)); toml::find_or<bool>(data, "General", "enableDiscordRPC", true));
ui->fullscreenCheckBox->setChecked(toml::find_or<bool>(data, "General", "Fullscreen", false)); ui->fullscreenCheckBox->setChecked(toml::find_or<bool>(data, "General", "Fullscreen", false));
ui->fullscreenModeComboBox->setCurrentText(
QString::fromStdString(toml::find_or<std::string>(data, "General", "FullscreenMode", "Borderless")));
ui->separateUpdatesCheckBox->setChecked( ui->separateUpdatesCheckBox->setChecked(
toml::find_or<bool>(data, "General", "separateUpdateEnabled", false)); toml::find_or<bool>(data, "General", "separateUpdateEnabled", false));
ui->showSplashCheckBox->setChecked(toml::find_or<bool>(data, "General", "showSplash", false)); ui->showSplashCheckBox->setChecked(toml::find_or<bool>(data, "General", "showSplash", false));
@ -532,7 +534,8 @@ void SettingsDialog::UpdateSettings() {
const QVector<std::string> TouchPadIndex = {"left", "center", "right", "none"}; const QVector<std::string> TouchPadIndex = {"left", "center", "right", "none"};
Config::setBackButtonBehavior(TouchPadIndex[ui->backButtonBehaviorComboBox->currentIndex()]); Config::setBackButtonBehavior(TouchPadIndex[ui->backButtonBehaviorComboBox->currentIndex()]);
Config::setFullscreenMode(ui->fullscreenCheckBox->isChecked()); Config::setIsFullscreen(ui->fullscreenCheckBox->isChecked());
Config::setFullscreenMode(ui->fullscreenModeComboBox->currentText().toStdString());
Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked()); Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked());
Config::setPlayBGM(ui->playBGMCheckBox->isChecked()); Config::setPlayBGM(ui->playBGMCheckBox->isChecked());
Config::setLogType(ui->logTypeComboBox->currentText().toStdString()); Config::setLogType(ui->logTypeComboBox->currentText().toStdString());

View File

@ -133,6 +133,35 @@
<string>Enable Fullscreen</string> <string>Enable Fullscreen</string>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QGroupBox" name="fullscreenModeGroupBox">
<property name="title">
<string>Fullscreen Mode</string>
</property>
<layout class="QVBoxLayout" name="fullscreenModeLayout">
<item>
<widget class="QComboBox" name="fullscreenModeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Borderless</string>
</property>
</item>
<item>
<property name="text">
<string>True</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="separateUpdatesCheckBox"> <widget class="QCheckBox" name="separateUpdatesCheckBox">

View File

@ -92,8 +92,21 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_
UNREACHABLE_MSG("Failed to create window handle: {}", SDL_GetError()); UNREACHABLE_MSG("Failed to create window handle: {}", SDL_GetError());
} }
SDL_SetWindowMinimumSize(window, 640, 360); bool error = false;
SDL_SetWindowFullscreen(window, Config::isFullscreenMode()); const SDL_DisplayID displayIndex = SDL_GetDisplayForWindow(window);
if (displayIndex < 0) {
LOG_ERROR(Frontend, "Error getting display index: {}", SDL_GetError());
error = true;
}
const SDL_DisplayMode* displayMode;
if ((displayMode = SDL_GetCurrentDisplayMode(displayIndex)) == 0) {
LOG_ERROR(Frontend, "Error getting display mode: {}", SDL_GetError());
error = true;
}
if (!error) {
SDL_SetWindowFullscreenMode(window, Config::getFullscreenMode() == "True" ? displayMode : NULL);
}
SDL_SetWindowFullscreen(window, Config::getIsFullscreen());
SDL_InitSubSystem(SDL_INIT_GAMEPAD); SDL_InitSubSystem(SDL_INIT_GAMEPAD);
controller->TryOpenSDLController(); controller->TryOpenSDLController();