mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-25 00:14:15 +02:00
Open the 3D mouse non-exclusively on macOS
hidapi's macOS backend opens every device with kIOHIDOptionsTypeSeizeDevice unless told otherwise (hid_init() calls hid_darwin_set_open_exclusive(1) for backward compatibility). When 3DxWare is running it already holds the SpacePilot/SpaceMouse, so the seize fails, hid_open_path() returns NULL and HidBackend::scan() keeps retrying every 3 s without ever finding the device. Reported in discussion #599: a SpacePilot Pro (046d:c629) is listed by hid_enumerate() and works in 3DxWare, but has no effect in QET's macOS build. Enumeration never opens a device, so it did not exercise this. Guarded on HID_API_VERSION >= 0.12, where the setter first appeared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include <hidapi.h>
|
||||
#if defined(Q_OS_MACOS) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
|
||||
# include <hidapi_darwin.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
constexpr int SCAN_INTERVAL_MS = 3000;
|
||||
@@ -42,6 +45,11 @@ HidBackend::HidBackend(QObject *parent) :
|
||||
return;
|
||||
}
|
||||
m_hid_initialised = true;
|
||||
#if defined(Q_OS_MACOS) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
|
||||
//hidapi opens devices exclusively on macOS by default, which fails
|
||||
//while 3DxWare has the device open (discussion #599).
|
||||
hid_darwin_set_open_exclusive(0);
|
||||
#endif
|
||||
|
||||
m_read_timer = new QTimer(this);
|
||||
connect(m_read_timer, &QTimer::timeout, this, &HidBackend::readReports);
|
||||
|
||||
Reference in New Issue
Block a user