IOS HLE: Replace is_hardware with a proper device type
is_hardware is an obscure name (what does hardware mean?) and it forces us to assume that anything that !is_hardware is a FileIO device. This assumption prevents properly restoring OH0 child devices (which will be implemented in the USB PR), so this commit replaces the is_hardware bool with a device type.
This commit is contained in:
parent
91044178ef
commit
a68aea1ace
|
@ -112,6 +112,7 @@ template <typename T>
|
|||
std::shared_ptr<T> AddDevice(const char* device_name)
|
||||
{
|
||||
auto device = std::make_shared<T>(num_devices, device_name);
|
||||
_assert_(device->GetDeviceType() == IWII_IPC_HLE_Device::DeviceType::Static);
|
||||
s_device_map[num_devices] = device;
|
||||
num_devices++;
|
||||
return device;
|
||||
|
@ -172,7 +173,7 @@ void Reset(bool hard)
|
|||
|
||||
for (auto& dev : s_fdmap)
|
||||
{
|
||||
if (dev && !dev->IsHardware())
|
||||
if (dev && dev->GetDeviceType() != IWII_IPC_HLE_Device::DeviceType::Static)
|
||||
{
|
||||
// close all files and delete their resources
|
||||
dev->Close(0, true);
|
||||
|
@ -285,12 +286,7 @@ void DoState(PointerWrap& p)
|
|||
}
|
||||
|
||||
for (const auto& entry : s_device_map)
|
||||
{
|
||||
if (entry.second->IsHardware())
|
||||
{
|
||||
entry.second->DoState(p);
|
||||
}
|
||||
}
|
||||
entry.second->DoState(p);
|
||||
|
||||
if (p.GetMode() == PointerWrap::MODE_READ)
|
||||
{
|
||||
|
@ -300,18 +296,21 @@ void DoState(PointerWrap& p)
|
|||
p.Do(exists);
|
||||
if (exists)
|
||||
{
|
||||
u32 isHw = 0;
|
||||
p.Do(isHw);
|
||||
if (isHw)
|
||||
auto device_type = IWII_IPC_HLE_Device::DeviceType::Static;
|
||||
p.Do(device_type);
|
||||
switch (device_type)
|
||||
{
|
||||
u32 hwId = 0;
|
||||
p.Do(hwId);
|
||||
s_fdmap[i] = AccessDeviceByID(hwId);
|
||||
case IWII_IPC_HLE_Device::DeviceType::Static:
|
||||
{
|
||||
u32 device_id = 0;
|
||||
p.Do(device_id);
|
||||
s_fdmap[i] = AccessDeviceByID(device_id);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
case IWII_IPC_HLE_Device::DeviceType::FileIO:
|
||||
s_fdmap[i] = std::make_shared<CWII_IPC_HLE_Device_FileIO>(i, "");
|
||||
s_fdmap[i]->DoState(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -331,9 +330,9 @@ void DoState(PointerWrap& p)
|
|||
p.Do(exists);
|
||||
if (exists)
|
||||
{
|
||||
u32 isHw = descriptor->IsHardware() ? 1 : 0;
|
||||
p.Do(isHw);
|
||||
if (isHw)
|
||||
auto device_type = descriptor->GetDeviceType();
|
||||
p.Do(device_type);
|
||||
if (device_type == IWII_IPC_HLE_Device::DeviceType::Static)
|
||||
{
|
||||
u32 hwId = descriptor->GetDeviceID();
|
||||
p.Do(hwId);
|
||||
|
|
|
@ -47,8 +47,8 @@ SIOCtlVBuffer::SIOCtlVBuffer(const u32 address) : m_Address(address)
|
|||
}
|
||||
|
||||
IWII_IPC_HLE_Device::IWII_IPC_HLE_Device(const u32 device_id, const std::string& device_name,
|
||||
const bool hardware)
|
||||
: m_name(device_name), m_device_id(device_id), m_is_hardware(hardware)
|
||||
const DeviceType type)
|
||||
: m_name(device_name), m_device_id(device_id), m_device_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p)
|
|||
{
|
||||
p.Do(m_name);
|
||||
p.Do(m_device_id);
|
||||
p.Do(m_is_hardware);
|
||||
p.Do(m_device_type);
|
||||
p.Do(m_is_active);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,14 @@ struct SIOCtlVBuffer
|
|||
class IWII_IPC_HLE_Device
|
||||
{
|
||||
public:
|
||||
IWII_IPC_HLE_Device(u32 device_id, const std::string& device_name, bool hardware = true);
|
||||
enum class DeviceType : u32
|
||||
{
|
||||
Static, // Devices which appear in s_device_map.
|
||||
FileIO, // FileIO devices which are created dynamically.
|
||||
};
|
||||
|
||||
IWII_IPC_HLE_Device(u32 device_id, const std::string& device_name,
|
||||
DeviceType type = DeviceType::Static);
|
||||
|
||||
virtual ~IWII_IPC_HLE_Device() = default;
|
||||
// Release any resources which might interfere with savestating.
|
||||
|
@ -81,17 +88,16 @@ public:
|
|||
virtual IPCCommandResult IOCtlV(u32 command_address);
|
||||
|
||||
virtual u32 Update() { return 0; }
|
||||
virtual bool IsHardware() const { return m_is_hardware; }
|
||||
virtual DeviceType GetDeviceType() const { return m_device_type; }
|
||||
virtual bool IsOpened() const { return m_is_active; }
|
||||
static IPCCommandResult GetDefaultReply();
|
||||
static IPCCommandResult GetNoReply();
|
||||
|
||||
std::string m_name;
|
||||
|
||||
protected:
|
||||
std::string m_name;
|
||||
// STATE_TO_SAVE
|
||||
u32 m_device_id;
|
||||
bool m_is_hardware;
|
||||
DeviceType m_device_type;
|
||||
bool m_is_active = false;
|
||||
|
||||
// Write out the IPC struct from command_address to number_of_commands numbers
|
||||
|
|
|
@ -66,7 +66,7 @@ void HLE_IPC_CreateVirtualFATFilesystem()
|
|||
|
||||
CWII_IPC_HLE_Device_FileIO::CWII_IPC_HLE_Device_FileIO(u32 device_id,
|
||||
const std::string& device_name)
|
||||
: IWII_IPC_HLE_Device(device_id, device_name, false) // not a real hardware
|
||||
: IWII_IPC_HLE_Device(device_id, device_name, DeviceType::FileIO)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
|
|||
static std::thread g_save_thread;
|
||||
|
||||
// Don't forget to increase this after doing changes on the savestate system
|
||||
static const u32 STATE_VERSION = 67; // Last changed in PR 4634
|
||||
static const u32 STATE_VERSION = 68; // Last changed in PR 4638
|
||||
|
||||
// Maps savestate versions to Dolphin versions.
|
||||
// Versions after 42 don't need to be added to this list,
|
||||
|
|
Loading…
Reference in New Issue