Moving the X11-specific code from "freeglut_input_devices.c" into its own file (thank...
[freeglut] / src / Common / freeglut_internal.h
index 1d0a5b6..3870515 100644 (file)
@@ -33,8 +33,8 @@
 #endif\r
 \r
 /* XXX Update these for each release! */\r
-#define  VERSION_MAJOR 2\r
-#define  VERSION_MINOR 7\r
+#define  VERSION_MAJOR 3\r
+#define  VERSION_MINOR 0\r
 #define  VERSION_PATCH 0\r
 \r
 /* Freeglut is intended to function under all Unix/X11 and Win32 platforms. */\r
 \r
 /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */\r
 \r
-/* All Win32 headers depend on the huge windows.h recursive include.\r
- * Note: Lower-case header names are used, for best cross-platform\r
- * compatibility.\r
- */\r
-#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)\r
-#    include <windows.h>\r
-#    include <windowsx.h>\r
-#    include <mmsystem.h>\r
-/* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */\r
-#    ifndef __CYGWIN__\r
-#      include <tchar.h>\r
-#    else\r
-#      define _TEXT(x) TEXT(x)\r
-#      define _T(x)    TEXT(x)\r
-#    endif\r
-\r
-#elif TARGET_HOST_POSIX_X11\r
+#if TARGET_HOST_POSIX_X11\r
 #    include <GL/glx.h>\r
 #    include <X11/Xlib.h>\r
 #    include <X11/Xatom.h>\r
 #    endif\r
 #endif\r
 \r
-#if TARGET_HOST_MS_WINDOWS\r
-#    define  HAVE_VFPRINTF 1\r
-#endif\r
-\r
-/* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */\r
-#if TARGET_HOST_MS_WINDOWS && !defined(ChangeDisplaySettingsEx)\r
-LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID);\r
-LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);\r
-#    ifdef UNICODE\r
-#        define ChangeDisplaySettingsEx ChangeDisplaySettingsExW\r
-#    else\r
-#        define ChangeDisplaySettingsEx ChangeDisplaySettingsExA\r
-#    endif\r
-#endif\r
-\r
 #if defined(_MSC_VER) || defined(__WATCOMC__)\r
 /* strdup() is non-standard, for all but POSIX-2001 */\r
 #define strdup   _strdup\r
@@ -450,19 +419,24 @@ struct tagSFG_Context
 };\r
 \r
 /* Window's state description. This structure should be kept portable. */\r
+#if TARGET_HOST_POSIX_X11\r
+typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;\r
+struct tagSFG_PlatformWindowState\r
+{\r
+    int             OldWidth;           /* Window width from before a resize */\r
+    int             OldHeight;          /*   "    height  "    "    "   "    */\r
+};\r
+#endif\r
+\r
+\r
 typedef struct tagSFG_WindowState SFG_WindowState;\r
 struct tagSFG_WindowState\r
 {\r
     /* Note that on Windows, sizes always refer to the client area, thus without the window decorations */\r
     int             Width;              /* Window's width in pixels          */\r
     int             Height;             /* The same about the height         */\r
-#if TARGET_HOST_POSIX_X11\r
-    int             OldWidth;           /* Window width from before a resize */\r
-    int             OldHeight;          /*   "    height  "    "    "   "    */\r
-#elif TARGET_HOST_MS_WINDOWS\r
-    RECT            OldRect;            /* window rect - stored before the window is made fullscreen */\r
-    DWORD           OldStyle;           /* window style - stored before the window is made fullscreen */\r
-#endif\r
+\r
+       SFG_PlatformWindowState pWState;    /* Window width/height (X11) or rectangle/style (Windows) from before a resize */\r
 \r
     GLboolean       Redisplay;          /* Do we have to redisplay?          */\r
     GLboolean       Visible;            /* Is the window visible now         */\r
@@ -781,57 +755,119 @@ struct tagSFG_StrokeFont
 \r
 \r
 /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */\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
+ * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"\r
+ * interspersed\r
  */\r
-#define _JS_MAX_BUTTONS 32\r
 \r
 #if TARGET_HOST_MACINTOSH\r
-#    define _JS_MAX_AXES  9\r
+#    include <InputSprocket.h>\r
 #endif\r
 \r
 #if TARGET_HOST_MAC_OSX\r
-#    define _JS_MAX_AXES 16\r
-#endif\r
-\r
-#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)\r
-#    define _JS_MAX_AXES  8\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
-#    define _JS_MAX_AXES 16\r
-#endif\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
- * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.\r
- * See "js.h" lines 80-178.\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
-typedef struct tagSFG_Joystick SFG_Joystick;\r
-struct tagSFG_Joystick\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
+#define _JS_MAX_BUTTONS 32\r
+\r
 #if TARGET_HOST_MACINTOSH\r
+#    define _JS_MAX_AXES  9\r
+typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
+struct tagSFG_PlatformJoystick\r
+{\r
 #define  ISP_NUM_AXIS    9\r
 #define  ISP_NUM_NEEDS  41\r
     ISpElementReference isp_elem  [ ISP_NUM_NEEDS ];\r
     ISpNeed             isp_needs [ ISP_NUM_NEEDS ];\r
+};\r
 #endif\r
 \r
 #if TARGET_HOST_MAC_OSX\r
+#    define _JS_MAX_AXES 16\r
+typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
+struct tagSFG_PlatformJoystick\r
+{\r
     IOHIDDeviceInterface ** hidDev;\r
     IOHIDElementCookie buttonCookies[41];\r
     IOHIDElementCookie axisCookies[_JS_MAX_AXES];\r
-    long minReport[_JS_MAX_AXES],\r
-         maxReport[_JS_MAX_AXES];\r
-#endif\r
-\r
-#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)\r
-    JOYCAPS     jsCaps;\r
-    JOYINFOEX   js;\r
-    UINT        js_id;\r
+/* The next two variables are not used anywhere */\r
+/*    long minReport[_JS_MAX_AXES],\r
+ *         maxReport[_JS_MAX_AXES];\r
+ */\r
+};\r
 #endif\r
 \r
-\r
 #if TARGET_HOST_POSIX_X11\r
+#    define _JS_MAX_AXES 16\r
+typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;\r
+struct tagSFG_PlatformJoystick\r
+{\r
 #   if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)\r
        struct os_specific_s *os;\r
 #   endif\r
@@ -846,8 +882,18 @@ struct tagSFG_Joystick
 \r
     char         fname [ 128 ];\r
     int          fd;\r
+};\r
 #endif\r
 \r
+/*\r
+ * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class.\r
+ * See "js.h" lines 80-178.\r
+ */\r
+typedef struct tagSFG_Joystick SFG_Joystick;\r
+struct tagSFG_Joystick\r
+{\r
+       SFG_PlatformJoystick pJoystick;\r
+\r
     int          id;\r
     GLboolean    error;\r
     char         name [ 128 ];\r