Skip to content
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

Android: Detect GCAdapter hotplug using BroadcastReceiver #13260

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JosJuice
Copy link
Member

@JosJuice JosJuice commented Jan 2, 2025

We can register a BroadcastReceiver to have Android tell us when a GC adapter gets connected or disconnected instead of having a loop where we continuously call SleepCurrentThread(1000) and poll the current status. When waiting for a GC adapter to connect, this both reduces power usage and improves responsiveness. Additionally, we can get rid of the Reset call from the read thread, making PR #13203 unnecessary.

This isn't how we name things in Java/Kotlin.
We can register a BroadcastReceiver to have Android tell us when a GC
adapter gets connected instead of having a loop where we continuously
call SleepCurrentThread(1000) and poll the current status. When waiting
for a GC adapter to connect, this both reduces power usage and improves
responsiveness.

Note that I made openAdapter get the UsbDevice that's been stored by the
hotplug code instead of having openAdapter find the UsbDevice on its own
like before. This is only because I want to ensure that the UsbDevice
being tracked for disconnection is the same as the UsbDevice actually
being used, in case the user has multiple adapters connected.
This lets us get rid of the Reset call in ProcessInputPayload, which was
causing us some threading headaches (see 74ed5e5). Instead we handle
disconnection in the same way as the libusb implementation does.
This reverts commit 74ed5e5.
It solves a problem that no longer exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant