summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/configuration/config.cpp4
-rw-r--r--src/yuzu/configuration/configure_general.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.ui7
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp22
-rw-r--r--src/yuzu/configuration/configure_service.cpp2
-rw-r--r--src/yuzu/game_list.cpp8
-rw-r--r--src/yuzu/game_list_p.h9
-rw-r--r--src/yuzu/game_list_worker.cpp12
-rw-r--r--src/yuzu/game_list_worker.h5
-rw-r--r--src/yuzu/main.cpp42
-rw-r--r--src/yuzu/main.h3
-rw-r--r--src/yuzu/uisettings.h1
12 files changed, 94 insertions, 23 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 4cb27ddb2..f92a4b3c3 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -716,6 +716,8 @@ void Config::ReadUIValues() {
UISettings::values.callout_flags = ReadSetting(QStringLiteral("calloutFlags"), 0).toUInt();
UISettings::values.show_console = ReadSetting(QStringLiteral("showConsole"), false).toBool();
UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt();
+ UISettings::values.pause_when_in_background =
+ ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool();
ApplyDefaultProfileIfInputInvalid();
@@ -1124,6 +1126,8 @@ void Config::SaveUIValues() {
WriteSetting(QStringLiteral("calloutFlags"), UISettings::values.callout_flags, 0);
WriteSetting(QStringLiteral("showConsole"), UISettings::values.show_console, false);
WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0);
+ WriteSetting(QStringLiteral("pauseWhenInBackground"),
+ UISettings::values.pause_when_in_background, false);
qt_config->endGroup();
}
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index 98bc9b391..34e1d7fea 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -31,6 +31,7 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
+ ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked());
@@ -42,6 +43,7 @@ void ConfigureGeneral::ApplyConfiguration() {
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
UISettings::values.theme =
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
+ UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();
Settings::values.frame_limit = ui->frame_limit->value();
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index 0bb91d64b..26b3486ff 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -65,6 +65,13 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="toggle_background_pause">
+ <property name="text">
+ <string>Pause emulation when in background</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
</layout>
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index a968cfb5d..67c9a7c6d 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -245,10 +245,24 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
button->setContextMenuPolicy(Qt::CustomContextMenu);
connect(button, &QPushButton::clicked, [=] {
- HandleClick(
- button_map[button_id],
- [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; },
- InputCommon::Polling::DeviceType::Button);
+ HandleClick(button_map[button_id],
+ [=](Common::ParamPackage params) {
+ // Workaround for ZL & ZR for analog triggers like on XBOX controllors.
+ // Analog triggers (from controllers like the XBOX controller) would not
+ // work due to a different range of their signals (from 0 to 255 on
+ // analog triggers instead of -32768 to 32768 on analog joysticks). The
+ // SDL driver misinterprets analog triggers as analog joysticks.
+ // TODO: reinterpret the signal range for analog triggers to map the
+ // values correctly. This is required for the correct emulation of the
+ // analog triggers of the GameCube controller.
+ if (button_id == Settings::NativeButton::ZL ||
+ button_id == Settings::NativeButton::ZR) {
+ params.Set("direction", "+");
+ params.Set("threshold", "0.5");
+ }
+ buttons_param[button_id] = std::move(params);
+ },
+ InputCommon::Polling::DeviceType::Button);
});
connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
QMenu context_menu;
diff --git a/src/yuzu/configuration/configure_service.cpp b/src/yuzu/configuration/configure_service.cpp
index 81c9e933f..06566e981 100644
--- a/src/yuzu/configuration/configure_service.cpp
+++ b/src/yuzu/configuration/configure_service.cpp
@@ -73,6 +73,8 @@ std::pair<QString, QString> ConfigureService::BCATDownloadEvents() {
const auto res = Service::BCAT::Boxcat::GetStatus(global, map);
switch (res) {
+ case Service::BCAT::Boxcat::StatusResult::Success:
+ break;
case Service::BCAT::Boxcat::StatusResult::Offline:
return {QString{},
tr("The boxcat service is offline or you are not connected to the internet.")};
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index d5fab2f1f..a2b88c787 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -172,9 +172,7 @@ void GameList::onTextChanged(const QString& new_text) {
const int folder_count = tree_view->model()->rowCount();
QString edit_filter_text = new_text.toLower();
QStandardItem* folder;
- QStandardItem* child;
int children_total = 0;
- QModelIndex root_index = item_model->invisibleRootItem()->index();
// If the searchfield is empty every item is visible
// Otherwise the filter gets applied
@@ -272,6 +270,8 @@ void GameList::onUpdateThemedIcons() {
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
Qt::DecorationRole);
break;
+ default:
+ break;
}
}
}
@@ -392,6 +392,8 @@ void GameList::ValidateEntry(const QModelIndex& item) {
case GameListItemType::AddDir:
emit AddDirectory();
break;
+ default:
+ break;
}
}
@@ -462,6 +464,8 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
case GameListItemType::SysNandDir:
AddPermDirPopup(context_menu, selected);
break;
+ default:
+ break;
}
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
}
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h
index a8d888fee..1c2b37afd 100644
--- a/src/yuzu/game_list_p.h
+++ b/src/yuzu/game_list_p.h
@@ -247,7 +247,7 @@ public:
Qt::DecorationRole);
setData(QObject::tr("System Titles"), Qt::DisplayRole);
break;
- case GameListItemType::CustomDir:
+ case GameListItemType::CustomDir: {
const QString icon_name = QFileInfo::exists(game_dir->path)
? QStringLiteral("folder")
: QStringLiteral("bad_folder");
@@ -256,8 +256,11 @@ public:
Qt::DecorationRole);
setData(game_dir->path, Qt::DisplayRole);
break;
- };
- };
+ }
+ default:
+ break;
+ }
+ }
int type() const override {
return static_cast<int>(dir_type);
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index fd21a9761..4c81ef12b 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -326,10 +326,10 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
}
} else {
std::vector<u8> icon;
- const auto res1 = loader->ReadIcon(icon);
+ [[maybe_unused]] const auto res1 = loader->ReadIcon(icon);
std::string name = " ";
- const auto res3 = loader->ReadTitle(name);
+ [[maybe_unused]] const auto res3 = loader->ReadTitle(name);
const FileSys::PatchManager patch{program_id};
@@ -354,20 +354,20 @@ void GameListWorker::run() {
for (UISettings::GameDir& game_dir : game_dirs) {
if (game_dir.path == QStringLiteral("SDMC")) {
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
AddTitlesToGameList(game_list_dir);
} else if (game_dir.path == QStringLiteral("UserNAND")) {
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
AddTitlesToGameList(game_list_dir);
} else if (game_dir.path == QStringLiteral("SysNAND")) {
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
AddTitlesToGameList(game_list_dir);
} else {
watch_list.append(game_dir.path);
auto* const game_list_dir = new GameListDir(game_dir);
- emit DirEntryReady({game_list_dir});
+ emit DirEntryReady(game_list_dir);
provider->ClearAllEntries();
ScanFileSystem(ScanTarget::FillManualContentProvider, game_dir.path.toStdString(), 2,
game_list_dir);
diff --git a/src/yuzu/game_list_worker.h b/src/yuzu/game_list_worker.h
index 6e52fca89..84e4e1b42 100644
--- a/src/yuzu/game_list_worker.h
+++ b/src/yuzu/game_list_worker.h
@@ -75,8 +75,9 @@ private:
std::shared_ptr<FileSys::VfsFilesystem> vfs;
FileSys::ManualContentProvider* provider;
- QStringList watch_list;
- const CompatibilityList& compatibility_list;
QVector<UISettings::GameDir>& game_dirs;
+ const CompatibilityList& compatibility_list;
+
+ QStringList watch_list;
std::atomic_bool stop_processing;
};
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 2d82df739..d6bb18d24 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -675,6 +675,24 @@ void GMainWindow::RestoreUIState() {
Debugger::ToggleConsole();
}
+void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
+ if (!UISettings::values.pause_when_in_background) {
+ return;
+ }
+ if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive &&
+ state != Qt::ApplicationActive) {
+ LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state);
+ }
+ if (ui.action_Pause->isEnabled() &&
+ (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
+ auto_paused = true;
+ OnPauseGame();
+ } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) {
+ auto_paused = false;
+ OnStartGame();
+ }
+}
+
void GMainWindow::ConnectWidgetEvents() {
connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory);
@@ -1889,15 +1907,24 @@ void GMainWindow::OnCaptureScreenshot() {
}
void GMainWindow::UpdateWindowTitle(const QString& title_name) {
- const QString full_name = QString::fromUtf8(Common::g_build_fullname);
- const QString branch_name = QString::fromUtf8(Common::g_scm_branch);
- const QString description = QString::fromUtf8(Common::g_scm_desc);
+ const auto full_name = std::string(Common::g_build_fullname);
+ const auto branch_name = std::string(Common::g_scm_branch);
+ const auto description = std::string(Common::g_scm_desc);
+ const auto build_id = std::string(Common::g_build_id);
+
+ const auto date =
+ QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd")).toStdString();
if (title_name.isEmpty()) {
- setWindowTitle(QStringLiteral("yuzu %1| %2-%3").arg(full_name, branch_name, description));
+ const auto fmt = std::string(Common::g_title_bar_format_idle);
+ setWindowTitle(QString::fromStdString(fmt::format(fmt.empty() ? "yuzu {0}| {1}-{2}" : fmt,
+ full_name, branch_name, description,
+ std::string{}, date, build_id)));
} else {
- setWindowTitle(QStringLiteral("yuzu %1| %4 | %2-%3")
- .arg(full_name, branch_name, description, title_name));
+ const auto fmt = std::string(Common::g_title_bar_format_running);
+ setWindowTitle(QString::fromStdString(
+ fmt::format(fmt.empty() ? "yuzu {0}| {3} | {1}-{2}" : fmt, full_name, branch_name,
+ description, title_name.toStdString(), date, build_id)));
}
}
@@ -2311,6 +2338,9 @@ int main(int argc, char* argv[]) {
// After settings have been loaded by GMainWindow, apply the filter
main_window.show();
+ QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window,
+ &GMainWindow::OnAppFocusStateChanged);
+
Settings::LogSettings();
int result = app.exec();
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index e942d1248..fd4b9ccf5 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -119,6 +119,7 @@ public slots:
void SoftwareKeyboardGetText(const Core::Frontend::SoftwareKeyboardParameters& parameters);
void SoftwareKeyboardInvokeCheckDialog(std::u16string error_message);
void WebBrowserOpenPage(std::string_view filename, std::string_view arguments);
+ void OnAppFocusStateChanged(Qt::ApplicationState state);
private:
void InitializeWidgets();
@@ -244,6 +245,8 @@ private:
// The path to the game currently running
QString game_path;
+ bool auto_paused = false;
+
// FS
std::shared_ptr<FileSys::VfsFilesystem> vfs;
std::unique_ptr<FileSys::ManualContentProvider> provider;
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index a8eaf5f8c..bc7725a01 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -58,6 +58,7 @@ struct Values {
bool confirm_before_closing;
bool first_start;
+ bool pause_when_in_background;
bool select_user_on_boot;