diff --git a/src/common/config.cpp b/src/common/config.cpp index 1838f35f..b46ab8d6 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -33,6 +33,7 @@ namespace Config { static bool isNeo = false; static bool isFullscreen = false; +static std::string fullscreenMode = "borderless"; static bool playBGM = false; static bool isTrophyPopupDisabled = false; static int BGMvolume = 50; @@ -105,10 +106,14 @@ bool isNeoModeConsole() { return isNeo; } -bool isFullscreenMode() { +bool getIsFullscreen() { return isFullscreen; } +std::string getFullscreenMode() { + return fullscreenMode; +} + bool getisTrophyPopupDisabled() { return isTrophyPopupDisabled; } @@ -309,10 +314,14 @@ void setVblankDiv(u32 value) { vblankDivider = value; } -void setFullscreenMode(bool enable) { +void setIsFullscreen(bool enable) { isFullscreen = enable; } +void setFullscreenMode(std::string mode) { + fullscreenMode = mode; +} + void setisTrophyPopupDisabled(bool disable) { isTrophyPopupDisabled = disable; } @@ -575,6 +584,7 @@ void load(const std::filesystem::path& path) { isNeo = toml::find_or(general, "isPS4Pro", false); isFullscreen = toml::find_or(general, "Fullscreen", false); + fullscreenMode = toml::find_or(general, "FullscreenMode", "borderless"); playBGM = toml::find_or(general, "playBGM", false); isTrophyPopupDisabled = toml::find_or(general, "isTrophyPopupDisabled", false); BGMvolume = toml::find_or(general, "BGMvolume", 50); @@ -701,6 +711,7 @@ void save(const std::filesystem::path& path) { data["General"]["isPS4Pro"] = isNeo; data["General"]["Fullscreen"] = isFullscreen; + data["General"]["FullscreenMode"] = fullscreenMode; data["General"]["isTrophyPopupDisabled"] = isTrophyPopupDisabled; data["General"]["playBGM"] = playBGM; data["General"]["BGMvolume"] = BGMvolume; diff --git a/src/common/config.h b/src/common/config.h index d2860bec..6e6a5d96 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -17,9 +17,9 @@ void saveMainWindow(const std::filesystem::path& path); std::string getTrophyKey(); void setTrophyKey(std::string key); - +bool getIsFullscreen(); +std::string getFullscreenMode(); bool isNeoModeConsole(); -bool isFullscreenMode(); bool getPlayBGM(); int getBGMvolume(); bool getisTrophyPopupDisabled(); @@ -66,7 +66,8 @@ void setVblankDiv(u32 value); void setGpuId(s32 selectedGpuId); void setScreenWidth(u32 width); void setScreenHeight(u32 height); -void setFullscreenMode(bool enable); +void setIsFullscreen(bool enable); +void setFullscreenMode(std::string mode); void setisTrophyPopupDisabled(bool disable); void setPlayBGM(bool enable); void setBGMvolume(int volume); diff --git a/src/main.cpp b/src/main.cpp index bdbab89c..54772870 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,7 +86,7 @@ int main(int argc, char* argv[]) { exit(1); } // Set fullscreen mode without saving it to config file - Config::setFullscreenMode(is_fullscreen); + Config::setIsFullscreen(is_fullscreen); }}, {"--fullscreen", [&](int& i) { arg_map["-f"](i); }}, {"--add-game-folder", diff --git a/src/qt_gui/main.cpp b/src/qt_gui/main.cpp index ac731fdc..2d524e19 100644 --- a/src/qt_gui/main.cpp +++ b/src/qt_gui/main.cpp @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) { exit(1); } // Set fullscreen mode without saving it to config file - Config::setFullscreenMode(is_fullscreen); + Config::setIsFullscreen(is_fullscreen); }}, {"--fullscreen", [&](int& i) { arg_map["-f"](i); }}, {"--add-game-folder", @@ -190,4 +190,4 @@ int main(int argc, char* argv[]) { // Show the main window and run the Qt application m_main_window->show(); return a.exec(); -} \ No newline at end of file +} diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index 1a03345e..193ce5cd 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -300,6 +300,8 @@ void SettingsDialog::LoadValuesFromConfig() { ui->discordRPCCheckbox->setChecked( toml::find_or(data, "General", "enableDiscordRPC", true)); ui->fullscreenCheckBox->setChecked(toml::find_or(data, "General", "Fullscreen", false)); + ui->fullscreenModeComboBox->setCurrentText(QString::fromStdString( + toml::find_or(data, "General", "FullscreenMode", "Borderless"))); ui->separateUpdatesCheckBox->setChecked( toml::find_or(data, "General", "separateUpdateEnabled", false)); ui->showSplashCheckBox->setChecked(toml::find_or(data, "General", "showSplash", false)); @@ -534,8 +536,9 @@ void SettingsDialog::UpdateSettings() { const QVector TouchPadIndex = {"left", "center", "right", "none"}; Config::setBackButtonBehavior(TouchPadIndex[ui->backButtonBehaviorComboBox->currentIndex()]); + Config::setIsFullscreen(ui->fullscreenCheckBox->isChecked()); + Config::setFullscreenMode(ui->fullscreenModeComboBox->currentText().toStdString()); Config::setIsMotionControlsEnabled(ui->motionControlsCheckBox->isChecked()); - Config::setFullscreenMode(ui->fullscreenCheckBox->isChecked()); Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked()); Config::setPlayBGM(ui->playBGMCheckBox->isChecked()); Config::setLogType(ui->logTypeComboBox->currentText().toStdString()); diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index cefe1f7c..fbfee5a9 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -12,7 +12,7 @@ 0 0 970 - 670 + 750 @@ -133,6 +133,35 @@ Enable Fullscreen + + + + + Fullscreen Mode + + + + + + + 0 + 0 + + + + + Borderless + + + + + True + + + + + + @@ -536,6 +565,9 @@ 0 + + 80 + @@ -566,6 +598,12 @@ 0 + + + 10 + false + + diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index d694b093..318b3349 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -93,7 +93,23 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_ } SDL_SetWindowMinimumSize(window, 640, 360); - SDL_SetWindowFullscreen(window, Config::isFullscreenMode()); + + bool error = false; + 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); controller->TryOpenSDLController();