static SFG_Window *spnav_win;\r
#endif\r
\r
-static int sball_initialized;\r
+/* Flag telling whether we have a spaceball:\r
+ * 0 - haven't tried initializing\r
+ * 1 - have successfully initialized\r
+ * -1 - have tried to initialize but not succeeded\r
+ */\r
+static int sball_initialized = 0;\r
\r
\r
void fgInitialiseSpaceball(void)\r
{\r
- if(sball_initialized) {\r
+ if(sball_initialized != 0) {\r
return;\r
}\r
\r
Window w;\r
\r
if(!fgStructure.CurrentWindow)\r
+ {\r
+ sball_initialized = -1;\r
return;\r
+ }\r
\r
w = fgStructure.CurrentWindow->Window.Handle;\r
- if(spnav_x11_open(fgDisplay.Display, w) == -1) {\r
+ if(spnav_x11_open(fgDisplay.Display, w) == -1)\r
+ {\r
+ sball_initialized = -1;\r
return;\r
}\r
}\r
\r
int fgHasSpaceball(void)\r
{\r
- if(!sball_initialized) {\r
+ if(sball_initialized == 0) {\r
fgInitialiseSpaceball();\r
- if(!sball_initialized) {\r
+ if(sball_initialized != 1) {\r
fgWarning("fgInitialiseSpaceball failed\n");\r
return 0;\r
}\r
\r
int fgSpaceballNumButtons(void)\r
{\r
- if(!sball_initialized) {\r
+ if(sball_initialized == 0) {\r
fgInitialiseSpaceball();\r
- if(!sball_initialized) {\r
+ if(sball_initialized != 1) {\r
fgWarning("fgInitialiseSpaceball failed\n");\r
return 0;\r
}\r
\r
void fgSpaceballSetWindow(SFG_Window *window)\r
{\r
- if(!sball_initialized) {\r
+ if(sball_initialized == 0) {\r
fgInitialiseSpaceball();\r
- if(!sball_initialized) {\r
+ if(sball_initialized != 1) {\r
return;\r
}\r
}\r
fgSpaceballSetWindow(fgStructure.CurrentWindow);\r
}\r
\r
- if(!sball_initialized) {\r
+ if(sball_initialized != 1) {\r
return 0;\r
}\r
\r
{\r
spnav_event sev;\r
\r
- if(!sball_initialized) {\r
+ if(sball_initialized == 0) {\r
fgInitialiseSpaceball();\r
- if(!sball_initialized) {\r
+ if(sball_initialized != 1) {\r
return;\r
}\r
}\r