From 6e22e145a0aa06a49741ff55b4bcd85e69c210a6 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 18 Mar 2025 02:23:09 -0500 Subject: [PATCH] HW/SI: Don't require waiting a second before disconnecting an SIDevice. --- Source/Core/Core/HW/SI/SI.cpp | 22 ++++++++++++---------- Source/Core/Core/HW/SI/SI.h | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/HW/SI/SI.cpp b/Source/Core/Core/HW/SI/SI.cpp index bd856733a2..461ade8f1b 100644 --- a/Source/Core/Core/HW/SI/SI.cpp +++ b/Source/Core/Core/HW/SI/SI.cpp @@ -90,7 +90,7 @@ void SerialInterfaceManager::ChangeDeviceCallback(Core::System& system, u64 user { // The purpose of this callback is to simply re-enable device changes. auto& si = system.GetSerialInterface(); - si.m_channel[user_data].has_recent_device_change = false; + si.m_channel[user_data].has_recent_device_unplug = false; } void SerialInterfaceManager::UpdateInterrupts() @@ -201,7 +201,7 @@ void SerialInterfaceManager::DoState(PointerWrap& p) p.Do(m_channel[i].in_hi.hex); p.Do(m_channel[i].in_lo.hex); p.Do(m_channel[i].out.hex); - p.Do(m_channel[i].has_recent_device_change); + p.Do(m_channel[i].has_recent_device_unplug); std::unique_ptr& device = m_channel[i].device; SIDevices type = device->GetDeviceType(); @@ -269,7 +269,7 @@ void SerialInterfaceManager::Init() m_channel[i].out.hex = 0; m_channel[i].in_hi.hex = 0; m_channel[i].in_lo.hex = 0; - m_channel[i].has_recent_device_change = false; + m_channel[i].has_recent_device_unplug = false; auto& movie = m_system.GetMovie(); if (movie.IsMovieActive()) @@ -511,7 +511,7 @@ void SerialInterfaceManager::ChangeDeviceDeterministic(SIDevices device, int cha { if (channel < 0 || channel >= MAX_SI_CHANNELS) return; - if (m_channel[channel].has_recent_device_change) + if (m_channel[channel].has_recent_device_unplug) return; if (GetDeviceType(channel) != SIDEVICE_NONE) @@ -520,18 +520,20 @@ void SerialInterfaceManager::ChangeDeviceDeterministic(SIDevices device, int cha device = SIDEVICE_NONE; } + // TODO: Resetting this state may not be necessary or accurate. m_channel[channel].out.hex = 0; m_channel[channel].in_hi.hex = 0; m_channel[channel].in_lo.hex = 0; - SetNoResponse(channel); - AddDevice(device, channel); - // Prevent additional device changes on this channel for one second. - m_channel[channel].has_recent_device_change = true; - m_system.GetCoreTiming().ScheduleEvent(m_system.GetSystemTimers().GetTicksPerSecond(), - m_event_type_change_device, channel); + if (device == SIDEVICE_NONE) + { + // Prevent additional device changes on this channel for one second. + m_channel[channel].has_recent_device_unplug = true; + m_system.GetCoreTiming().ScheduleEvent(m_system.GetSystemTimers().GetTicksPerSecond(), + m_event_type_change_device, channel); + } } void SerialInterfaceManager::UpdateDevices() diff --git a/Source/Core/Core/HW/SI/SI.h b/Source/Core/Core/HW/SI/SI.h index 9bd9f707a2..731b9b5c19 100644 --- a/Source/Core/Core/HW/SI/SI.h +++ b/Source/Core/Core/HW/SI/SI.h @@ -131,7 +131,7 @@ private: USIChannelIn_Lo in_lo{}; std::unique_ptr device; - bool has_recent_device_change = false; + bool has_recent_device_unplug = false; }; // SI Poll: Controls how often a device is polled