[macOS] Update hid_pad_handler.cpp to prevent DS4 from disconnecting (#12493)

Prevents DS4 (and possibly DS3) from disconnecting from bluetooth after 15 minutes by using hidapi's non-exclusive mode. 
The most recent version of hidapi, 0.12 from two months ago, added "macOS-specific function(s) to open device(s) in non-exclusive mode".
This commit is contained in:
shinra-electric 2022-08-11 06:14:37 +01:00 committed by GitHub
parent c51d3b5465
commit cba4c3cdc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,10 @@
#include "Emu/System.h" #include "Emu/System.h"
#include "pad_thread.h" #include "pad_thread.h"
#if defined(__APPLE__)
#include "3rdparty/hidapi/hidapi/mac/hidapi_darwin.h"
#endif
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
@ -63,6 +67,10 @@ bool hid_pad_handler<Device>::Init()
if (res != 0) if (res != 0)
fmt::throw_exception("%s hidapi-init error.threadproc", m_type); fmt::throw_exception("%s hidapi-init error.threadproc", m_type);
#if defined(__APPLE__)
hid_darwin_set_open_exclusive(0);
#endif
for (usz i = 1; i <= MAX_GAMEPADS; i++) // Controllers 1-n in GUI for (usz i = 1; i <= MAX_GAMEPADS; i++) // Controllers 1-n in GUI
{ {
m_controllers.emplace(m_name_string + std::to_string(i), std::make_shared<Device>()); m_controllers.emplace(m_name_string + std::to_string(i), std::make_shared<Device>());