Fix compilation on Linux.
[freeglut] / src / fg_spaceball.c
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
11 #include <GL/freeglut.h>
12 #include "fg_internal.h"
13
14 #if( !_WIN32 || _WIN32_WINNT >= 0x0501)
15
16 /* -- PRIVATE FUNCTIONS --------------------------------------------------- */
17
18 extern void fgPlatformInitializeSpaceball(void);
19 extern void fgPlatformSpaceballClose(void);
20 extern int fgPlatformHasSpaceball(void);
21 extern int fgPlatformSpaceballNumButtons(void);
22 extern void fgPlatformSpaceballSetWindow(SFG_Window *window);
23
24
25 int sball_initialized = 0;
26
27 void fgInitialiseSpaceball(void)
28 {
29     if(sball_initialized != 0) {
30         return;
31     }
32
33     fgPlatformInitializeSpaceball();
34 }
35
36 void fgSpaceballClose(void)
37 {
38         fgPlatformSpaceballClose();
39 }
40
41 int fgHasSpaceball(void)
42 {
43     if(sball_initialized == 0) {
44         fgInitialiseSpaceball();
45         if(sball_initialized != 1) {
46             fgWarning("fgInitialiseSpaceball failed\n");
47             return 0;
48         }
49     }
50
51     return fgPlatformHasSpaceball();
52 }
53
54 int fgSpaceballNumButtons(void)
55 {
56     if(sball_initialized == 0) {
57         fgInitialiseSpaceball();
58         if(sball_initialized != 1) {
59             fgWarning("fgInitialiseSpaceball failed\n");
60             return 0;
61         }
62     }
63
64     return fgPlatformSpaceballNumButtons();
65 }
66
67 void fgSpaceballSetWindow(SFG_Window *window)
68 {
69     if(sball_initialized == 0) {
70         fgInitialiseSpaceball();
71         if(sball_initialized != 1) {
72             return;
73         }
74     }
75
76     fgPlatformSpaceballSetWindow(window);
77 }
78
79 #else
80
81 void fgInitialiseSpaceball(void)
82 {
83 }
84
85 void fgSpaceballClose(void)
86 {
87 }
88
89 int fgHasSpaceball(void)
90 {
91         return 0;
92 }
93
94 int fgSpaceballNumButtons(void)
95 {
96         return 0;
97 }
98
99 void fgSpaceballSetWindow(SFG_Window *window)
100 {
101 }
102
103 #endif