JoyShockLibrary icon indicating copy to clipboard operation
JoyShockLibrary copied to clipboard

How To Check If Controller Is Disconnected?

Open michaelarts opened this issue 4 years ago • 1 comments

Hey again,

I've got everything working great except one thing: how do we check if a controller is disconnected? Right now I'm calling JslConnectDevices() and JslGetConnectedDeviceHandles() every frame to see if there have been any changes to the device. However, this seems to cause problems with the DS4 lightbar, as each time I call those functions the color gets turned off.

Basically I'm looking for a way to call something like JslIsControllerActive(int deviceID), and if that returns false I'll call JslConnectDevices and JslGetConnectedDeviceHandles to find a new device.

Thanks, this library is super awesome!!

Michael

michaelarts avatar Aug 14 '20 20:08 michaelarts

Hi Michael! Thanks for checking it out. It's best not to be reconnecting every frame, but you could have a time-out on your end. If the call-back for a particular device hasn't been called for too long, then do the reconnecting.

JibbSmart avatar Aug 20 '20 05:08 JibbSmart