| 1 | /* Spaceball support for Linux. |
|---|---|
| 2 | * Written by John Tsiombikas <nuclear@member.fsf.org> |
| 3 | * |
| 4 | * This code supports 3Dconnexion's 6-dof space-whatever devices. |
| 5 | * It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv) |
| 6 | * free spacenavd (http://spacenav.sourceforge.net), through the "standard" |
| 7 | * magellan X-based protocol. |
| 8 | */ |
| 9 | |
| 10 | #include <GL/freeglut.h> |
| 11 | #include "fg_internal.h" |
| 12 | |
| 13 | /* -- PRIVATE FUNCTIONS --------------------------------------------------- */ |
| 14 | |
| 15 | extern void fgPlatformInitializeSpaceball(void); |
| 16 | extern void fgPlatformSpaceballClose(void); |
| 17 | extern int fgPlatformHasSpaceball(void); |
| 18 | extern int fgPlatformSpaceballNumButtons(void); |
| 19 | extern void fgPlatformSpaceballSetWindow(SFG_Window *window); |
| 20 | |
| 21 | |
| 22 | int sball_initialized = 0; |
| 23 | |
| 24 | void fgInitialiseSpaceball(void) |
| 25 | { |
| 26 | if(sball_initialized != 0) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | fgPlatformInitializeSpaceball(); |
| 31 | |
| 32 | sball_initialized = 1; |
| 33 | } |
| 34 | |
| 35 | void fgSpaceballClose(void) |
| 36 | { |
| 37 | fgPlatformSpaceballClose();} |
| 38 | |
| 39 | int fgHasSpaceball(void) |
| 40 | { |
| 41 | if(sball_initialized == 0) { |
| 42 | fgInitialiseSpaceball(); |
| 43 | if(sball_initialized != 1) { |
| 44 | fgWarning("fgInitialiseSpaceball failed\n"); |
| 45 | return 0; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return fgPlatformHasSpaceball(); |
| 50 | } |
| 51 | |
| 52 | int fgSpaceballNumButtons(void) |
| 53 | { |
| 54 | if(sball_initialized == 0) { |
| 55 | fgInitialiseSpaceball(); |
| 56 | if(sball_initialized != 1) { |
| 57 | fgWarning("fgInitialiseSpaceball failed\n"); |
| 58 | return 0; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return fgPlatformSpaceballNumButtons(); |
| 63 | } |
| 64 | |
| 65 | void fgSpaceballSetWindow(SFG_Window *window) |
| 66 | { |
| 67 | if(sball_initialized == 0) { |
| 68 | fgInitialiseSpaceball(); |
| 69 | if(sball_initialized != 1) { |
| 70 | return; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | fgPlatformSpaceballSetWindow(window); |
| 75 | } |
| 76 | |
| 77 |