13#define DEBUG_NDOF_DRIVER false
34#define kConnexionClientModeTakeOver 1
35#define kConnexionMaskAll 0x3fff
36#define kConnexionMaskAxis 0x3f00
37#define kConnexionMaskNoButtons 0x0
38#define kConnexionMaskAllButtons 0xffffffff
39#define kConnexionCmdHandleButtons 2
40#define kConnexionCmdHandleAxis 3
41#define kConnexionCmdAppSpecific 10
42#define kConnexionCmdAppEvent 11
43#define kConnexionMsgDeviceState '3dSR'
44#define kConnexionCtlGetDeviceID '3did'
81#define DECLARE_FUNC(name) name##_ptr name = nullptr
92 void *func = dlsym(
module, func_name);
96 printf(
"'%s' loaded :D\n", func_name);
99 printf(
"<!> %s\n", dlerror());
106#define LOAD_FUNC(name) name = (name##_ptr)load_func(module, #name)
116 module = dlopen("/Library/Frameworks/3DconnexionClient.framework/3DconnexionClient",
117 RTLD_LAZY | RTLD_LOCAL);
122 if (SetConnexionHandlers !=
nullptr) {
136 printf(
"<!> %s\n", dlerror());
153 printf(
"ndof: device added\n");
159 const int16_t vendorID = result >> 16;
160 const int16_t productID = result & 0xffff;
168 printf(
"ndof: device removed\n");
172static void DeviceEvent(uint32_t , uint32_t msg_type,
void *msg_arg)
185 const int t[3] = {s->
axis[0], -(s->
axis[2]), s->
axis[1]};
186 const int r[3] = {-(s->
axis[3]), s->
axis[5], -(s->
axis[4])};
195 const int button_bits = s->
buttons;
196#ifdef DEBUG_NDOF_BUTTONS
197 printf(
"button bits: 0x%08x\n", button_bits);
204 const int button_number = s->
value;
206#ifdef DEBUG_NDOF_BUTTONS
207 printf(
"button number: %d, pressed: %d\n", button_number, pressed);
215 printf(
"ndof: app-specific command, param = %hd, value = %d\n", s->
param, s->
value);
237 printf(
"ndof: error %d while setting up handlers\n", error);
242 const NSDictionary *dictInfos =
243 [NSBundle bundleWithPath:
@"/Library/Frameworks/3DconnexionClient.framework"]
245 NSString *strVersion = [dictInfos objectForKey:(NSString *)kCFBundleVersionKey];
247 const bool has_new_driver = compare != NSOrderedAscending;
262 SetConnexionClientButtonMask(
clientID, button_mask);
269 UnregisterConnexionClient(
clientID);
270 CleanupConnexionHandlers();
static void DeviceAdded(uint32_t)
static GHOST_NDOFManager * ndof_manager
static void DeviceRemoved(uint32_t)
void(*) RemovedHandler(uint32_t)
#define kConnexionMaskNoButtons
#define kConnexionCmdAppSpecific
void(*) UnregisterConnexionClient_ptr(uint16_t clientID)
#define kConnexionCmdAppEvent
#define kConnexionCmdHandleButtons
static bool load_driver_functions()
static void unload_driver()
#define kConnexionMaskAxis
void(*) CleanupConnexionHandlers_ptr()
static NSString * new_driver_minimal_version
uint16_t(*) RegisterConnexionClient_ptr(uint32_t signature, const char *name, uint16_t mode, uint32_t mask)
void(*) AddedHandler(uint32_t)
static bool driver_loaded
void(*) MessageHandler(uint32_t, uint32_t msg_type, void *msg_arg)
#define DECLARE_FUNC(name)
#define kConnexionMsgDeviceState
int16_t(*) ConnexionClientControl_ptr(uint16_t clientID, uint32_t message, int32_t param, int32_t *result)
#define kConnexionMaskAll
#define kConnexionCtlGetDeviceID
#define kConnexionCmdHandleAxis
int16_t(*) SetConnexionHandlers_ptr(MessageHandler, AddedHandler, RemovedHandler, bool)
void(*) SetConnexionClientButtonMask_ptr(uint16_t clientID, uint32_t buttonMask)
static void * load_func(void *module, const char *func_name)
#define kConnexionMaskAllButtons
static void DeviceEvent(uint32_t, uint32_t msg_type, void *msg_arg)
#define kConnexionClientModeTakeOver
static GHOST_SystemCocoa * ghost_system
unsigned long long int uint64_t
bool available() override
GHOST_NDOFManagerCocoa(GHOST_System &)
~GHOST_NDOFManagerCocoa() override
void updateButtonsBitmask(int button_bits, uint64_t time)
void updateButton(GHOST_NDOF_ButtonT button, bool press, uint64_t time)
void updateTranslation(const int t[3], uint64_t time)
GHOST_NDOFManager(GHOST_System &)
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 float2 mask(const MaskType mask, const float2 a)
static struct PyModuleDef module