Merge pull request #13172 from deReeperJosh/superchargersfix

IOS/USB: Reconnect HIDv4 Devices after shutdown
This commit is contained in:
JMC47 2024-11-05 15:02:22 -05:00 committed by GitHub
commit 7e1074b140
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -96,10 +96,11 @@ std::optional<IPCReply> USB_HIDv4::GetDeviceChange(const IOCtlRequest& request)
m_devicechange_hook_request = std::make_unique<IOCtlRequest>(GetSystem(), request.address); m_devicechange_hook_request = std::make_unique<IOCtlRequest>(GetSystem(), request.address);
// If there are pending changes, the reply is sent immediately (instead of on device // If there are pending changes, the reply is sent immediately (instead of on device
// insertion/removal). // insertion/removal).
if (m_has_pending_changes) if (m_has_pending_changes || m_is_shut_down)
{ {
TriggerDeviceChangeReply(); TriggerDeviceChangeReply();
m_has_pending_changes = false; m_has_pending_changes = false;
m_is_shut_down = false;
} }
return std::nullopt; return std::nullopt;
} }
@ -114,6 +115,7 @@ IPCReply USB_HIDv4::Shutdown(const IOCtlRequest& request)
memory.Write_U32(0xffffffff, m_devicechange_hook_request->buffer_out); memory.Write_U32(0xffffffff, m_devicechange_hook_request->buffer_out);
GetEmulationKernel().EnqueueIPCReply(*m_devicechange_hook_request, -1); GetEmulationKernel().EnqueueIPCReply(*m_devicechange_hook_request, -1);
m_devicechange_hook_request.reset(); m_devicechange_hook_request.reset();
m_is_shut_down = true;
} }
return IPCReply(IPC_SUCCESS); return IPCReply(IPC_SUCCESS);
} }

View File

@ -45,6 +45,7 @@ private:
static constexpr u8 HID_CLASS = 0x03; static constexpr u8 HID_CLASS = 0x03;
bool m_has_pending_changes = true; bool m_has_pending_changes = true;
bool m_is_shut_down = false;
std::mutex m_devicechange_hook_address_mutex; std::mutex m_devicechange_hook_address_mutex;
std::unique_ptr<IOCtlRequest> m_devicechange_hook_request; std::unique_ptr<IOCtlRequest> m_devicechange_hook_request;