I'm trying to make a native module for React Native/Expo using Expo Modules API to support game controllers in my app.
On iOS there is a notification/event that is posted immediately after a game controller gets connected to the device called GCControllerDidConnect, and another similar notification/event called GCControllerDidDisconnect that is posted immediately after a game controller is disconnected.
I was not able to find an equivalent event on Android for this purpose.
Based on Android's developer docs, it is suggested to call getSources()
to get a list of connected input devices and check for certain properties on the returned values to ensure a game controller with the buttons/controls that are needed in your app has been connected.
The problem with this approach is that I need to manually check the connected devices with an arbitrary interval to know when the game controller I need has been connected.
Is there something that I'm missing? Can you think of a way to circumvent this limitation?
All ideas are appreciated!