New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a background thread to detect the GC adapter #2330
Add a background thread to detect the GC adapter #2330
Conversation
|
||
wxCheckBox* const gamecube_adapter = new wxCheckBox(this, wxID_ANY, _("Direct Connect")); | ||
gamecube_adapter->Bind(wxEVT_CHECKBOX, &ControllerConfigDiag::OnGameCubeAdapter, this); | ||
m_adapter_status = new wxStaticText(this, wxID_ANY, _("")); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
8e987ad
to
a5984a7
Compare
Probably should disable the thread when the direct connect option is unchecked. |
There should not be an option to run the thread (as opposed to disabling direct connection entirely), as there would be no point changing it. Can you please use the libusb hotplug API where available? I don't think it supports Windows, but it supports the other major operating systems. This avoids the delay of polling. I haven't really looked at the code, but I don't understand why you would need an additional thread to ensure the device stays connected when you already have one that detects if it is connected. |
@comex the Read() thread does not detect anything, it merely performs a dumb read & copy, adding stuff into that loop may add undesirable latency to inputs. However using the hotplug API is a good idea (but still needs a thread on its own, because hotplug needs blocking or frequent calls to handle_events()), so I'm working on integrating both solutions (the first one I coded and the hotplug) and use whichever is available on the platform using the libusb capabilities. |
Is there anything else blocking on this? It's pretty great. |
static std::thread s_adapter_detect_thread; | ||
static Common::Flag s_adapter_detect_thread_running; | ||
|
||
static std::function<void(void)> s_detect_callback; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This scanning thread either polls libusb or checks every 500ms for a change depending on host capabilities. The GC Adapter can now be plugged and unplugged at any time when dolphin is open, it will be used if the direct connect option is set.
7a44f2a
to
ec7445d
Compare
Add a background thread to detect the GC adapter
There definitely needs to be an option to disable this thread. It was causing false button presses on my USB DInput Logitech PS3 controller when emulating the classic controller on Wii. It was driving me mad so I decided to track down the exact update that introduced this bug. |
see pr #2744 |
This should take care of connecting/disconnecting the GC adapter while dolphin is running; previously, dolphin would simply disable the functionality if the adapter wasn’t available on startup.
The thread polls libusb every 500ms if no adapter is found, and it receives a callback from the controller window where it displays the current adapter status (Found/Not Found/Driver not detected).
Why it's not perfect: