Add support for true fullscreen (#2016)

* Support for true fullscreen

* clang

* Re-add mistakenly deleted line

* Size

I adjusted the size of the entire screen.
trophies font size and added a margin so it wouldn't be so spaced out.

---------

Co-authored-by: DanielSvoboda <daniel.svoboda@hotmail.com>
This commit is contained in:
kalaposfos13 2025-01-07 14:30:05 +01:00 committed by GitHub
parent 32fc983ef8
commit 4df0d9c035
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 80 additions and 11 deletions

View file

@ -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<bool>(general, "isPS4Pro", 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);
isTrophyPopupDisabled = toml::find_or<bool>(general, "isTrophyPopupDisabled", false);
BGMvolume = toml::find_or<int>(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;

View file

@ -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);

View file

@ -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",

View file

@ -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();
}
}

View file

@ -300,6 +300,8 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->discordRPCCheckbox->setChecked(
toml::find_or<bool>(data, "General", "enableDiscordRPC", true));
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(
toml::find_or<bool>(data, "General", "separateUpdateEnabled", false));
ui->showSplashCheckBox->setChecked(toml::find_or<bool>(data, "General", "showSplash", false));
@ -534,8 +536,9 @@ void SettingsDialog::UpdateSettings() {
const QVector<std::string> 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());

View file

@ -12,7 +12,7 @@
<x>0</x>
<y>0</y>
<width>970</width>
<height>670</height>
<height>750</height>
</rect>
</property>
<property name="sizePolicy">
@ -133,6 +133,35 @@
<string>Enable Fullscreen</string>
</property>
</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>
<widget class="QCheckBox" name="separateUpdatesCheckBox">
@ -536,6 +565,9 @@
<property name="leftMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>80</number>
</property>
<item>
<layout class="QHBoxLayout" name="hLayoutTrophy">
<item>
@ -566,6 +598,12 @@
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<bold>false</bold>
</font>
</property>
</widget>
</item>
</layout>

View file

@ -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();