DualSense disconnects after around 15 minutes on macOS
DualSense Controller Disconnects on macOS Bluetooth with pydualsense
Issue Description
Firstly, many thanks for this library, appreciate all the effort you've put in! <3
I have used pydualsense library to run a webhook server to emulate gamepad API with complete feature support (as exposed by pydualsense)
DualSense controller unexpectedly disconnects when using pydualsense library on macOS over Bluetooth, despite active use and button presses. Digging at the Console multiple disconnection-related logs were observed in system logs
I am wondering if they indicate conflicts between pydualsense and macOS's native game controller/bluetooth management.
Environment
- OS: macOS 15.5 (Sonoma) on M2 Macbook Air
- Library: pydualsense
- Connection: Bluetooth
- Controller: PS5 DualSense Wireless Controller
Log Analysis
status 722 disconnected
Received disconnection result for "HID Host" profile on device 14:3A:9A:B6:67:97 - result was 0 - reason was 10436
Received disconnection indication on device DualSense Wireless Controller reason 436
Invalidate: CBDiscovery, CID 0xFDDE0001, DsFl 0x200000 < Connections >, from gamecontrollerd:11489
isIdle for 906.47 seconds - will disconnect if permitted
https://gist.github.com/DroidThug/42cd23aad9a58e5185c4fd495c3243b6 Here is the complete log around the time of disconnect.
Using a USB connection does seem to help - have not seen such disconnects.
Will verify if periodically re-initiating the controller session from pydualsense will help, allowing the system to think the controller is alive, but until then just wanted your opinion, and bring this issue to your notice.
Many thanks
It seems like re-attempting disconnect + connect at intervals of 600s did not do the job either
https://github.com/RPCS3/rpcs3/issues/12290
here is a similar issue, they too have used hidapi, looks like when hidapi is given exclusive controller access, macOS disconnects the controller
hidapi includes a non-exclusive method for the controller, I shall attempt to include these fixes and see if that works
This fixed the bluetooth disconnection issue after 15 minutes
However in the PR, I have made libhidapi open non-exclusive connection by default.
Technically, the USB connection works with no disconnect issues, so if needed we may have to assign exclusivity based on device connection or we may be able to provide the choice to the user as a parameter?
In my opinion I think default non-exclusive access is better as the controller connection can be shared by other applications in parallel.
Note: This does not affect other platforms