From 50e55f4fca6b70e34f6ef4673e8b7f512a95ce24 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Sun, 14 Sep 2025 14:30:46 +0100 Subject: [PATCH] mtp: support overriding vid/pid. --- sphaira/CMakeLists.txt | 2 +- sphaira/include/app.hpp | 4 ++++ sphaira/source/app.cpp | 5 ++++- sphaira/source/haze_helper.cpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sphaira/CMakeLists.txt b/sphaira/CMakeLists.txt index 7d9bfa2..35beda0 100644 --- a/sphaira/CMakeLists.txt +++ b/sphaira/CMakeLists.txt @@ -394,7 +394,7 @@ endif() if (ENABLE_LIBHAZE) FetchContent_Declare(libhaze GIT_REPOSITORY https://github.com/ITotalJustice/libhaze.git - GIT_TAG f0b2a14 + GIT_TAG d60ba60 ) FetchContent_MakeAvailable(libhaze) diff --git a/sphaira/include/app.hpp b/sphaira/include/app.hpp index 72c2328..dc39b6f 100644 --- a/sphaira/include/app.hpp +++ b/sphaira/include/app.hpp @@ -338,6 +338,10 @@ public: // todo: move this into it's own menu option::OptionLong m_text_scroll_speed{"accessibility", "text_scroll_speed", 1}; // normal + // mtp options. + option::OptionLong m_mtp_vid{"mtp", "vid", 0x057e}; // nintendo + option::OptionLong m_mtp_pid{"mtp", "pid", 0x201d}; // switch + std::shared_ptr m_fs{}; audio::SongID m_background_music{}; diff --git a/sphaira/source/app.cpp b/sphaira/source/app.cpp index 417942e..3b161db 100644 --- a/sphaira/source/app.cpp +++ b/sphaira/source/app.cpp @@ -1427,7 +1427,7 @@ App::App(const char* argv0) { // init fs for app use. m_fs = std::make_shared(true); - auto cb = [](const mTCHAR *Section, const mTCHAR *Key, const mTCHAR *Value, void *UserData) -> int { + static const auto cb = [](const mTCHAR *Section, const mTCHAR *Key, const mTCHAR *Value, void *UserData) -> int { auto app = static_cast(UserData); if (!std::strcmp(Section, INI_SECTION)) { @@ -1478,6 +1478,9 @@ App::App(const char* argv0) { else if (app->m_nsz_compress_ldm.LoadFrom(Key, Value)) {} else if (app->m_nsz_compress_block.LoadFrom(Key, Value)) {} else if (app->m_nsz_compress_block_exponent.LoadFrom(Key, Value)) {} + } else if (!std::strcmp(Section, "mtp")) { + if (app->m_mtp_vid.LoadFrom(Key, Value)) {} + else if (app->m_mtp_pid.LoadFrom(Key, Value)) {} } return 1; diff --git a/sphaira/source/haze_helper.cpp b/sphaira/source/haze_helper.cpp index e7138b1..afc2c4d 100644 --- a/sphaira/source/haze_helper.cpp +++ b/sphaira/source/haze_helper.cpp @@ -579,7 +579,7 @@ bool Init() { g_fs_entries.emplace_back(std::make_shared("install", "Install (NSP, XCI, NSZ, XCZ)")); g_should_exit = false; - if (!::haze::Initialize(haze_callback, THREAD_PRIO, THREAD_CORE, g_fs_entries)) { + if (!::haze::Initialize(haze_callback, THREAD_PRIO, THREAD_CORE, g_fs_entries, App::GetApp()->m_mtp_vid.Get(), App::GetApp()->m_mtp_pid.Get())) { return false; }