Moving some header-style joystick code from "freeglut_joystick.c" to "freeglut_intern...
[freeglut] / src / Common / freeglut_internal.h
index bbef2ce..3870515 100644 (file)
@@ -755,6 +755,82 @@ struct tagSFG_StrokeFont
 \r
 \r
 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */\r
+/*\r
+ * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"\r
+ * interspersed\r
+ */\r
+\r
+#if TARGET_HOST_MACINTOSH\r
+#    include <InputSprocket.h>\r
+#endif\r
+\r
+#if TARGET_HOST_MAC_OSX\r
+#    include <mach/mach.h>\r
+#    include <IOKit/IOkitLib.h>\r
+#    include <IOKit/hid/IOHIDLib.h>\r
+#endif\r
+\r
+#if TARGET_HOST_POSIX_X11\r
+#    ifdef HAVE_SYS_IOCTL_H\r
+#        include <sys/ioctl.h>\r
+#    endif\r
+#    ifdef HAVE_FCNTL_H\r
+#        include <fcntl.h>\r
+#    endif\r
+#    ifdef HAVE_ERRNO_H\r
+#        include <errno.h>\r
+#        include <string.h>\r
+#    endif\r
+#    if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)\r
+/* XXX The below hack is done until freeglut's autoconf is updated. */\r
+#        define HAVE_USB_JS    1\r
+\r
+#        if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)\r
+#            include <sys/joystick.h>\r
+#        else\r
+/*\r
+ * XXX NetBSD/amd64 systems may find that they have to steal the\r
+ * XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.\r
+ * XXX I cannot comment whether that works for the interface, but\r
+ * XXX it lets you compile...(^&  I do not think that we can do away\r
+ * XXX with this header.\r
+ */\r
+#            include <machine/joystick.h>         /* For analog joysticks */\r
+#        endif\r
+#        define JS_DATA_TYPE joystick\r
+#        define JS_RETURN (sizeof(struct JS_DATA_TYPE))\r
+#    endif\r
+\r
+#    if defined(__linux__)\r
+#        include <linux/joystick.h>\r
+\r
+/* check the joystick driver version */\r
+#        if defined(JS_VERSION) && JS_VERSION >= 0x010000\r
+#            define JS_NEW\r
+#        endif\r
+#    else  /* Not BSD or Linux */\r
+#        ifndef JS_RETURN\r
+\r
+  /*\r
+   * We'll put these values in and that should\r
+   * allow the code to at least compile when there is\r
+   * no support. The JS open routine should error out\r
+   * and shut off all the code downstream anyway and if\r
+   * the application doesn't use a joystick we'll be fine.\r
+   */\r
+\r
+  struct JS_DATA_TYPE\r
+  {\r
+    int buttons;\r
+    int x;\r
+    int y;\r
+  };\r
+\r
+#            define JS_RETURN (sizeof(struct JS_DATA_TYPE))\r
+#        endif\r
+#    endif\r
+#endif\r
+\r
 /* XXX It might be better to poll the operating system for the numbers of buttons and\r
  * XXX axes and then dynamically allocate the arrays.\r
  */\r