5#define DEBUG_NDOF_DRIVER false
33#define kConnexionClientModeTakeOver 1
34#define kConnexionMaskAll 0x3fff
35#define kConnexionMaskAxis 0x3f00
36#define kConnexionMaskNoButtons 0x0
37#define kConnexionMaskAllButtons 0xffffffff
38#define kConnexionCmdHandleButtons 2
39#define kConnexionCmdHandleAxis 3
40#define kConnexionCmdAppSpecific 10
41#define kConnexionCmdAppEvent 11
42#define kConnexionMsgDeviceState '3dSR'
43#define kConnexionCtlGetDeviceID '3did'
80#define DECLARE_FUNC(name) name##_ptr name = nullptr
91 void *func = dlsym(
module, func_name);
95 printf(
"'%s' loaded :D\n", func_name);
98 printf(
"<!> %s\n", dlerror());
105#define LOAD_FUNC(name) name = (name##_ptr)load_func(module, #name)
115 module = dlopen("/Library/Frameworks/3DconnexionClient.framework/3DconnexionClient",
116 RTLD_LAZY | RTLD_LOCAL);
121 if (SetConnexionHandlers !=
nullptr) {
135 printf(
"<!> %s\n", dlerror());
152 printf(
"ndof: device added\n");
158 const int16_t vendorID =
result >> 16;
159 const int16_t productID =
result & 0xffff;
167 printf(
"ndof: device removed\n");
171static void DeviceEvent(uint32_t , uint32_t msg_type,
void *msg_arg)
184 const int t[3] = {s->
axis[0], -(s->
axis[2]), s->
axis[1]};
185 const int r[3] = {-(s->
axis[3]), s->
axis[5], -(s->
axis[4])};
194 const int button_bits = s->
buttons;
195#ifdef DEBUG_NDOF_BUTTONS
196 printf(
"button bits: 0x%08x\n", button_bits);
203 const int button_number = s->
value;
205#ifdef DEBUG_NDOF_BUTTONS
206 printf(
"button number: %d, pressed: %d\n", button_number, pressed);
214 printf(
"ndof: app-specific command, param = %hd, value = %d\n", s->
param, s->
value);
236 printf(
"ndof: error %d while setting up handlers\n",
error);
241 const NSDictionary *dictInfos =
242 [NSBundle bundleWithPath:
@"/Library/Frameworks/3DconnexionClient.framework"]
244 NSString *strVersion = [dictInfos objectForKey:(NSString *)kCFBundleVersionKey];
246 const bool has_new_driver = compare != NSOrderedAscending;
261 SetConnexionClientButtonMask(
clientID, button_mask);
268 UnregisterConnexionClient(
clientID);
269 CleanupConnexionHandlers();
static void DeviceAdded(uint32_t)
void(* CleanupConnexionHandlers_ptr)()
static GHOST_NDOFManager * ndof_manager
static void DeviceRemoved(uint32_t)
#define kConnexionMaskNoButtons
uint16_t(* RegisterConnexionClient_ptr)(uint32_t signature, const char *name, uint16_t mode, uint32_t mask)
#define kConnexionCmdAppSpecific
int16_t(* SetConnexionHandlers_ptr)(MessageHandler, AddedHandler, RemovedHandler, bool)
#define kConnexionCmdAppEvent
void(* SetConnexionClientButtonMask_ptr)(uint16_t clientID, uint32_t buttonMask)
#define kConnexionCmdHandleButtons
static bool load_driver_functions()
void(* RemovedHandler)(uint32_t)
static void unload_driver()
#define kConnexionMaskAxis
static NSString * new_driver_minimal_version
void(* MessageHandler)(uint32_t, uint32_t msg_type, void *msg_arg)
static bool driver_loaded
#define DECLARE_FUNC(name)
#define kConnexionMsgDeviceState
#define kConnexionMaskAll
#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
unsigned long long int uint64_t
bool available() override
GHOST_NDOFManagerCocoa(GHOST_System &)
~GHOST_NDOFManagerCocoa() override
GHOST_NDOFManager(GHOST_System &)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static void error(const char *str)
static struct PyModuleDef module