mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #10502 from Pokechu22/defer-gcadapter
GCAdapter: Defer initialization until MainWindow::InitControllers
This commit is contained in:
@ -75,7 +75,7 @@ static bool s_libusb_hotplug_enabled = false;
|
||||
static libusb_hotplug_callback_handle s_hotplug_handle;
|
||||
#endif
|
||||
|
||||
static LibusbUtils::Context s_libusb_context;
|
||||
static std::unique_ptr<LibusbUtils::Context> s_libusb_context;
|
||||
|
||||
static u8 s_endpoint_in = 0;
|
||||
static u8 s_endpoint_out = 0;
|
||||
@ -172,7 +172,7 @@ static void ScanThreadFunc()
|
||||
if (s_libusb_hotplug_enabled)
|
||||
{
|
||||
if (libusb_hotplug_register_callback(
|
||||
s_libusb_context,
|
||||
*s_libusb_context,
|
||||
(libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED |
|
||||
LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT),
|
||||
LIBUSB_HOTPLUG_ENUMERATE, 0x057e, 0x0337, LIBUSB_HOTPLUG_MATCH_ANY, HotplugCallback,
|
||||
@ -218,6 +218,8 @@ void Init()
|
||||
if (s_handle != nullptr)
|
||||
return;
|
||||
|
||||
s_libusb_context = std::make_unique<LibusbUtils::Context>();
|
||||
|
||||
if (Core::GetState() != Core::State::Uninitialized && Core::GetState() != Core::State::Starting)
|
||||
{
|
||||
if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond())
|
||||
@ -240,7 +242,7 @@ void StartScanThread()
|
||||
{
|
||||
if (s_adapter_detect_thread_running.IsSet())
|
||||
return;
|
||||
if (!s_libusb_context.IsValid())
|
||||
if (!s_libusb_context->IsValid())
|
||||
return;
|
||||
s_adapter_detect_thread_running.Set(true);
|
||||
s_adapter_detect_thread = std::thread(ScanThreadFunc);
|
||||
@ -266,7 +268,7 @@ static void Setup()
|
||||
s_controller_type.fill(ControllerTypes::CONTROLLER_NONE);
|
||||
s_controller_rumble.fill(0);
|
||||
|
||||
s_libusb_context.GetDeviceList([](libusb_device* device) {
|
||||
s_libusb_context->GetDeviceList([](libusb_device* device) {
|
||||
if (CheckDeviceAccess(device))
|
||||
{
|
||||
// Only connect to a single adapter in case the user has multiple connected
|
||||
@ -397,9 +399,10 @@ void Shutdown()
|
||||
{
|
||||
StopScanThread();
|
||||
#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102
|
||||
if (s_libusb_context.IsValid() && s_libusb_hotplug_enabled)
|
||||
libusb_hotplug_deregister_callback(s_libusb_context, s_hotplug_handle);
|
||||
if (s_libusb_context->IsValid() && s_libusb_hotplug_enabled)
|
||||
libusb_hotplug_deregister_callback(*s_libusb_context, s_hotplug_handle);
|
||||
#endif
|
||||
s_libusb_context.reset();
|
||||
Reset();
|
||||
|
||||
s_status = NO_ADAPTER_DETECTED;
|
||||
|
Reference in New Issue
Block a user