diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 56a3003d0f..1915a7eb5f 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -500,7 +500,7 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("BBA_MAC", &m_bba_mac); for (size_t i = 0; i < std::size(m_SIDevice); ++i) { - core->Get(fmt::format("SIDevice{}", i), (u32*)&m_SIDevice[i], + core->Get(fmt::format("SIDevice{}", i), &m_SIDevice[i], (i == 0) ? SerialInterface::SIDEVICE_GC_CONTROLLER : SerialInterface::SIDEVICE_NONE); core->Get(fmt::format("AdapterRumble{}", i), &m_AdapterRumble[i], true); core->Get(fmt::format("SimulateKonga{}", i), &m_AdapterKonga[i], false); diff --git a/Source/Core/Core/HW/SI/SI_Device.cpp b/Source/Core/Core/HW/SI/SI_Device.cpp index e4637709bd..dfe74b4f0e 100644 --- a/Source/Core/Core/HW/SI/SI_Device.cpp +++ b/Source/Core/Core/HW/SI/SI_Device.cpp @@ -4,8 +4,11 @@ #include "Core/HW/SI/SI_Device.h" +#include #include +#include #include +#include #include @@ -21,6 +24,28 @@ namespace SerialInterface { +std::ostream& operator<<(std::ostream& stream, SIDevices device) +{ + stream << static_cast>(device); + return stream; +} + +std::istream& operator>>(std::istream& stream, SIDevices& device) +{ + std::underlying_type_t value; + + if (stream >> value) + { + device = static_cast(value); + } + else + { + device = SIDevices::SIDEVICE_NONE; + } + + return stream; +} + ISIDevice::ISIDevice(SIDevices device_type, int device_number) : m_device_number(device_number), m_device_type(device_type) { diff --git a/Source/Core/Core/HW/SI/SI_Device.h b/Source/Core/Core/HW/SI/SI_Device.h index c666f98805..b6418ec698 100644 --- a/Source/Core/Core/HW/SI/SI_Device.h +++ b/Source/Core/Core/HW/SI/SI_Device.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include "Common/CommonTypes.h" @@ -63,6 +64,9 @@ enum SIDevices : int SIDEVICE_COUNT, }; +std::ostream& operator<<(std::ostream& stream, SIDevices device); +std::istream& operator>>(std::istream& stream, SIDevices& device); + class ISIDevice { public: