From: John F. Fay Date: Sun, 29 Jan 2012 03:51:12 +0000 (+0000) Subject: Moving the definition of the "fgJoystick" structure type to the header file so I... X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=8b4ff32ddaad2cd37eea3e7dee935cd5052f24da;p=freeglut Moving the definition of the "fgJoystick" structure type to the header file so I can use it across source code files git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1019 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/Common/freeglut_internal.h b/src/Common/freeglut_internal.h index e4b9d8f..1d0a5b6 100644 --- a/src/Common/freeglut_internal.h +++ b/src/Common/freeglut_internal.h @@ -779,6 +779,90 @@ struct tagSFG_StrokeFont const SFG_StrokeChar** Characters; /* The characters mapping */ }; + +/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */ +/* XXX It might be better to poll the operating system for the numbers of buttons and + * XXX axes and then dynamically allocate the arrays. + */ +#define _JS_MAX_BUTTONS 32 + +#if TARGET_HOST_MACINTOSH +# define _JS_MAX_AXES 9 +#endif + +#if TARGET_HOST_MAC_OSX +# define _JS_MAX_AXES 16 +#endif + +#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) +# define _JS_MAX_AXES 8 +#endif + +#if TARGET_HOST_POSIX_X11 +# define _JS_MAX_AXES 16 +#endif + +/* + * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class. + * See "js.h" lines 80-178. + */ +typedef struct tagSFG_Joystick SFG_Joystick; +struct tagSFG_Joystick +{ +#if TARGET_HOST_MACINTOSH +#define ISP_NUM_AXIS 9 +#define ISP_NUM_NEEDS 41 + ISpElementReference isp_elem [ ISP_NUM_NEEDS ]; + ISpNeed isp_needs [ ISP_NUM_NEEDS ]; +#endif + +#if TARGET_HOST_MAC_OSX + IOHIDDeviceInterface ** hidDev; + IOHIDElementCookie buttonCookies[41]; + IOHIDElementCookie axisCookies[_JS_MAX_AXES]; + long minReport[_JS_MAX_AXES], + maxReport[_JS_MAX_AXES]; +#endif + +#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) + JOYCAPS jsCaps; + JOYINFOEX js; + UINT js_id; +#endif + + +#if TARGET_HOST_POSIX_X11 +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) + struct os_specific_s *os; +# endif + +# ifdef JS_NEW + struct js_event js; + int tmp_buttons; + float tmp_axes [ _JS_MAX_AXES ]; +# else + struct JS_DATA_TYPE js; +# endif + + char fname [ 128 ]; + int fd; +#endif + + int id; + GLboolean error; + char name [ 128 ]; + int num_axes; + int num_buttons; + + float dead_band[ _JS_MAX_AXES ]; + float saturate [ _JS_MAX_AXES ]; + float center [ _JS_MAX_AXES ]; + float max [ _JS_MAX_AXES ]; + float min [ _JS_MAX_AXES ]; +}; + + + /* -- GLOBAL VARIABLES EXPORTS --------------------------------------------- */ /* Freeglut display related stuff (initialized once per session) */ diff --git a/src/Common/freeglut_joystick.c b/src/Common/freeglut_joystick.c index bf5bf95..c5e1b4a 100644 --- a/src/Common/freeglut_joystick.c +++ b/src/Common/freeglut_joystick.c @@ -42,25 +42,17 @@ * interspersed */ -/* XXX It might be better to poll the operating system for the numbers of buttons and - * XXX axes and then dynamically allocate the arrays. - */ -#define _JS_MAX_BUTTONS 32 - #if TARGET_HOST_MACINTOSH -# define _JS_MAX_AXES 9 # include #endif #if TARGET_HOST_MAC_OSX -# define _JS_MAX_AXES 16 # include # include # include #endif #if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) -# define _JS_MAX_AXES 8 # include # include # include @@ -68,7 +60,6 @@ #endif #if TARGET_HOST_POSIX_X11 -# define _JS_MAX_AXES 16 # ifdef HAVE_SYS_IOCTL_H # include # endif @@ -376,65 +367,6 @@ static int fghJoystickInitializeHID(struct os_specific_s *os, #endif /* - * Definition of "SFG_Joystick" structure -- based on JS's "jsJoystick" object class. - * See "js.h" lines 80-178. - */ -typedef struct tagSFG_Joystick SFG_Joystick; -struct tagSFG_Joystick -{ -#if TARGET_HOST_MACINTOSH -#define ISP_NUM_AXIS 9 -#define ISP_NUM_NEEDS 41 - ISpElementReference isp_elem [ ISP_NUM_NEEDS ]; - ISpNeed isp_needs [ ISP_NUM_NEEDS ]; -#endif - -#if TARGET_HOST_MAC_OSX - IOHIDDeviceInterface ** hidDev; - IOHIDElementCookie buttonCookies[41]; - IOHIDElementCookie axisCookies[_JS_MAX_AXES]; - long minReport[_JS_MAX_AXES], - maxReport[_JS_MAX_AXES]; -#endif - -#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE) - JOYCAPS jsCaps; - JOYINFOEX js; - UINT js_id; -#endif - - -#if TARGET_HOST_POSIX_X11 -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) - struct os_specific_s *os; -# endif - -# ifdef JS_NEW - struct js_event js; - int tmp_buttons; - float tmp_axes [ _JS_MAX_AXES ]; -# else - struct JS_DATA_TYPE js; -# endif - - char fname [ 128 ]; - int fd; -#endif - - int id; - GLboolean error; - char name [ 128 ]; - int num_axes; - int num_buttons; - - float dead_band[ _JS_MAX_AXES ]; - float saturate [ _JS_MAX_AXES ]; - float center [ _JS_MAX_AXES ]; - float max [ _JS_MAX_AXES ]; - float min [ _JS_MAX_AXES ]; -}; - -/* * Functions associated with the "jsJoystick" class in PLIB */ #if TARGET_HOST_MAC_OSX