mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
Avoid game list rescans on settings changes/Remove Space pause shortcut
This commit is contained in:
@@ -141,9 +141,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool reserved = binding.key == SDLK_ESCAPE || binding.key == SDLK_SPACE ||
|
const bool reserved = binding.key == SDLK_ESCAPE || binding.key == SDLK_F1 ||
|
||||||
binding.key == SDLK_F1 || binding.key == SDLK_F7 ||
|
binding.key == SDLK_F7 || binding.key == SDLK_F11;
|
||||||
binding.key == SDLK_F11;
|
|
||||||
if (binding.control == INVALID_CONTROL || reserved ||
|
if (binding.control == INVALID_CONTROL || reserved ||
|
||||||
(binding.key == SDLK_UNKNOWN && binding.mouse_button == 0)) {
|
(binding.key == SDLK_UNKNOWN && binding.mouse_button == 0)) {
|
||||||
EXIT("Invalid input mapping: %s\n", value.c_str());
|
EXIT("Invalid input mapping: %s\n", value.c_str());
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ static void ToggleDesktopFullscreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GameEventKeyboard(WindowLoopState& game, const EventKeyboard& key) {
|
static void GameEventKeyboard(const EventKeyboard& key) {
|
||||||
static SDL_Keycode fullscreen_key = SDLK_UNKNOWN;
|
static SDL_Keycode fullscreen_key = SDLK_UNKNOWN;
|
||||||
|
|
||||||
#ifdef KYTY_DBG_INPUT
|
#ifdef KYTY_DBG_INPUT
|
||||||
@@ -235,7 +235,6 @@ static void GameEventKeyboard(WindowLoopState& game, const EventKeyboard& key) {
|
|||||||
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS || KYTY_PLATFORM == KYTY_PLATFORM_LINUX
|
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS || KYTY_PLATFORM == KYTY_PLATFORM_LINUX
|
||||||
if (key.down) {
|
if (key.down) {
|
||||||
switch (key.key_code) {
|
switch (key.key_code) {
|
||||||
case SDLK_SPACE: SetPause(game, !game.paused.load(std::memory_order_acquire)); break;
|
|
||||||
case SDLK_F1:
|
case SDLK_F1:
|
||||||
if (!key.repeat) {
|
if (!key.repeat) {
|
||||||
RenderDocRequestCapture();
|
RenderDocRequestCapture();
|
||||||
@@ -539,7 +538,7 @@ void WindowContext::ProcessEvent(double time_s) {
|
|||||||
key.mod = event->key.keysym.mod;
|
key.mod = event->key.keysym.mod;
|
||||||
key.timestamp_seconds = time_s;
|
key.timestamp_seconds = time_s;
|
||||||
|
|
||||||
GameEventKeyboard(game, key);
|
GameEventKeyboard(key);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public:
|
|||||||
host_input_mapping = other.host_input_mapping;
|
host_input_mapping = other.host_input_mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyFrom(const Configuration& other) {
|
void CopyGameInfoFrom(const Configuration& other) {
|
||||||
name = other.name;
|
name = other.name;
|
||||||
title_id = other.title_id;
|
title_id = other.title_id;
|
||||||
gameVersion = other.gameVersion;
|
gameVersion = other.gameVersion;
|
||||||
@@ -154,8 +154,6 @@ public:
|
|||||||
custom_settings = other.custom_settings;
|
custom_settings = other.custom_settings;
|
||||||
game_status = other.game_status;
|
game_status = other.game_status;
|
||||||
game_comment = other.game_comment;
|
game_comment = other.game_comment;
|
||||||
CopyEmulatorSettingsFrom(other);
|
|
||||||
elf = other.elf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteSettings(QSettings* s) const {
|
void WriteSettings(QSettings* s) const {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class ConfigurationItem;
|
class ConfigurationItem;
|
||||||
class CompatibilityDatabase;
|
class CompatibilityDatabase;
|
||||||
class QEvent;
|
class QEvent;
|
||||||
@@ -30,10 +32,9 @@ public:
|
|||||||
[[nodiscard]] const ConfigurationItem* GetSelectedItem() const { return m_selected_item; }
|
[[nodiscard]] const ConfigurationItem* GetSelectedItem() const { return m_selected_item; }
|
||||||
ConfigurationItem* GetSelectedItem() { return m_selected_item; }
|
ConfigurationItem* GetSelectedItem() { return m_selected_item; }
|
||||||
|
|
||||||
[[nodiscard]] const QString& GetSettingsFile() const { return m_settings_file; }
|
[[nodiscard]] const QString& GetSettingsFile() const { return m_settings_file; }
|
||||||
[[nodiscard]] const QStringList& GetHostInputMapping() const {
|
[[nodiscard]] std::unique_ptr<Configuration>
|
||||||
return m_global_info.host_input_mapping;
|
CreateConfiguration(const ConfigurationItem& item) const;
|
||||||
}
|
|
||||||
|
|
||||||
bool EnsureGameDirectory();
|
bool EnsureGameDirectory();
|
||||||
void ScanGameDirectory();
|
void ScanGameDirectory();
|
||||||
@@ -64,7 +65,6 @@ protected slots:
|
|||||||
void filter_configurations(const QString& text);
|
void filter_configurations(const QString& text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClearCustomSettings(ConfigurationItem* item);
|
|
||||||
void SelectItem(QTreeWidgetItem* witem);
|
void SelectItem(QTreeWidgetItem* witem);
|
||||||
void ApplyCompatibility();
|
void ApplyCompatibility();
|
||||||
void UpdateToolbarIcons();
|
void UpdateToolbarIcons();
|
||||||
|
|||||||
@@ -410,10 +410,17 @@ void ConfigurationListWidget::ApplyCompatibility() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Configuration* CloneConfiguration(const Configuration& source) {
|
std::unique_ptr<Configuration>
|
||||||
auto* ret = new Configuration;
|
ConfigurationListWidget::CreateConfiguration(const ConfigurationItem& item) const {
|
||||||
ret->CopyFrom(source);
|
auto info = std::make_unique<Configuration>();
|
||||||
return ret;
|
const auto* custom = m_custom_infos.value(item.GetInfo().game_path);
|
||||||
|
info->CopyGameInfoFrom(item.GetInfo());
|
||||||
|
info->CopyEmulatorSettingsFrom(custom != nullptr ? *custom : m_global_info);
|
||||||
|
if (custom != nullptr && !custom->elf.isEmpty()) {
|
||||||
|
info->elf = custom->elf;
|
||||||
|
}
|
||||||
|
info->host_input_mapping = m_global_info.host_input_mapping;
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GameMetadata {
|
struct GameMetadata {
|
||||||
@@ -528,9 +535,6 @@ static void SetGameFiles(Configuration& info, const QString& game_dir, const QSt
|
|||||||
if (info.name.isEmpty()) {
|
if (info.name.isEmpty()) {
|
||||||
info.name = game.dirName();
|
info.name = game.dirName();
|
||||||
}
|
}
|
||||||
if (info.elf.isEmpty()) {
|
|
||||||
info.elf = QStringLiteral("eboot.bin");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Configuration* FindCustomInfo(QMap<QString, Configuration*>* custom_infos,
|
static Configuration* FindCustomInfo(QMap<QString, Configuration*>* custom_infos,
|
||||||
@@ -634,16 +638,9 @@ void ConfigurationListWidget::ScanGameDirectory() {
|
|||||||
auto metadata = GetGameMetadata(
|
auto metadata = GetGameMetadata(
|
||||||
game_dir.filePath(QStringLiteral("sce_sys/param.json")), game_dir.dirName());
|
game_dir.filePath(QStringLiteral("sce_sys/param.json")), game_dir.dirName());
|
||||||
|
|
||||||
auto info = std::make_unique<Configuration>();
|
auto info = std::make_unique<Configuration>();
|
||||||
auto* custom = FindCustomInfo(&m_custom_infos, game_path, legacy_game_path);
|
info->custom_settings =
|
||||||
if (custom != nullptr) {
|
FindCustomInfo(&m_custom_infos, game_path, legacy_game_path) != nullptr;
|
||||||
info->CopyFrom(*custom);
|
|
||||||
info->custom_settings = true;
|
|
||||||
} else {
|
|
||||||
info->CopyEmulatorSettingsFrom(m_global_info);
|
|
||||||
info->custom_settings = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetGameFiles(*info, game_dir.absolutePath(), game_path, metadata);
|
SetGameFiles(*info, game_dir.absolutePath(), game_path, metadata);
|
||||||
const auto* compatibility = m_compatibility->Find(info->title_id);
|
const auto* compatibility = m_compatibility->Find(info->title_id);
|
||||||
if (compatibility != nullptr) {
|
if (compatibility != nullptr) {
|
||||||
@@ -652,10 +649,9 @@ void ConfigurationListWidget::ScanGameDirectory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto* item = running_items.value(game_key); item != nullptr) {
|
if (auto* item = running_items.value(game_key); item != nullptr) {
|
||||||
// The process already has its own configuration copy. Refresh the
|
// Refresh metadata without losing the running row's identity.
|
||||||
// row's settings for the next launch without losing its running state.
|
|
||||||
const QSignalBlocker status_blocker(item->GetStatusCombo());
|
const QSignalBlocker status_blocker(item->GetStatusCombo());
|
||||||
item->GetInfo().CopyFrom(*info);
|
item->GetInfo().CopyGameInfoFrom(*info);
|
||||||
item->Update();
|
item->Update();
|
||||||
item->SetCompatibilityEditable(m_compatibility->IsLocal() &&
|
item->SetCompatibilityEditable(m_compatibility->IsLocal() &&
|
||||||
!item->GetInfo().title_id.trimmed().isEmpty());
|
!item->GetInfo().title_id.trimmed().isEmpty());
|
||||||
@@ -732,16 +728,19 @@ void ConfigurationListWidget::edit_configuration() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationEditDialog dlg(item->GetInfo(), this);
|
auto info = CreateConfiguration(*item);
|
||||||
|
ConfigurationEditDialog dlg(*info, this);
|
||||||
dlg.setWindowTitle(tr("Edit game settings"));
|
dlg.setWindowTitle(tr("Edit game settings"));
|
||||||
|
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
|
info->custom_settings = true;
|
||||||
item->GetInfo().custom_settings = true;
|
item->GetInfo().custom_settings = true;
|
||||||
auto game_path = item->GetInfo().game_path;
|
auto game_path = info->game_path;
|
||||||
delete m_custom_infos.take(game_path);
|
delete m_custom_infos.take(game_path);
|
||||||
m_custom_infos.insert(game_path, CloneConfiguration(item->GetInfo()));
|
m_custom_infos.insert(game_path, info.release());
|
||||||
WriteSettings();
|
WriteSettings();
|
||||||
ScanGameDirectory();
|
item->Update();
|
||||||
|
SelectItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,9 +752,11 @@ void ConfigurationListWidget::delete_configuartion() {
|
|||||||
|
|
||||||
if (QMessageBox::Yes == QMessageBox::question(this, tr("Clear custom settings"),
|
if (QMessageBox::Yes == QMessageBox::question(this, tr("Clear custom settings"),
|
||||||
tr("Do you want to clear custom settings?"))) {
|
tr("Do you want to clear custom settings?"))) {
|
||||||
ClearCustomSettings(item);
|
delete m_custom_infos.take(item->GetInfo().game_path);
|
||||||
|
item->GetInfo().custom_settings = false;
|
||||||
WriteSettings();
|
WriteSettings();
|
||||||
ScanGameDirectory();
|
item->Update();
|
||||||
|
SelectItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,9 +771,13 @@ void ConfigurationListWidget::edit_global_settings() {
|
|||||||
|
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
m_global_info.CopyEmulatorSettingsFrom(info);
|
m_global_info.CopyEmulatorSettingsFrom(info);
|
||||||
m_game_dirs = NormalizeGameDirectories(dlg.GetGameDirectories());
|
const auto game_dirs = NormalizeGameDirectories(dlg.GetGameDirectories());
|
||||||
|
const bool game_dirs_changed = game_dirs != m_game_dirs;
|
||||||
|
m_game_dirs = game_dirs;
|
||||||
WriteSettings();
|
WriteSettings();
|
||||||
ScanGameDirectory();
|
if (game_dirs_changed) {
|
||||||
|
ScanGameDirectory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,10 +789,6 @@ void ConfigurationListWidget::edit_input_mapping() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationListWidget::ClearCustomSettings(ConfigurationItem* item) {
|
|
||||||
delete m_custom_infos.take(item->GetInfo().game_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigurationListWidget::ViewTrophies() {
|
void ConfigurationListWidget::ViewTrophies() {
|
||||||
auto* current = static_cast<ConfigurationItem*>(m_ui->cfgs_list->currentItem());
|
auto* current = static_cast<ConfigurationItem*>(m_ui->cfgs_list->currentItem());
|
||||||
auto* item = current != nullptr ? current : m_selected_item;
|
auto* item = current != nullptr ? current : m_selected_item;
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ QString KeyName(const QKeyEvent& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case Qt::Key_Space: return QStringLiteral("Space");
|
||||||
case Qt::Key_Return:
|
case Qt::Key_Return:
|
||||||
case Qt::Key_Enter: return QStringLiteral("Return");
|
case Qt::Key_Enter: return QStringLiteral("Return");
|
||||||
case Qt::Key_Backspace: return QStringLiteral("Backspace");
|
case Qt::Key_Backspace: return QStringLiteral("Backspace");
|
||||||
@@ -132,8 +133,7 @@ public:
|
|||||||
|
|
||||||
auto* layout = new QVBoxLayout(this);
|
auto* layout = new QVBoxLayout(this);
|
||||||
m_label = new QLabel(
|
m_label = new QLabel(
|
||||||
tr("Press a key or mouse button.\nSpace, F1, F7, and F11 are reserved; Esc cancels."),
|
tr("Press a key or mouse button.\nF1, F7, and F11 are reserved; Esc cancels."), this);
|
||||||
this);
|
|
||||||
m_label->setAlignment(Qt::AlignCenter);
|
m_label->setAlignment(Qt::AlignCenter);
|
||||||
layout->addWidget(m_label);
|
layout->addWidget(m_label);
|
||||||
}
|
}
|
||||||
@@ -149,8 +149,8 @@ protected:
|
|||||||
reject();
|
reject();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event->key() == Qt::Key_Space || event->key() == Qt::Key_F1 ||
|
if (event->key() == Qt::Key_F1 || event->key() == Qt::Key_F7 ||
|
||||||
event->key() == Qt::Key_F7 || event->key() == Qt::Key_F11) {
|
event->key() == Qt::Key_F11) {
|
||||||
m_label->setText(tr("That key is reserved by the emulator."));
|
m_label->setText(tr("That key is reserved by the emulator."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -493,10 +493,8 @@ void MainDialogPrivate::Run() {
|
|||||||
|
|
||||||
m_running_item->SetRunning(true);
|
m_running_item->SetRunning(true);
|
||||||
|
|
||||||
Configuration info;
|
auto info = m_ui->widget->CreateConfiguration(*m_running_item);
|
||||||
info.CopyFrom(m_running_item->GetInfo());
|
m_main_dialog->RunInterpreter(&m_process, *info);
|
||||||
info.host_input_mapping = m_ui->widget->GetHostInputMapping();
|
|
||||||
m_main_dialog->RunInterpreter(&m_process, info);
|
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user