Copyright © 1994, 1996, 1999 Information Geometers Ltd and The University of Bath
OpenGL supports the Spaceball, but the window event tags that the Spacemouse produces are different. Hence the problem.
LogiCAD supply an X-Windows driver for the spacemouse; the first thing to do is to download that from their website and get it working.
If (like me) you're running Linux on a PC this may be the first time you've used the 9-pin serial port on your machine, so things such as conflicting IRQs from odd PCI cards and the like may suddenly become apparent when you plug in the Spacemouse. Read the Linux Serial-HOWTO to sort this sort of thing out. I found it useful to connect a dumb terminal (actually a Psion 3a with an RS232 cable) to listen to the communication between the PC and the Spacemouse, so I could convince myself that the right characters were going to and fro. The LogiCAD website has an online manual giving all the codes the Spacemouse uses, incidentally.
It would be kinda nice if OpenGL GLUT had one extra callback registration - one that allowed one to register a procedure to which all events in OpenGL's window(s) that OpenGL itself didn't deal with would be passed. However, it doesn't. Fortunately Mesa is available as source code under the GNU public licence, so you can hack your own. The files you have to replace (keep a backup of the originals...) are glut.h and glut_event.c in the directories include/GL and src-glut in the Mesa directory tree.
You can download my amended copies of glut.h and glut_event.c from those highlights.
The changes that I made are these (use diff with the original files to see the details):
I've added an extra callback registration:
void glutUserEventFunc( int (*your_event_function)(Display* display, Window window, XEvent* event) );
this allows you to register your event handler to be called back.
I've written a skeleton event handler which you can use to develop your
own. It's called sm_event.c,
and is downloadable from that highlight.
Adrian Bowyer
12 July 1999
![]()