summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-03-18 02:23:09 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2025-05-04 15:00:48 -0500
commit6e22e145a0aa06a49741ff55b4bcd85e69c210a6 (patch)
tree01e65f6c3820f4e8ddab7b1dab5490262adeaa28 /Source
parentd2db9d95906de73d704bd0f32bd1ee79f4a442f6 (diff)
HW/SI: Don't require waiting a second before disconnecting an SIDevice.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/SI/SI.cpp22
-rw-r--r--Source/Core/Core/HW/SI/SI.h2
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<ISIDevice>& 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<ISIDevice> device;
- bool has_recent_device_change = false;
+ bool has_recent_device_unplug = false;
};
// SI Poll: Controls how often a device is polled