\r
\r
/* External function declarations (mostly platform-specific) */\r
+extern void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident );\r
extern void fgPlatformJoystickClose ( int ident );\r
\r
/*\r
*/\r
\r
#if TARGET_HOST_MACINTOSH\r
+void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )\r
+{\r
+ fgJoystick[ ident ]->id = ident;\r
+ snprintf( fgJoystick[ ident ]->fname, sizeof(fgJoystick[ ident ]->fname), "/dev/js%d", ident ); /* FIXME */\r
+ fgJoystick[ ident ]->error = GL_FALSE;\r
+}\r
+\r
+\r
void fgPlatformJoystickClose ( int ident )\r
{\r
ISpSuspend( );\r
#endif\r
\r
#if TARGET_HOST_MAC_OSX\r
+void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )\r
+{\r
+ fgJoystick[ ident ]->id = ident;\r
+ fgJoystick[ ident ]->error = GL_FALSE;\r
+ fgJoystick[ ident ]->num_axes = 0;\r
+ fgJoystick[ ident ]->num_buttons = 0;\r
+\r
+ if( numDevices < 0 )\r
+ {\r
+ /* do first-time init (since we can't over-ride jsInit, hmm */\r
+ numDevices = 0;\r
+\r
+ mach_port_t masterPort;\r
+ IOReturn rv = IOMasterPort( bootstrap_port, &masterPort );\r
+ if( rv != kIOReturnSuccess )\r
+ {\r
+ fgWarning( "error getting master Mach port" );\r
+ return;\r
+ }\r
+ fghJoystickFindDevices( masterPort );\r
+ }\r
+\r
+ if ( ident >= numDevices )\r
+ {\r
+ fgJoystick[ ident ]->error = GL_TRUE;\r
+ return;\r
+ }\r
+\r
+ /* get the name now too */\r
+ CFDictionaryRef properties = getCFProperties( ioDevices[ ident ] );\r
+ CFTypeRef ref = CFDictionaryGetValue( properties,\r
+ CFSTR( kIOHIDProductKey ) );\r
+ if (!ref)\r
+ ref = CFDictionaryGetValue(properties, CFSTR( "USB Product Name" ) );\r
+\r
+ if( !ref ||\r
+ !CFStringGetCString( ( CFStringRef )ref, name, 128,\r
+ CFStringGetSystemEncoding( ) ) )\r
+ {\r
+ fgWarning( "error getting device name" );\r
+ name[ 0 ] = '\0';\r
+ }\r
+}\r
+\r
+\r
void fgPlatformJoystickClose ( int ident )\r
{\r
( *( fgJoystick[ ident ]->hidDev ) )->\r
#endif\r
\r
#if TARGET_HOST_POSIX_X11\r
+void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )\r
+{\r
+#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )\r
+ fgJoystick[ ident ]->id = ident;\r
+ fgJoystick[ ident ]->error = GL_FALSE;\r
+\r
+ fgJoystick[ ident ]->os = calloc( 1, sizeof( struct os_specific_s ) );\r
+ memset( fgJoystick[ ident ]->os, 0, sizeof( struct os_specific_s ) );\r
+ if( ident < USB_IDENT_OFFSET )\r
+ fgJoystick[ ident ]->os->is_analog = 1;\r
+ if( fgJoystick[ ident ]->os->is_analog )\r
+ snprintf( fgJoystick[ ident ]->os->fname, sizeof(fgJoystick[ ident ]->os->fname), "%s%d", AJSDEV, ident );\r
+ else\r
+ snprintf( fgJoystick[ ident ]->os->fname, sizeof(fgJoystick[ ident ]->os->fname), "%s%d", UHIDDEV,\r
+ ident - USB_IDENT_OFFSET );\r
+#elif defined( __linux__ )\r
+ fgJoystick[ ident ]->id = ident;\r
+ fgJoystick[ ident ]->error = GL_FALSE;\r
+\r
+ snprintf( fgJoystick[ident]->fname, sizeof(fgJoystick[ident]->fname), "/dev/input/js%d", ident );\r
+\r
+ if( access( fgJoystick[ ident ]->fname, F_OK ) != 0 )\r
+ snprintf( fgJoystick[ ident ]->fname, sizeof(fgJoystick[ ident ]->fname), "/dev/js%d", ident );\r
+#endif\r
+}\r
+\r
+\r
void fgPlatformJoystickClose ( int ident )\r
{\r
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )\r
fgJoystick[ ident ]->num_axes = fgJoystick[ ident ]->num_buttons = 0;\r
fgJoystick[ ident ]->error = GL_TRUE;\r
\r
-#if TARGET_HOST_MACINTOSH\r
- fgJoystick[ ident ]->id = ident;\r
- snprintf( fgJoystick[ ident ]->fname, sizeof(fgJoystick[ ident ]->fname), "/dev/js%d", ident ); /* FIXME */\r
- fgJoystick[ ident ]->error = GL_FALSE;\r
-#endif\r
-\r
-#if TARGET_HOST_MAC_OSX\r
- fgJoystick[ ident ]->id = ident;\r
- fgJoystick[ ident ]->error = GL_FALSE;\r
- fgJoystick[ ident ]->num_axes = 0;\r
- fgJoystick[ ident ]->num_buttons = 0;\r
-\r
- if( numDevices < 0 )\r
- {\r
- /* do first-time init (since we can't over-ride jsInit, hmm */\r
- numDevices = 0;\r
-\r
- mach_port_t masterPort;\r
- IOReturn rv = IOMasterPort( bootstrap_port, &masterPort );\r
- if( rv != kIOReturnSuccess )\r
- {\r
- fgWarning( "error getting master Mach port" );\r
- return;\r
- }\r
- fghJoystickFindDevices( masterPort );\r
- }\r
-\r
- if ( ident >= numDevices )\r
- {\r
- fgJoystick[ ident ]->error = GL_TRUE;\r
- return;\r
- }\r
-\r
- /* get the name now too */\r
- CFDictionaryRef properties = getCFProperties( ioDevices[ ident ] );\r
- CFTypeRef ref = CFDictionaryGetValue( properties,\r
- CFSTR( kIOHIDProductKey ) );\r
- if (!ref)\r
- ref = CFDictionaryGetValue(properties, CFSTR( "USB Product Name" ) );\r
-\r
- if( !ref ||\r
- !CFStringGetCString( ( CFStringRef )ref, name, 128,\r
- CFStringGetSystemEncoding( ) ) )\r
- {\r
- fgWarning( "error getting device name" );\r
- name[ 0 ] = '\0';\r
- }\r
-#endif\r
-\r
-#if TARGET_HOST_MS_WINDOWS && !defined(_WIN32_WCE)\r
- switch( ident )\r
- {\r
- case 0:\r
- fgJoystick[ ident ]->js_id = JOYSTICKID1;\r
- fgJoystick[ ident ]->error = GL_FALSE;\r
- break;\r
- case 1:\r
- fgJoystick[ ident ]->js_id = JOYSTICKID2;\r
- fgJoystick[ ident ]->error = GL_FALSE;\r
- break;\r
- default:\r
- fgJoystick[ ident ]->num_axes = 0;\r
- fgJoystick[ ident ]->error = GL_TRUE;\r
- return;\r
- }\r
-#endif\r
-\r
-#if TARGET_HOST_POSIX_X11\r
-# if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )\r
- fgJoystick[ ident ]->id = ident;\r
- fgJoystick[ ident ]->error = GL_FALSE;\r
-\r
- fgJoystick[ ident ]->os = calloc( 1, sizeof( struct os_specific_s ) );\r
- memset( fgJoystick[ ident ]->os, 0, sizeof( struct os_specific_s ) );\r
- if( ident < USB_IDENT_OFFSET )\r
- fgJoystick[ ident ]->os->is_analog = 1;\r
- if( fgJoystick[ ident ]->os->is_analog )\r
- snprintf( fgJoystick[ ident ]->os->fname, sizeof(fgJoystick[ ident ]->os->fname), "%s%d", AJSDEV, ident );\r
- else\r
- snprintf( fgJoystick[ ident ]->os->fname, sizeof(fgJoystick[ ident ]->os->fname), "%s%d", UHIDDEV,\r
- ident - USB_IDENT_OFFSET );\r
-# elif defined( __linux__ )\r
- fgJoystick[ ident ]->id = ident;\r
- fgJoystick[ ident ]->error = GL_FALSE;\r
-\r
- snprintf( fgJoystick[ident]->fname, sizeof(fgJoystick[ident]->fname), "/dev/input/js%d", ident );\r
-\r
- if( access( fgJoystick[ ident ]->fname, F_OK ) != 0 )\r
- snprintf( fgJoystick[ ident ]->fname, sizeof(fgJoystick[ ident ]->fname), "/dev/js%d", ident );\r
-# endif\r
-#endif\r
+ fgPlatformJoystickInit( fgJoystick, ident );\r
\r
fghJoystickOpen( fgJoystick[ ident ] );\r
}\r