diff --git a/UnleashedRecomp/api/SWA/HUD/Loading/Loading.h b/UnleashedRecomp/api/SWA/HUD/Loading/Loading.h index a70dad0..27f1c9a 100644 --- a/UnleashedRecomp/api/SWA/HUD/Loading/Loading.h +++ b/UnleashedRecomp/api/SWA/HUD/Loading/Loading.h @@ -20,8 +20,12 @@ namespace SWA class CLoading { public: - SWA_INSERT_PADDING(0x128); - bool m_IsVisible; + SWA_INSERT_PADDING(0xD8); + be m_pUnk; + SWA_INSERT_PADDING(0x3C); + Chao::CSD::RCPtr m_rcNightToDay; + SWA_INSERT_PADDING(0x0C); + be m_IsVisible; SWA_INSERT_PADDING(0x0C); be m_LoadingDisplayType; SWA_INSERT_PADDING(0x65); diff --git a/UnleashedRecomp/app.h b/UnleashedRecomp/app.h index 5479420..6505e18 100644 --- a/UnleashedRecomp/app.h +++ b/UnleashedRecomp/app.h @@ -7,6 +7,7 @@ class App public: static inline bool s_isInit; static inline bool s_isMissingDLC; + static inline bool s_isLoading; static inline ELanguage s_language; diff --git a/UnleashedRecomp/hid/driver/sdl_hid.cpp b/UnleashedRecomp/hid/driver/sdl_hid.cpp index 3bd6a96..76e8f9a 100644 --- a/UnleashedRecomp/hid/driver/sdl_hid.cpp +++ b/UnleashedRecomp/hid/driver/sdl_hid.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #define TRANSLATE_INPUT(S, X) SDL_GameControllerGetButton(controller, S) << FirstBitLow(X) #define VIBRATION_TIMEOUT_MS 5000 @@ -163,6 +164,10 @@ inline Controller* FindController(int which) static void SetControllerInputDevice(Controller* controller) { g_activeController = controller; + + if (App::s_isLoading) + return; + hid::detail::g_inputDevice = controller->GetInputDevice(); hid::detail::g_inputDeviceController = hid::detail::g_inputDevice; } diff --git a/UnleashedRecomp/patches/resident_patches.cpp b/UnleashedRecomp/patches/resident_patches.cpp index 42efec6..1a27622 100644 --- a/UnleashedRecomp/patches/resident_patches.cpp +++ b/UnleashedRecomp/patches/resident_patches.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include const char* m_pStageID; @@ -13,10 +15,12 @@ void GetStageIDMidAsmHook(PPCRegister& r5) m_pStageID = *(xpointer*)g_memory.Translate(r5.u32); } -// Loading screen hook. +// SWA::Message::MsgRequestStartLoading::Impl PPC_FUNC_IMPL(__imp__sub_824DCF38); PPC_FUNC(sub_824DCF38) { + App::s_isLoading = true; + // TODO: use the actual PS3 loading screen ("n_2_d"). if (Config::TimeOfDayTransition == ETimeOfDayTransition::PlayStation) { @@ -35,6 +39,18 @@ PPC_FUNC(sub_824DCF38) __imp__sub_824DCF38(ctx, base); } +// SWA::CLoading::Update +PPC_FUNC_IMPL(__imp__sub_824DAB60); +PPC_FUNC(sub_824DAB60) +{ + auto pLoading = (SWA::CLoading*)g_memory.Translate(ctx.r3.u32); + + __imp__sub_824DAB60(ctx, base); + + if (!pLoading->m_LoadingDisplayType) + App::s_isLoading = false; +} + // Load voice language files. PPC_FUNC_IMPL(__imp__sub_824EB9B0); PPC_FUNC(sub_824EB9B0) @@ -112,10 +128,16 @@ void LoadingScreenControllerMidAsmHook() 0x820301C4, // 360_sonic3 0x820301D0, // 360_evil 0x820301DC, // 360_robo - 0x820301E8, // 360_super + 0x820301E8 // 360_super }; - const char* prefix = Config::ControllerIcons == EControllerIcons::PlayStation ? "ps3" : "360"; + auto isPlayStation = Config::ControllerIcons == EControllerIcons::PlayStation; + + if (Config::ControllerIcons == EControllerIcons::Auto) + isPlayStation = hid::detail::g_inputDeviceController == hid::detail::EInputDevice::PlayStation; + + const char* prefix = isPlayStation ? "ps3" : "360"; + for (auto address : STR_ADDRESSES) memcpy(g_memory.Translate(address), prefix, 3); }