--- src/js/js.h.orig	Mon May 10 14:25:05 1999
+++ src/js/js.h	Sat Jun 26 17:13:51 1999
@@ -4,6 +4,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+/* the next lines are to define BSD */
+/* see http://www.freebsd.org/handbook/porting.html for why we do this */
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
 #ifdef WIN32
 #  include <windows.h>
 #  if defined( __CYGWIN32__ ) || defined( __CYGWIN__ )
@@ -17,7 +23,12 @@
 #  include <unistd.h>
 #  include <fcntl.h>
 
-#  ifdef __linux__
+#  ifdef BSD
+#    include <machine/joystick.h>
+#    define JS_DATA_TYPE joystick
+#    define JS_RETURN (sizeof(struct JS_DATA_TYPE))
+
+#  elif defined(__linux__)
 #    include <linux/joystick.h>
 #  else
 #    ifndef JS_DATA_TYPE
@@ -61,6 +72,9 @@
 
 class jsJoystick
 {
+#ifdef BSD
+  int          id ;
+#endif
 #ifdef WIN32
   JOYINFOEX    js       ;
   UINT         js_id    ;
@@ -117,6 +131,13 @@
     }
 
 #else
+
+#  ifdef BSD
+    FILE *joyfile;
+    char joyfname[1024];
+    int noargs, in_no_axes;
+#  endif
+
     num_axes = _JS_MAX_AXES ;
 
     fd = ::open ( fname, O_RDONLY ) ;
@@ -126,6 +147,34 @@
     if ( error )
       return ;
 
+#  ifdef BSD
+
+    float axes[_JS_MAX_AXES];
+    int buttons[_JS_MAX_AXES];
+    rawRead ( buttons, axes );
+    error = axes[0] < -1000000000.0f;
+    if ( error )
+      return ;
+
+    sprintf(joyfname,"%s/.joy%drc",::getenv( "HOME" ),id);
+
+    joyfile = fopen(joyfname,"r");
+    error = joyfile == NULL;
+    if ( error )
+      return ;
+    noargs = fscanf(joyfile,"%d%f%f%f%f%f%f",&in_no_axes,
+                        &min[0],&center[0],&max[0],
+                        &min[1],&center[1],&max[1]);
+    error = noargs != 7 || in_no_axes != _JS_MAX_AXES;
+    fclose(joyfile);
+    if ( error )
+      return ;
+
+    for ( int i = 0 ; i < _JS_MAX_AXES ; i++ )
+      dead_band [ i ] = 0.0f ;
+
+#  else
+
     int counter = 0 ;
 
     /*
@@ -153,6 +202,9 @@
       min [ i ] = 0.0f ;
       dead_band [ i ] = 0.0f ;
     }
+
+#  endif
+
 #endif
   }
 
@@ -200,7 +252,12 @@
       default : num_axes = 0 ; setError () ; break ;
     }
 #else
+#  ifdef BSD
+    this->id = id;
+    sprintf ( fname, "/dev/joy%d", id ) ;
+#  elif
     sprintf ( fname, "/dev/js%d", id ) ;
+#  endif
     open () ;
 #endif
   }
@@ -297,7 +354,11 @@
     }
 
     if ( buttons )
+#  ifdef BSD
+      *buttons = 0 ; /* probably should be something else here */
+#  else
       *buttons = js.buttons ;
+#  endif
 
     if ( axes )
     {
--- src/sg/sg.h.orig	Wed Jun  2 20:54:11 1999
+++ src/sg/sg.h	Sat Jun 26 17:13:57 1999
@@ -5,7 +5,17 @@
 #include <limits.h>
 #include <math.h>
 
+/* the next lines are to define BSD */
+/* see http://www.freebsd.org/handbook/porting.html for why we do this */
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
 #ifdef WIN32
+#include <float.h>
+#endif
+
+#ifdef BSD
 #include <float.h>
 #endif
 
--- src/sl/sl.h.orig	Wed Jun  2 13:45:46 1999
+++ src/sl/sl.h	Sat Jun 26 17:14:01 1999
@@ -8,7 +8,7 @@
 #define SLDSP_DEFAULT_DEVICE "/dev/dsp"
 #elif defined(WIN32)
 #define SLDSP_DEFAULT_DEVICE "dsp"	
-#elif defined(__OpenBSD__)
+#elif defined(BSD)
 #define SLDSP_DEFAULT_DEVICE "/dev/audio"
 #elif defined(sgi)
 #define SLDSP_DEFAULT_DEVICE "dsp"		// dummy ...
--- src/sl/slPortability.h.orig	Mon May 10 14:25:05 1999
+++ src/sl/slPortability.h	Sat Jun 26 17:14:09 1999
@@ -9,6 +9,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+/* the next lines are to define BSD */
+/* see http://www.freebsd.org/handbook/porting.html for why we do this */
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
 #ifndef  WIN32
 #include <unistd.h>
 #include <sys/ioctl.h>
@@ -31,6 +37,11 @@
 #ifdef __linux__
 #define SL_USING_OSS_AUDIO 1
 #endif
+
+#ifdef BSD
+#define SL_USING_OSS_AUDIO 1
+#endif
+
 
 #ifdef SL_USING_OSS_AUDIO
 #if defined(__linux__)
