22 const char *env_path = getenv(
"SPNAV_SOCKET");
32 if (access(spnav_sock_path, F_OK) != 0) {
33 CLOG_DEBUG(&
LOG,
"'spacenavd' not found at \"%s\"", spnav_sock_path);
35 else if (spnav_open() != -1) {
36 CLOG_DEBUG(&
LOG,
"'spacenavd' found at\"%s\"", spnav_sock_path);
40 spnav_client_name(
"blender");
44#define MAX_LINE_LENGTH 100
47 FILE *command_output = popen(
"lsusb | grep '046d:\\|256f:'",
"r");
51 ushort vendor_id = 0, product_id = 0;
52 if (sscanf(line,
"Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2) {
58 pclose(command_output);
83#define USE_FINISH_GLITCH_WORKAROUND
86#ifdef USE_FINISH_GLITCH_WORKAROUND
99# define MOTION_TEST_IDLE_MS 100
104 bool anyProcessed =
false;
109#ifdef USE_FINISH_GLITCH_WORKAROUND
110 bool motion_test =
false;
113 while (spnav_poll_event(&e)) {
115 case SPNAV_EVENT_MOTION: {
118 const int t[3] = {int(e.motion.x), int(e.motion.y), int(-e.motion.z)};
119 const int r[3] = {int(-e.motion.rx), int(-e.motion.ry), int(e.motion.rz)};
123#ifdef USE_FINISH_GLITCH_WORKAROUND
129 case SPNAV_EVENT_BUTTON:
137#ifdef USE_FINISH_GLITCH_WORKAROUND
146 const int v[3] = {0, 0, 0};
161#undef USE_FINISH_GLITCH_WORKAROUND
#define CLOG_DEBUG(clg_ref,...)
#define GHOST_ASSERT(x, info)
static uint64_t motion_test_prev_time
static bool motion_test_prev
#define MOTION_TEST_IDLE_MS
static const char * spnav_sock_path_get()
static const char * spnav_sock_path_default
unsigned long long int uint64_t
virtual uint64_t getMilliSeconds() const =0
bool available() override
~GHOST_NDOFManagerUnix() override
GHOST_NDOFManagerUnix(GHOST_System &)
void updateTranslation(const int t[3], uint64_t time)
GHOST_NDOFManager(GHOST_System &)
void updateButtonRAW(int button_number, bool press, uint64_t time)
void updateRotation(const int r[3], uint64_t time)
bool setDevice(unsigned short vendor_id, unsigned short product_id)