diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index d0cf5bb92..020d57d8c 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -2153,9 +2153,6 @@ struct DreamLinkVmu : public maple_sega_vmu void OnSetup() override { - // Update useRealVmuMemory in case config changed - useRealVmuMemory = config::UsePhysicalVmuMemory; - // All data must be re-read memset(mirroredBlocks, 0, sizeof(mirroredBlocks)); @@ -2500,7 +2497,7 @@ struct DreamLinkPurupuru : public maple_sega_purupuru static std::list> dreamLinkVmus[2]; static std::list> dreamLinkPurupurus; -void createDreamLinkDevices(std::shared_ptr dreamlink, bool gameStart) +void createDreamLinkDevices(std::shared_ptr dreamlink, bool gameStart, bool stateLoaded) { const int bus = dreamlink->getBus(); @@ -2522,13 +2519,28 @@ void createDreamLinkDevices(std::shared_ptr dreamlink, bool gameStart } } - if (gameStart || !vmuFound) + if (gameStart || stateLoaded || !vmuFound) { if (!vmu) { vmu = std::make_shared(dreamlink); } + if (gameStart) + { + // Update useRealVmuMemory in case config changed + vmu->useRealVmuMemory = config::UsePhysicalVmuMemory; + } + else if (stateLoaded) + { + if (vmu->useRealVmuMemory) + { + // Disconnect from real VMU memory when a state is loaded + vmu->useRealVmuMemory = false; + os_notify("WARNING: Disconnected from physical VMU memory due to load state", 6000); + } + } + vmu->Setup(bus, i); if (!vmuFound && dev && dev->get_device_type() == MDT_SegaVMU && !vmu->useRealVmuMemory) { @@ -2558,12 +2570,13 @@ void createDreamLinkDevices(std::shared_ptr dreamlink, bool gameStart } } - if (gameStart || !rumbleFound) + if (gameStart || stateLoaded || !rumbleFound) { if (!rumble) { rumble = std::make_shared(dreamlink); } + rumble->Setup(bus, i); if (!rumbleFound) dreamLinkPurupurus.push_back(rumble); diff --git a/core/sdl/dreamlink.cpp b/core/sdl/dreamlink.cpp index 2c1974eb7..3f62d474f 100644 --- a/core/sdl/dreamlink.cpp +++ b/core/sdl/dreamlink.cpp @@ -46,7 +46,7 @@ #include #endif -void createDreamLinkDevices(std::shared_ptr dreamlink, bool gameStart); +void createDreamLinkDevices(std::shared_ptr dreamlink, bool gameStart, bool stateLoaded); void tearDownDreamLinkDevices(std::shared_ptr dreamlink); bool DreamLinkGamepad::isDreamcastController(int deviceIndex) @@ -146,21 +146,22 @@ void DreamLinkGamepad::registered() dreamlink->connect(); // Create DreamLink Maple Devices here just in case game is already running - createDreamLinkDevices(dreamlink, false); + createDreamLinkDevices(dreamlink, false, false); } } void DreamLinkGamepad::handleEvent(Event event, void *arg) { DreamLinkGamepad *gamepad = static_cast(arg); - if (gamepad->dreamlink != nullptr && event != Event::Terminate) { - createDreamLinkDevices(gamepad->dreamlink, event == Event::Start); + if (gamepad->dreamlink != nullptr) + { + if (event != Event::Terminate) { + createDreamLinkDevices(gamepad->dreamlink, event == Event::Start, event == Event::LoadState); + } + else { + gamepad->dreamlink->gameTermination(); + } } - - if (gamepad->dreamlink != nullptr && event == Event::Terminate) - { - gamepad->dreamlink->gameTermination(); - } } void DreamLinkGamepad::resetMappingToDefault(bool arcade, bool gamepad) { diff --git a/core/ui/settings_controls.cpp b/core/ui/settings_controls.cpp index b0a6576ed..e8ddb9c78 100644 --- a/core/ui/settings_controls.cpp +++ b/core/ui/settings_controls.cpp @@ -23,6 +23,10 @@ #include "vgamepad.h" #include "oslib/storage.h" +#if defined(USE_SDL) +#include "sdl/dreamlink.h" // For USE_DREAMCASTCONTROLLER +#endif + static float calcComboWidth(const char *biggestLabel) { return ImGui::CalcTextSize(biggestLabel).x + ImGui::GetStyle().FramePadding.x * 2.0f + ImGui::GetFrameHeight(); } @@ -937,7 +941,8 @@ void gui_settings_controls(bool& maple_devices_changed) { DisabledScope scope(game_started); OptionCheckbox("Use Physical VMU Memory", config::UsePhysicalVmuMemory, - "Enables direct read/write access to physical VMU memory via DreamPicoPort/DreamConn."); + "Enables direct read/write access to physical VMU memory via DreamPicoPort/DreamConn. " + "This is not compatible with load state events."); } #endif