Merge Upstream Dolphin code (#3)

* Debugger: Fix warning on Debian builder

Fix "braces around scalar initializer [-Wbraced-scalar-init]" warning

* Fix manual update check which was hardcoded to "dev" track

* OGLRender: Log video backend info, in addition to showing it via OSD

This is mainly intended for debugging fifo.ci.

* FileUtil: Remove redundant statement

* Qt/GeneralPane: Don't trigger config change events when populating GUI.

* more stuff

* buildbot from dolphin-mpn-src to dolphin-mpn-advanced-src

* Fix Netplay Traversal Error

* Update linux.yml

* Update macos.yml

* Update linux.yml

* NANDImporter: Make a class variable for the NAND root

* fix linux buildbot

* rename binary automatically to dolphin-mpn

* NANDImporter: Improve NANDFSTEntry

`uid` is a u32, not a u16. Also, everything is big endian, so we
can simplify the code a little bit.

* NANDImporter: Reduce recursion in `ProcessEntry`

It also simplifies the code flow, as it no longer goes backwards
through the filesystem chain.

* NANDImporter: Don't pass paths if we don't need to

* NANDImporter: Make superblocks less magical

Create a struct describing the superblock layout and use it directly
without needing to specify offsets and such.

* NANDImporter: Only read the AES key once

There is no need to constantly reset the key for every file entry.

* Common: Make DynamicLibrary non-copyable

The default implementations of DynamicLibrary's copy and move
constructors and assignment operators are unsafe.

* minor fixes

Co-authored-by: Dentomologist <dentomologist@gmail.com>
Co-authored-by: Pierre Bourdon <delroth@gmail.com>
Co-authored-by: Pokechu22 <Pokechu022@gmail.com>
Co-authored-by: Admiral H. Curtiss <pikachu025@gmail.com>
Co-authored-by: JosJuice <josjuice@gmail.com>
Co-authored-by: Starsam80 <samraskauskas@gmail.com>
Co-authored-by: Léo Lam <leo@leolam.fr>
This commit is contained in:
Nora 2022-03-08 01:37:34 -05:00 committed by GitHub
commit b788d33717
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 223 additions and 182 deletions

View file

@ -24,6 +24,12 @@ public:
// Closes the library. // Closes the library.
~DynamicLibrary(); ~DynamicLibrary();
DynamicLibrary(const DynamicLibrary&) = delete;
DynamicLibrary(DynamicLibrary&&) = delete;
DynamicLibrary& operator=(const DynamicLibrary&) = delete;
DynamicLibrary& operator=(DynamicLibrary&&) = delete;
// Returns the specified library name with the platform-specific suffix added. // Returns the specified library name with the platform-specific suffix added.
static std::string GetUnprefixedFilename(const char* filename); static std::string GetUnprefixedFilename(const char* filename);

View file

@ -859,7 +859,6 @@ std::string GetExePath()
} }
#elif defined(__APPLE__) #elif defined(__APPLE__)
result = GetBundleDirectory(); result = GetBundleDirectory();
result = result.substr(0, result.find_last_of("Dolphin.app/Contents/MacOS") + 1);
#else #else
char dolphin_exe_path[PATH_MAX]; char dolphin_exe_path[PATH_MAX];
ssize_t len = ::readlink("/proc/self/exe", dolphin_exe_path, sizeof(dolphin_exe_path)); ssize_t len = ::readlink("/proc/self/exe", dolphin_exe_path, sizeof(dolphin_exe_path));

View file

@ -182,7 +182,7 @@ Common::Debug::Threads PPCDebugInterface::GetThreads() const
if (!active_thread->IsValid()) if (!active_thread->IsValid())
return threads; return threads;
std::vector<u32> visited_addrs{{active_thread->GetAddress()}}; std::vector<u32> visited_addrs{active_thread->GetAddress()};
const auto insert_threads = [&threads, &visited_addrs](u32 addr, auto get_next_addr) { const auto insert_threads = [&threads, &visited_addrs](u32 addr, auto get_next_addr) {
while (addr != 0 && PowerPC::HostIsRAMAddress(addr)) while (addr != 0 && PowerPC::HostIsRAMAddress(addr))
{ {

View file

@ -221,7 +221,9 @@ const mpn_board_t MP5_BOARDS[] = {{1, 0x76, {"Toy Dream"}, {"mp5-toy"}},
{3, 0x7A, {"Pirate Dream"}, {"mp5-pirate"}}, {3, 0x7A, {"Pirate Dream"}, {"mp5-pirate"}},
{4, 0x7C, {"Undersea Dream"}, {"mp5-undersea"}}, {4, 0x7C, {"Undersea Dream"}, {"mp5-undersea"}},
{5, 0x7E, {"Future Dream"}, {"mp5-future"}}, {5, 0x7E, {"Future Dream"}, {"mp5-future"}},
{6, 0x80, {"Bowser Nightmare"}, {"mp5-bowser"}}, {6, 0x80, {"Sweet Dream"}, {"mp5-sweet"}},
{7, 0x82, {"Bowser Nightmare"}, {"mp5-bowser"}},
{NONE, NONE, {""}, ""}}; {NONE, NONE, {""}, ""}};
@ -318,7 +320,8 @@ const mpn_scene_t MP5_GAMESTATES[] = {{NONE, 0x01, {"Title Screen"}, 0},
{NONE, 0x7A, {"Pirate Dream"}, 0}, {NONE, 0x7A, {"Pirate Dream"}, 0},
{NONE, 0x7C, {"Undersea Dream"}, 0}, {NONE, 0x7C, {"Undersea Dream"}, 0},
{NONE, 0x7E, {"Future Dream"}, 0}, {NONE, 0x7E, {"Future Dream"}, 0},
{NONE, 0x80, {"Bowser Nightmare"}, 0}, {NONE, 0x80, {"Sweet Dream"}, 0},
{NONE, 0x82, {"Bowser Nightmare"}, 0},
{NONE, NONE, {""}}}; {NONE, NONE, {""}}};

View file

@ -4,17 +4,13 @@
#include "DiscIO/NANDImporter.h" #include "DiscIO/NANDImporter.h"
#include <algorithm> #include <algorithm>
#include <array>
#include <cstring> #include <cstring>
#include <fmt/format.h>
#include "Common/Crypto/AES.h" #include "Common/Crypto/AES.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/IOFile.h" #include "Common/IOFile.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "Core/IOS/ES/Formats.h" #include "Core/IOS/ES/Formats.h"
namespace DiscIO namespace DiscIO
@ -22,7 +18,9 @@ namespace DiscIO
constexpr size_t NAND_SIZE = 0x20000000; constexpr size_t NAND_SIZE = 0x20000000;
constexpr size_t NAND_KEYS_SIZE = 0x400; constexpr size_t NAND_KEYS_SIZE = 0x400;
NANDImporter::NANDImporter() = default; NANDImporter::NANDImporter() : m_nand_root(File::GetUserPath(D_WIIROOT_IDX))
{
}
NANDImporter::~NANDImporter() = default; NANDImporter::~NANDImporter() = default;
void NANDImporter::ImportNANDBin(const std::string& path_to_bin, void NANDImporter::ImportNANDBin(const std::string& path_to_bin,
@ -33,15 +31,12 @@ void NANDImporter::ImportNANDBin(const std::string& path_to_bin,
if (!ReadNANDBin(path_to_bin, get_otp_dump_path)) if (!ReadNANDBin(path_to_bin, get_otp_dump_path))
return; return;
if (!FindSuperblock())
return;
std::string nand_root = File::GetUserPath(D_WIIROOT_IDX); ExportKeys();
nand_root.pop_back(); // remove trailing path separator ProcessEntry(0, "");
m_nand_root_length = nand_root.length(); ExtractCertificates();
FindSuperblock();
ProcessEntry(0, nand_root);
ExportKeys(nand_root);
ExtractCertificates(nand_root);
} }
bool NANDImporter::ReadNANDBin(const std::string& path_to_bin, bool NANDImporter::ReadNANDBin(const std::string& path_to_bin,
@ -93,32 +88,37 @@ bool NANDImporter::ReadNANDBin(const std::string& path_to_bin,
return file.ReadBytes(m_nand_keys.data(), NAND_KEYS_SIZE); return file.ReadBytes(m_nand_keys.data(), NAND_KEYS_SIZE);
} }
void NANDImporter::FindSuperblock() bool NANDImporter::FindSuperblock()
{ {
constexpr size_t NAND_SUPERBLOCK_START = 0x1fc00000; constexpr size_t NAND_SUPERBLOCK_START = 0x1fc00000;
constexpr size_t NAND_SUPERBLOCK_SIZE = 0x40000;
size_t superblock = 0; // There are 16 superblocks, choose the highest/newest version
u32 newest_version = 0; for (int i = 0; i < 16; i++)
for (size_t pos = NAND_SUPERBLOCK_START; pos < NAND_SIZE; pos += NAND_SUPERBLOCK_SIZE)
{ {
if (!memcmp(m_nand.data() + pos, "SFFS", 4)) auto superblock = std::make_unique<NANDSuperblock>();
std::memcpy(superblock.get(), &m_nand[NAND_SUPERBLOCK_START + i * sizeof(NANDSuperblock)],
sizeof(NANDSuperblock));
if (std::memcmp(superblock->magic, "SFFS", 4) != 0)
{ {
const u32 version = Common::swap32(&m_nand[pos + 4]); ERROR_LOG_FMT(DISCIO, "Superblock #{} does not exist", i);
INFO_LOG_FMT(DISCIO, "Found superblock at {:#x} with version {:#x}", pos, version); continue;
if (superblock == 0 || version > newest_version)
{
superblock = pos;
newest_version = version;
}
} }
INFO_LOG_FMT(DISCIO, "Superblock #{} has version {:#x}", i, superblock->version);
if (!m_superblock || superblock->version > m_superblock->version)
m_superblock = std::move(superblock);
} }
m_nand_fat_offset = superblock + 0xC; if (!m_superblock)
m_nand_fst_offset = m_nand_fat_offset + 0x10000; {
INFO_LOG_FMT(DISCIO, PanicAlertFmtT("This file does not contain a valid Wii filesystem.");
"Using superblock version {:#x} at position {:#x}. FAT/FST offset: {:#x}/{:#x}", return false;
newest_version, superblock, m_nand_fat_offset, m_nand_fst_offset); }
INFO_LOG_FMT(DISCIO, "Using superblock version {:#x}", m_superblock->version);
return true;
} }
std::string NANDImporter::GetPath(const NANDFSTEntry& entry, const std::string& parent_path) std::string NANDImporter::GetPath(const NANDFSTEntry& entry, const std::string& parent_path)
@ -131,76 +131,65 @@ std::string NANDImporter::GetPath(const NANDFSTEntry& entry, const std::string&
return parent_path + '/' + name; return parent_path + '/' + name;
} }
std::string NANDImporter::FormatDebugString(const NANDFSTEntry& entry)
{
return fmt::format(
"{:12.12} {:#04x} {:#04x} {:#06x} {:#06x} {:#010x} {:#06x} {:#06x} {:#06x} {:#010x}",
entry.name, entry.mode, entry.attr, entry.sub, entry.sib, entry.size, entry.x1, entry.uid,
entry.gid, entry.x3);
}
void NANDImporter::ProcessEntry(u16 entry_number, const std::string& parent_path) void NANDImporter::ProcessEntry(u16 entry_number, const std::string& parent_path)
{ {
NANDFSTEntry entry; while (entry_number != 0xffff)
memcpy(&entry, &m_nand[m_nand_fst_offset + sizeof(NANDFSTEntry) * Common::swap16(entry_number)], {
sizeof(NANDFSTEntry)); const NANDFSTEntry entry = m_superblock->fst[entry_number];
if (entry.sib != 0xffff) const std::string path = GetPath(entry, parent_path);
ProcessEntry(entry.sib, parent_path); INFO_LOG_FMT(DISCIO, "Entry: {} Path: {}", entry, path);
m_update_callback();
if ((entry.mode & 3) == 1) Type type = static_cast<Type>(entry.mode & 3);
ProcessFile(entry, parent_path); if (type == Type::File)
else if ((entry.mode & 3) == 2) {
ProcessDirectory(entry, parent_path); std::vector<u8> data = GetEntryData(entry);
else File::IOFile file(m_nand_root + path, "wb");
ERROR_LOG_FMT(DISCIO, "Unknown mode: {}", FormatDebugString(entry)); file.WriteBytes(data.data(), data.size());
}
else if (type == Type::Directory)
{
File::CreateDir(m_nand_root + path);
ProcessEntry(entry.sub, path);
}
else
{
ERROR_LOG_FMT(DISCIO, "Ignoring unknown entry type for {}", entry);
}
entry_number = entry.sib;
}
} }
void NANDImporter::ProcessDirectory(const NANDFSTEntry& entry, const std::string& parent_path) std::vector<u8> NANDImporter::GetEntryData(const NANDFSTEntry& entry)
{ {
m_update_callback();
INFO_LOG_FMT(DISCIO, "Path: {}", FormatDebugString(entry));
const std::string path = GetPath(entry, parent_path);
File::CreateDir(path);
if (entry.sub != 0xffff)
ProcessEntry(entry.sub, path);
INFO_LOG_FMT(DISCIO, "Path: {}", parent_path.data() + m_nand_root_length);
}
void NANDImporter::ProcessFile(const NANDFSTEntry& entry, const std::string& parent_path)
{
constexpr size_t NAND_AES_KEY_OFFSET = 0x158;
constexpr size_t NAND_FAT_BLOCK_SIZE = 0x4000; constexpr size_t NAND_FAT_BLOCK_SIZE = 0x4000;
m_update_callback(); u16 sub = entry.sub;
INFO_LOG_FMT(DISCIO, "File: {}", FormatDebugString(entry)); size_t remaining_bytes = entry.size;
std::vector<u8> data{};
const std::string path = GetPath(entry, parent_path); data.reserve(remaining_bytes);
File::IOFile file(path, "wb");
std::array<u8, 16> key{};
std::copy(&m_nand_keys[NAND_AES_KEY_OFFSET], &m_nand_keys[NAND_AES_KEY_OFFSET + key.size()],
key.begin());
u16 sub = Common::swap16(entry.sub);
u32 remaining_bytes = Common::swap32(entry.size);
while (remaining_bytes > 0) while (remaining_bytes > 0)
{ {
std::array<u8, 16> iv{}; std::array<u8, 16> iv{};
std::vector<u8> block = Common::AES::Decrypt( std::vector<u8> block = Common::AES::Decrypt(
key.data(), iv.data(), &m_nand[NAND_FAT_BLOCK_SIZE * sub], NAND_FAT_BLOCK_SIZE); m_aes_key.data(), iv.data(), &m_nand[NAND_FAT_BLOCK_SIZE * sub], NAND_FAT_BLOCK_SIZE);
u32 size = remaining_bytes < NAND_FAT_BLOCK_SIZE ? remaining_bytes : NAND_FAT_BLOCK_SIZE;
file.WriteBytes(block.data(), size); size_t size = std::min(remaining_bytes, block.size());
data.insert(data.end(), block.begin(), block.begin() + size);
remaining_bytes -= size; remaining_bytes -= size;
sub = Common::swap16(&m_nand[m_nand_fat_offset + 2 * sub]);
sub = m_superblock->fat[sub];
} }
return data;
} }
bool NANDImporter::ExtractCertificates(const std::string& nand_root) bool NANDImporter::ExtractCertificates()
{ {
const std::string content_dir = nand_root + "/title/00000001/0000000d/content/"; const std::string content_dir = m_nand_root + "/title/00000001/0000000d/content/";
File::IOFile tmd_file(content_dir + "title.tmd", "rb"); File::IOFile tmd_file(content_dir + "title.tmd", "rb");
std::vector<u8> tmd_bytes(tmd_file.GetSize()); std::vector<u8> tmd_bytes(tmd_file.GetSize());
@ -251,7 +240,7 @@ bool NANDImporter::ExtractCertificates(const std::string& nand_root)
return false; return false;
} }
const std::string pem_file_path = nand_root + std::string(certificate.filename); const std::string pem_file_path = m_nand_root + std::string(certificate.filename);
const ptrdiff_t certificate_offset = std::distance(content_bytes.begin(), search_result); const ptrdiff_t certificate_offset = std::distance(content_bytes.begin(), search_result);
const u16 certificate_size = Common::swap16(&content_bytes[certificate_offset - 2]); const u16 certificate_size = Common::swap16(&content_bytes[certificate_offset - 2]);
INFO_LOG_FMT(DISCIO, "ExtractCertificates: '{}' offset: {:#x} size: {:#x}", INFO_LOG_FMT(DISCIO, "ExtractCertificates: '{}' offset: {:#x} size: {:#x}",
@ -267,9 +256,13 @@ bool NANDImporter::ExtractCertificates(const std::string& nand_root)
return true; return true;
} }
void NANDImporter::ExportKeys(const std::string& nand_root) void NANDImporter::ExportKeys()
{ {
const std::string file_path = nand_root + "/keys.bin"; constexpr size_t NAND_AES_KEY_OFFSET = 0x158;
std::copy_n(&m_nand_keys[NAND_AES_KEY_OFFSET], m_aes_key.size(), m_aes_key.begin());
const std::string file_path = m_nand_root + "/keys.bin";
File::IOFile file(file_path, "wb"); File::IOFile file(file_path, "wb");
if (!file.WriteBytes(m_nand_keys.data(), NAND_KEYS_SIZE)) if (!file.WriteBytes(m_nand_keys.data(), NAND_KEYS_SIZE))
PanicAlertFmtT("Unable to write to file {0}", file_path); PanicAlertFmtT("Unable to write to file {0}", file_path);

View file

@ -3,11 +3,16 @@
#pragma once #pragma once
#include <array>
#include <functional> #include <functional>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include <fmt/format.h>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Swap.h"
namespace DiscIO namespace DiscIO
{ {
@ -22,39 +27,69 @@ public:
// get_otp_dump_path will be called to get a path to it. // get_otp_dump_path will be called to get a path to it.
void ImportNANDBin(const std::string& path_to_bin, std::function<void()> update_callback, void ImportNANDBin(const std::string& path_to_bin, std::function<void()> update_callback,
std::function<std::string()> get_otp_dump_path); std::function<std::string()> get_otp_dump_path);
bool ExtractCertificates(const std::string& nand_root); bool ExtractCertificates();
enum class Type
{
File = 1,
Directory = 2,
};
private:
#pragma pack(push, 1) #pragma pack(push, 1)
struct NANDFSTEntry struct NANDFSTEntry
{ {
char name[12]; char name[12];
u8 mode; // 0x0C u8 mode;
u8 attr; // 0x0D u8 attr;
u16 sub; // 0x0E Common::BigEndianValue<u16> sub;
u16 sib; // 0x10 Common::BigEndianValue<u16> sib;
u32 size; // 0x12 Common::BigEndianValue<u32> size;
u16 x1; // 0x16 Common::BigEndianValue<u32> uid;
u16 uid; // 0x18 Common::BigEndianValue<u16> gid;
u16 gid; // 0x1A Common::BigEndianValue<u32> x3;
u32 x3; // 0x1C
}; };
static_assert(sizeof(NANDFSTEntry) == 0x20, "Wrong size");
struct NANDSuperblock
{
char magic[4]; // "SFFS"
Common::BigEndianValue<u32> version;
Common::BigEndianValue<u32> unknown;
Common::BigEndianValue<u16> fat[0x8000];
NANDFSTEntry fst[0x17FF];
u8 pad[0x14];
};
static_assert(sizeof(NANDSuperblock) == 0x40000, "Wrong size");
#pragma pack(pop) #pragma pack(pop)
private:
bool ReadNANDBin(const std::string& path_to_bin, std::function<std::string()> get_otp_dump_path); bool ReadNANDBin(const std::string& path_to_bin, std::function<std::string()> get_otp_dump_path);
void FindSuperblock(); bool FindSuperblock();
std::string GetPath(const NANDFSTEntry& entry, const std::string& parent_path); std::string GetPath(const NANDFSTEntry& entry, const std::string& parent_path);
std::string FormatDebugString(const NANDFSTEntry& entry); std::string FormatDebugString(const NANDFSTEntry& entry);
void ProcessEntry(u16 entry_number, const std::string& parent_path); void ProcessEntry(u16 entry_number, const std::string& parent_path);
void ProcessFile(const NANDFSTEntry& entry, const std::string& parent_path); std::vector<u8> GetEntryData(const NANDFSTEntry& entry);
void ProcessDirectory(const NANDFSTEntry& entry, const std::string& parent_path); void ExportKeys();
void ExportKeys(const std::string& nand_root);
std::string m_nand_root;
std::vector<u8> m_nand; std::vector<u8> m_nand;
std::vector<u8> m_nand_keys; std::vector<u8> m_nand_keys;
size_t m_nand_fat_offset = 0; std::array<u8, 16> m_aes_key;
size_t m_nand_fst_offset = 0; std::unique_ptr<NANDSuperblock> m_superblock;
std::function<void()> m_update_callback; std::function<void()> m_update_callback;
size_t m_nand_root_length = 0;
}; };
} // namespace DiscIO } // namespace DiscIO
template <>
struct fmt::formatter<DiscIO::NANDImporter::NANDFSTEntry>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const DiscIO::NANDImporter::NANDFSTEntry& entry, FormatContext& ctx) const
{
return fmt::format_to(
ctx.out(), "{:12.12} {:#010b} {:#04x} {:#06x} {:#06x} {:#010x} {:#010x} {:#06x} {:#010x}",
entry.name, entry.mode, entry.attr, entry.sub, entry.sib, entry.size, entry.uid, entry.gid,
entry.x3);
}
};

View file

@ -279,6 +279,7 @@ add_executable(dolphin-emu
QtUtils/PartiallyClosableTabWidget.h QtUtils/PartiallyClosableTabWidget.h
QtUtils/ImageConverter.cpp QtUtils/ImageConverter.cpp
QtUtils/ImageConverter.h QtUtils/ImageConverter.h
QtUtils/SignalBlocking.h
QtUtils/UTF8CodePointCountValidator.cpp QtUtils/UTF8CodePointCountValidator.cpp
QtUtils/UTF8CodePointCountValidator.h QtUtils/UTF8CodePointCountValidator.h
QtUtils/WindowActivationEventFilter.cpp QtUtils/WindowActivationEventFilter.cpp

View file

@ -231,6 +231,7 @@
<ClInclude Include="QtUtils\ModalMessageBox.h" /> <ClInclude Include="QtUtils\ModalMessageBox.h" />
<ClInclude Include="QtUtils\QueueOnObject.h" /> <ClInclude Include="QtUtils\QueueOnObject.h" />
<ClInclude Include="QtUtils\RunOnObject.h" /> <ClInclude Include="QtUtils\RunOnObject.h" />
<ClInclude Include="QtUtils\SignalBlocking.h" />
<ClInclude Include="QtUtils\WinIconHelper.h" /> <ClInclude Include="QtUtils\WinIconHelper.h" />
<ClInclude Include="QtUtils\WrapInScrollArea.h" /> <ClInclude Include="QtUtils\WrapInScrollArea.h" />
<ClInclude Include="ResourcePackManager.h" /> <ClInclude Include="ResourcePackManager.h" />

View file

@ -60,6 +60,7 @@
#include "UICommon/AutoUpdate.h" #include "UICommon/AutoUpdate.h"
#include "UICommon/GameFile.h" #include "UICommon/GameFile.h"
#include <qprocess.h>
QPointer<MenuBar> MenuBar::s_menu_bar; QPointer<MenuBar> MenuBar::s_menu_bar;
@ -541,19 +542,6 @@ void MenuBar::AddOptionsMenu()
m_change_font = options_menu->addAction(tr("&Font..."), this, &MenuBar::ChangeDebugFont); m_change_font = options_menu->addAction(tr("&Font..."), this, &MenuBar::ChangeDebugFont);
} }
void MenuBar::InstallUpdateManually()
{
auto* updater =
new Updater(this->parentWidget(), "dev", Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
if (!updater->CheckForUpdate())
{
ModalMessageBox::information(
this, tr("Update"),
tr("You are running the latest version available on this update track."));
}
}
void MenuBar::AddHelpMenu() void MenuBar::AddHelpMenu()
{ {
QMenu* help_menu = addMenu(tr("&Help")); QMenu* help_menu = addMenu(tr("&Help"));
@ -575,13 +563,6 @@ void MenuBar::AddHelpMenu()
QUrl(QStringLiteral("https://bugs.dolphin-emu.org/projects/emulator"))); QUrl(QStringLiteral("https://bugs.dolphin-emu.org/projects/emulator")));
}); });
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
{
help_menu->addSeparator();
help_menu->addAction(tr("&Check for Updates..."), this, &MenuBar::InstallUpdateManually);
}
#ifndef __APPLE__ #ifndef __APPLE__
help_menu->addSeparator(); help_menu->addSeparator();
#endif #endif
@ -1170,7 +1151,7 @@ void MenuBar::CheckNAND()
void MenuBar::NANDExtractCertificates() void MenuBar::NANDExtractCertificates()
{ {
if (DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX))) if (DiscIO::NANDImporter().ExtractCertificates())
{ {
ModalMessageBox::information(this, tr("Success"), ModalMessageBox::information(this, tr("Success"),
tr("Successfully extracted certificates from NAND")); tr("Successfully extracted certificates from NAND"));

View file

@ -0,0 +1,32 @@
// Copyright 2022 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QSignalBlocker>
// Helper class for populating a GUI element without triggering its data change signals.
template <typename T>
class SignalBlockerProxy
{
public:
explicit SignalBlockerProxy(T* object) : m_object(object), m_blocker(object) {}
SignalBlockerProxy(const SignalBlockerProxy& other) = delete;
SignalBlockerProxy(SignalBlockerProxy&& other) = default;
SignalBlockerProxy& operator=(const SignalBlockerProxy& other) = delete;
SignalBlockerProxy& operator=(SignalBlockerProxy&& other) = default;
~SignalBlockerProxy() = default;
T* operator->() const { return m_object; }
private:
T* m_object;
QSignalBlocker m_blocker;
};
template <typename T>
SignalBlockerProxy<T> SignalBlocking(T* object)
{
return SignalBlockerProxy<T>(object);
}

View file

@ -23,14 +23,15 @@
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
//#include "UICommon/AutoUpdate.h" #include "UICommon/AutoUpdate.h"
#ifdef USE_DISCORD_PRESENCE #ifdef USE_DISCORD_PRESENCE
#include "UICommon/DiscordPresence.h" #include "UICommon/DiscordPresence.h"
#endif #endif
/* constexpr int AUTO_UPDATE_DISABLE_INDEX = 0; constexpr int AUTO_UPDATE_DISABLE_INDEX = 0;
constexpr int AUTO_UPDATE_STABLE_INDEX = 1; constexpr int AUTO_UPDATE_STABLE_INDEX = 1;
constexpr int AUTO_UPDATE_BETA_INDEX = 2; constexpr int AUTO_UPDATE_BETA_INDEX = 2;
constexpr int AUTO_UPDATE_DEV_INDEX = 3; constexpr int AUTO_UPDATE_DEV_INDEX = 3;
@ -38,7 +39,7 @@ constexpr int AUTO_UPDATE_DEV_INDEX = 3;
constexpr const char* AUTO_UPDATE_DISABLE_STRING = ""; constexpr const char* AUTO_UPDATE_DISABLE_STRING = "";
constexpr const char* AUTO_UPDATE_STABLE_STRING = "stable"; constexpr const char* AUTO_UPDATE_STABLE_STRING = "stable";
constexpr const char* AUTO_UPDATE_BETA_STRING = "beta"; constexpr const char* AUTO_UPDATE_BETA_STRING = "beta";
constexpr const char* AUTO_UPDATE_DEV_STRING = "dev";*/ constexpr const char* AUTO_UPDATE_DEV_STRING = "dev";
constexpr int FALLBACK_REGION_NTSCJ_INDEX = 0; constexpr int FALLBACK_REGION_NTSCJ_INDEX = 0;
constexpr int FALLBACK_REGION_NTSCU_INDEX = 1; constexpr int FALLBACK_REGION_NTSCU_INDEX = 1;
@ -65,9 +66,6 @@ void GeneralPane::CreateLayout()
// Create layout here // Create layout here
CreateBasic(); CreateBasic();
/* if (AutoUpdateChecker::SystemSupportsAutoUpdates())
CreateAutoUpdate();*/
CreateFallbackRegion(); CreateFallbackRegion();
#if defined(USE_ANALYTICS) && USE_ANALYTICS #if defined(USE_ANALYTICS) && USE_ANALYTICS
@ -83,6 +81,7 @@ void GeneralPane::OnEmulationStateChanged(Core::State state)
const bool running = state != Core::State::Uninitialized; const bool running = state != Core::State::Uninitialized;
m_checkbox_dualcore->setEnabled(!running); m_checkbox_dualcore->setEnabled(!running);
m_checkbox_cheats->setEnabled(!running);
m_checkbox_override_region_settings->setEnabled(!running); m_checkbox_override_region_settings->setEnabled(!running);
#ifdef USE_DISCORD_PRESENCE #ifdef USE_DISCORD_PRESENCE
m_checkbox_discord_presence->setEnabled(!running); m_checkbox_discord_presence->setEnabled(!running);
@ -93,6 +92,7 @@ void GeneralPane::OnEmulationStateChanged(Core::State state)
void GeneralPane::ConnectLayout() void GeneralPane::ConnectLayout()
{ {
connect(m_checkbox_dualcore, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig); connect(m_checkbox_dualcore, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
connect(m_checkbox_cheats, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
connect(m_checkbox_override_region_settings, &QCheckBox::stateChanged, this, connect(m_checkbox_override_region_settings, &QCheckBox::stateChanged, this,
&GeneralPane::OnSaveConfig); &GeneralPane::OnSaveConfig);
connect(m_checkbox_auto_disc_change, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig); connect(m_checkbox_auto_disc_change, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
@ -100,13 +100,13 @@ void GeneralPane::ConnectLayout()
connect(m_checkbox_discord_presence, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig); connect(m_checkbox_discord_presence, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
#endif #endif
/* if (AutoUpdateChecker::SystemSupportsAutoUpdates()) if (AutoUpdateChecker::SystemSupportsAutoUpdates())
{ {
connect(m_combobox_update_track, qOverload<int>(&QComboBox::currentIndexChanged), this, connect(m_combobox_update_track, qOverload<int>(&QComboBox::currentIndexChanged), this,
&GeneralPane::OnSaveConfig); &GeneralPane::OnSaveConfig);
connect(&Settings::Instance(), &Settings::AutoUpdateTrackChanged, this, connect(&Settings::Instance(), &Settings::AutoUpdateTrackChanged, this,
&GeneralPane::LoadConfig); &GeneralPane::LoadConfig);
}*/ }
// Advanced // Advanced
connect(m_combobox_speedlimit, qOverload<int>(&QComboBox::currentIndexChanged), connect(m_combobox_speedlimit, qOverload<int>(&QComboBox::currentIndexChanged),
@ -134,6 +134,9 @@ void GeneralPane::CreateBasic()
m_checkbox_dualcore = new QCheckBox(tr("Enable Dual Core (speedup)")); m_checkbox_dualcore = new QCheckBox(tr("Enable Dual Core (speedup)"));
basic_group_layout->addWidget(m_checkbox_dualcore); basic_group_layout->addWidget(m_checkbox_dualcore);
m_checkbox_cheats = new QCheckBox(tr("Enable Cheats"));
basic_group_layout->addWidget(m_checkbox_cheats);
m_checkbox_override_region_settings = new QCheckBox(tr("Allow Mismatched Region Settings")); m_checkbox_override_region_settings = new QCheckBox(tr("Allow Mismatched Region Settings"));
basic_group_layout->addWidget(m_checkbox_override_region_settings); basic_group_layout->addWidget(m_checkbox_override_region_settings);
@ -167,25 +170,6 @@ void GeneralPane::CreateBasic()
speed_limit_layout->addRow(tr("&Speed Limit:"), m_combobox_speedlimit); speed_limit_layout->addRow(tr("&Speed Limit:"), m_combobox_speedlimit);
} }
/* void GeneralPane::CreateAutoUpdate()
{
auto* auto_update_group = new QGroupBox(tr("Auto Update Settings"));
auto* auto_update_group_layout = new QFormLayout;
auto_update_group->setLayout(auto_update_group_layout);
m_main_layout->addWidget(auto_update_group);
auto_update_group_layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop);
auto_update_group_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
m_combobox_update_track = new QComboBox(this);
auto_update_group_layout->addRow(tr("&Auto Update:"), m_combobox_update_track);
for (const QString& option : {tr("Don't Update"), tr("Stable (once a year)"),
tr("Beta (once a month)"), tr("Dev (multiple times a day)")})
m_combobox_update_track->addItem(option);
}*/
void GeneralPane::CreateFallbackRegion() void GeneralPane::CreateFallbackRegion()
{ {
auto* fallback_region_group = new QGroupBox(tr("Fallback Region")); auto* fallback_region_group = new QGroupBox(tr("Fallback Region"));
@ -230,50 +214,52 @@ void GeneralPane::LoadConfig()
{ {
const QSignalBlocker blocker(this); const QSignalBlocker blocker(this);
/* if (AutoUpdateChecker::SystemSupportsAutoUpdates()) if (AutoUpdateChecker::SystemSupportsAutoUpdates())
{ {
const auto track = Settings::Instance().GetAutoUpdateTrack().toStdString(); const auto track = Settings::Instance().GetAutoUpdateTrack().toStdString();
if (track == AUTO_UPDATE_DISABLE_STRING) if (track == AUTO_UPDATE_DISABLE_STRING)
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_DISABLE_INDEX); SignalBlocking(m_combobox_update_track)->setCurrentIndex(AUTO_UPDATE_DISABLE_INDEX);
else if (track == AUTO_UPDATE_STABLE_STRING) else if (track == AUTO_UPDATE_STABLE_STRING)
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_STABLE_INDEX); SignalBlocking(m_combobox_update_track)->setCurrentIndex(AUTO_UPDATE_STABLE_INDEX);
else if (track == AUTO_UPDATE_BETA_STRING) else if (track == AUTO_UPDATE_BETA_STRING)
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_BETA_INDEX); SignalBlocking(m_combobox_update_track)->setCurrentIndex(AUTO_UPDATE_BETA_INDEX);
else else
m_combobox_update_track->setCurrentIndex(AUTO_UPDATE_DEV_INDEX); SignalBlocking(m_combobox_update_track)->setCurrentIndex(AUTO_UPDATE_DEV_INDEX);
}*/ }
#if defined(USE_ANALYTICS) && USE_ANALYTICS #if defined(USE_ANALYTICS) && USE_ANALYTICS
m_checkbox_enable_analytics->setChecked(Settings::Instance().IsAnalyticsEnabled()); SignalBlocking(m_checkbox_enable_analytics)
->setChecked(Settings::Instance().IsAnalyticsEnabled());
#endif #endif
m_checkbox_dualcore->setChecked(Config::Get(Config::MAIN_CPU_THREAD)); SignalBlocking(m_checkbox_dualcore)->setChecked(Config::Get(Config::MAIN_CPU_THREAD));
m_checkbox_override_region_settings->setChecked( SignalBlocking(m_checkbox_cheats)->setChecked(Settings::Instance().GetCheatsEnabled());
Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS)); SignalBlocking(m_checkbox_override_region_settings)
m_checkbox_auto_disc_change->setChecked(Config::Get(Config::MAIN_AUTO_DISC_CHANGE)); ->setChecked(Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS));
SignalBlocking(m_checkbox_auto_disc_change)
->setChecked(Config::Get(Config::MAIN_AUTO_DISC_CHANGE));
#ifdef USE_DISCORD_PRESENCE #ifdef USE_DISCORD_PRESENCE
m_checkbox_discord_presence->setChecked(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE)); SignalBlocking(m_checkbox_discord_presence)
->setChecked(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE));
#endif #endif
int selection = qRound(Config::Get(Config::MAIN_EMULATION_SPEED) * 10); int selection = qRound(Config::Get(Config::MAIN_EMULATION_SPEED) * 10);
if (selection < m_combobox_speedlimit->count()) if (selection < m_combobox_speedlimit->count())
m_combobox_speedlimit->setCurrentIndex(selection); SignalBlocking(m_combobox_speedlimit)->setCurrentIndex(selection);
m_checkbox_dualcore->setChecked(Config::Get(Config::MAIN_CPU_THREAD));
const auto fallback = Settings::Instance().GetFallbackRegion(); const auto fallback = Settings::Instance().GetFallbackRegion();
if (fallback == DiscIO::Region::NTSC_J) if (fallback == DiscIO::Region::NTSC_J)
m_combobox_fallback_region->setCurrentIndex(FALLBACK_REGION_NTSCJ_INDEX); SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCJ_INDEX);
else if (fallback == DiscIO::Region::NTSC_U) else if (fallback == DiscIO::Region::NTSC_U)
m_combobox_fallback_region->setCurrentIndex(FALLBACK_REGION_NTSCU_INDEX); SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCU_INDEX);
else if (fallback == DiscIO::Region::PAL) else if (fallback == DiscIO::Region::PAL)
m_combobox_fallback_region->setCurrentIndex(FALLBACK_REGION_PAL_INDEX); SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_PAL_INDEX);
else if (fallback == DiscIO::Region::NTSC_K) else if (fallback == DiscIO::Region::NTSC_K)
m_combobox_fallback_region->setCurrentIndex(FALLBACK_REGION_NTSCK_INDEX); SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCK_INDEX);
else else
m_combobox_fallback_region->setCurrentIndex(FALLBACK_REGION_NTSCJ_INDEX); SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCJ_INDEX);
} }
/* static QString UpdateTrackFromIndex(int index) static QString UpdateTrackFromIndex(int index)
{ {
QString value; QString value;
@ -294,7 +280,7 @@ void GeneralPane::LoadConfig()
} }
return value; return value;
}*/ }
static DiscIO::Region UpdateFallbackRegionFromIndex(int index) static DiscIO::Region UpdateFallbackRegionFromIndex(int index)
{ {
@ -326,11 +312,11 @@ void GeneralPane::OnSaveConfig()
Config::ConfigChangeCallbackGuard config_guard; Config::ConfigChangeCallbackGuard config_guard;
auto& settings = SConfig::GetInstance(); auto& settings = SConfig::GetInstance();
/* if (AutoUpdateChecker::SystemSupportsAutoUpdates()) if (AutoUpdateChecker::SystemSupportsAutoUpdates())
{ {
Settings::Instance().SetAutoUpdateTrack( Settings::Instance().SetAutoUpdateTrack(
UpdateTrackFromIndex(m_combobox_update_track->currentIndex())); UpdateTrackFromIndex(m_combobox_update_track->currentIndex()));
}*/ }
#ifdef USE_DISCORD_PRESENCE #ifdef USE_DISCORD_PRESENCE
Discord::SetDiscordPresenceEnabled(m_checkbox_discord_presence->isChecked()); Discord::SetDiscordPresenceEnabled(m_checkbox_discord_presence->isChecked());
@ -341,9 +327,11 @@ void GeneralPane::OnSaveConfig()
DolphinAnalytics::Instance().ReloadConfig(); DolphinAnalytics::Instance().ReloadConfig();
#endif #endif
Config::SetBaseOrCurrent(Config::MAIN_CPU_THREAD, m_checkbox_dualcore->isChecked()); Config::SetBaseOrCurrent(Config::MAIN_CPU_THREAD, m_checkbox_dualcore->isChecked());
Settings::Instance().SetCheatsEnabled(m_checkbox_cheats->isChecked());
Config::SetBaseOrCurrent(Config::MAIN_OVERRIDE_REGION_SETTINGS, Config::SetBaseOrCurrent(Config::MAIN_OVERRIDE_REGION_SETTINGS,
m_checkbox_override_region_settings->isChecked()); m_checkbox_override_region_settings->isChecked());
Config::SetBase(Config::MAIN_AUTO_DISC_CHANGE, m_checkbox_auto_disc_change->isChecked()); Config::SetBase(Config::MAIN_AUTO_DISC_CHANGE, m_checkbox_auto_disc_change->isChecked());
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, m_checkbox_cheats->isChecked());
Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED, Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED,
m_combobox_speedlimit->currentIndex() * 0.1f); m_combobox_speedlimit->currentIndex() * 0.1f);
Settings::Instance().SetFallbackRegion( Settings::Instance().SetFallbackRegion(

View file

@ -30,12 +30,12 @@ static void ShowResult(QWidget* parent, WiiUtils::UpdateResult result)
case WiiUtils::UpdateResult::Succeeded: case WiiUtils::UpdateResult::Succeeded:
ModalMessageBox::information(parent, QObject::tr("Update completed"), ModalMessageBox::information(parent, QObject::tr("Update completed"),
QObject::tr("The emulated Wii console has been updated.")); QObject::tr("The emulated Wii console has been updated."));
DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX)); DiscIO::NANDImporter().ExtractCertificates();
break; break;
case WiiUtils::UpdateResult::AlreadyUpToDate: case WiiUtils::UpdateResult::AlreadyUpToDate:
ModalMessageBox::information(parent, QObject::tr("Update completed"), ModalMessageBox::information(parent, QObject::tr("Update completed"),
QObject::tr("The emulated Wii console is already up-to-date.")); QObject::tr("The emulated Wii console is already up-to-date."));
DiscIO::NANDImporter().ExtractCertificates(File::GetUserPath(D_WIIROOT_IDX)); DiscIO::NANDImporter().ExtractCertificates();
break; break;
case WiiUtils::UpdateResult::ServerFailed: case WiiUtils::UpdateResult::ServerFailed:
ModalMessageBox::critical(parent, QObject::tr("Update failed"), ModalMessageBox::critical(parent, QObject::tr("Update failed"),

View file

@ -751,6 +751,8 @@ Renderer::Renderer(std::unique_ptr<GLContext> main_gl_context, float backbuffer_
OSD::AddMessage("This device's performance may be poor.", 60000); OSD::AddMessage("This device's performance may be poor.", 60000);
} }
INFO_LOG_FMT(VIDEO, "Video Info: {}, {}, {}", g_ogl_config.gl_vendor, g_ogl_config.gl_renderer,
g_ogl_config.gl_version);
WARN_LOG_FMT(VIDEO, "Missing OGL Extensions: {}{}{}{}{}{}{}{}{}{}{}{}{}{}", WARN_LOG_FMT(VIDEO, "Missing OGL Extensions: {}{}{}{}{}{}{}{}{}{}{}{}{}{}",
g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "" : "DualSourceBlend ", g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "" : "DualSourceBlend ",
g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? "" : "PrimitiveRestart ", g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? "" : "PrimitiveRestart ",