Hi.
Recently I bought a 3Dconnexion SpaceNavigator to use with OpenSCAD. I
know that this gadget is currently not supported by OpenSCAD. But being
a hacker fluent in C and C++, I thought it would be a nice project to
add support for it myself.
3Dconnexion offers a SDK for there devices, but the SDK is poisoned by a
ridiculous restrictive license. The SDK is impossible to use with Open
Source Software.
Fortunately the SpaceNavigator enumerates as an ordinary USB HID. I had
a look into libusb and the documentation here:
http://libusb.org/wiki/APIs#libusb-1.0currentAPIandimplementation
redirected me to HIDAPI:
http://www.signal11.us/oss/hidapi/
This is a small library with support for Mac OS X, Linux, Windows and
FreeBSD. It is a single .h file and a single .c file per platform.
With the help of HIDAPI I got reasonable output from the SpaceNavigator
using a small self written test program. See attachment. So now I can
get proper values for X/Y/Z translation and rotation as well as button
events. All on MacOS X. Fine. Now get this into OpenSCAD!
I tried to hack class QGLView as it handles mouse events. But getting
data from the SpaceNavigator requires a separate thread and Qt complained:
Cannot make QOpenGLContext current in a different thread
I have no clue about the OpenSCAD source code layout, its dependency
management, (3D) computer graphics nor Qt. So I need a bit of help to
get started with hacking OpenSCAD. As said, I am fluent in C++. So the
basics are covered. Mostly I need to know where to start digging, what
source code files to read, what classes to investigate, where are
similar things done as an example and the like.
Things that need to be done / I need help with:
tschüß,
Jochen
Hi,
I've used libusb myself and also wrote a (user-space) mouse driver (for
a touchscreen) for Linux.
I think you don't need to write a SpaceNavigator libusb-hid-driver.
At least for Linux, several usb-hid-drivers for the SpaceNavigator
exist (e.g.: http://janoc.rd-h.com/archives/74). I think there
should also be some for Mac OS X.
And I don't think that OpenSCAD should include hardware-specific
code. Instead, the SpaceNavigator should behave like a normal (extended)
mouse or joystick. The operating-system and window-manager should
handle the USB-polling, determine the current window and send
mouse-events to this window. At least that's how I think it should
be done.
You can also google for SpaceNavigator and FreeCAD -- it looks like
someone has already done something similar to implement SpaceNavigator-
support in FreeCAD (which also uses Qt AFAIK).
just my 2 ct,
Roland
Am 1.07.15 um 23:06 schrieb Roland:
I think you don't need to write a SpaceNavigator libusb-hid-driver.
At least for Linux, several usb-hid-drivers for the SpaceNavigator
exist (e.g.: http://janoc.rd-h.com/archives/74). I think there
should also be some for Mac OS X.
I had a look into this before I started. Unfortunately none of this is
really usable. Linux only, X11 only, outdated, can not coexist with the
3Dconnexion drivers, unacceptable license, ...
A direct USB interface with HIDAPI can coexist with the 3Dconnexion
drivers and is platform independent. But it probably has to deal with
differences among devices. Also note that the code to interpret the HID
reports from the SpaceNavigator is trivial. (See my demo code.)
And I don't think that OpenSCAD should include hardware-specific
code. Instead, the SpaceNavigator should behave like a normal
(extended) mouse or joystick. The operating-system and
window-manager should handle the USB-polling, determine the
current window and send mouse-events to this window. At least
that's how I think it should be done.
Agreed. Unfortunately Qt doesn't know anything about 6dof devices. There
is no generic support infrastructure like for 2D rodents.
http://www.codegardening.com/2011/02/using-3dconnexion-mouse-with-qt.html
"Qt has no corresponding Qt events for the 3D mouse"
As far as I read X11 has some generic multi-axis support, but not
Windows nor MacOS.
You can also google for SpaceNavigator and FreeCAD -- it looks like
someone has already done something similar to implement
SpaceNavigator-support in FreeCAD (which also uses Qt AFAIK).
tschüß,
Jochen