5#define DEBUG_NDOF_DRIVER false
31#define kConnexionClientModeTakeOver 1
32#define kConnexionMaskAll 0x3fff
33#define kConnexionMaskAllButtons 0xffffffff
34#define kConnexionCmdHandleButtons 2
35#define kConnexionCmdHandleAxis 3
36#define kConnexionCmdAppSpecific 10
37#define kConnexionMsgDeviceState '3dSR'
38#define kConnexionCtlGetDeviceID '3did'
76#define DECLARE_FUNC(name) name##_ptr name = nullptr
88 void *func = dlsym(
module, func_name);
92 printf(
"'%s' loaded :D\n", func_name);
95 printf(
"<!> %s\n", dlerror());
102#define LOAD_FUNC(name) name = (name##_ptr)load_func(module, #name)
112 module = dlopen("/Library/Frameworks/3DconnexionClient.framework/3DconnexionClient",
113 RTLD_LAZY | RTLD_LOCAL);
118 if (SetConnexionHandlers !=
nullptr) {
140 printf(
"<!> %s\n", dlerror());
159 printf(
"ndof: device added\n");
165 int16_t vendorID = result >> 16;
166 int16_t productID = result & 0xffff;
174 printf(
"ndof: device removed\n");
188 switch (s->command) {
191 const int t[3] = {s->axis[0], -(s->axis[2]), s->axis[1]};
192 const int r[3] = {-(s->axis[3]), s->axis[5], -(s->axis[4])};
202#ifdef DEBUG_NDOF_BUTTONS
203 printf(
"button bits: 0x%08x\n", button_bits);
211 printf(
"ndof: app-specific command, param = %hd, value = %d\n", s->param, s->value);
215 printf(
"ndof: mystery device command %d\n", s->command);
231 const bool separate_thread =
false;
240 printf(
"ndof: error %d while setting up handlers\n",
error);
258 UnregisterConnexionClient(
clientID);
259 CleanupConnexionHandlers();
static void DeviceAdded(uint32_t)
void(* CleanupConnexionHandlers_ptr)()
static GHOST_NDOFManager * ndof_manager
static void DeviceRemoved(uint32_t)
uint16_t(* RegisterConnexionClient_ptr)(uint32_t signature, const char *name, uint16_t mode, uint32_t mask)
int16_t(* InstallConnexionHandlers_ptr)(MessageHandler, AddedHandler, RemovedHandler)
#define kConnexionCmdAppSpecific
int16_t(* SetConnexionHandlers_ptr)(MessageHandler, AddedHandler, RemovedHandler, bool)
void(* SetConnexionClientButtonMask_ptr)(uint16_t clientID, uint32_t buttonMask)
#define kConnexionCmdHandleButtons
static bool load_driver_functions()
void(* RemovedHandler)(uint32_t)
static void unload_driver()
static bool has_old_driver
void(* MessageHandler)(uint32_t, uint32_t msg_type, void *msg_arg)
static bool driver_loaded
#define DECLARE_FUNC(name)
#define kConnexionMsgDeviceState
#define kConnexionMaskAll
static bool has_new_driver
#define kConnexionCtlGetDeviceID
#define kConnexionCmdHandleAxis
static void * load_func(void *module, const char *func_name)
#define kConnexionMaskAllButtons
static void DeviceEvent(uint32_t, uint32_t msg_type, void *msg_arg)
void(* AddedHandler)(uint32_t)
void(* UnregisterConnexionClient_ptr)(uint16_t clientID)
#define kConnexionClientModeTakeOver
int16_t(* ConnexionClientControl_ptr)(uint16_t clientID, uint32_t message, int32_t param, int32_t *result)
static GHOST_SystemCocoa * ghost_system
bool available() override
GHOST_NDOFManagerCocoa(GHOST_System &)
~GHOST_NDOFManagerCocoa() override
void updateButtonsBitmask(int button_bits, uint64_t time)
void updateTranslation(const int t[3], uint64_t time)
void updateRotation(const int r[3], uint64_t time)
bool setDevice(unsigned short vendor_id, unsigned short product_id)
void notifyExternalEventProcessed()
uint64_t getMilliSeconds() const override
ccl_device_inline float4 mask(const int4 mask, const float4 a)
static void error(const char *str)
unsigned __int64 uint64_t