Skip to content
Permalink
Browse files

Fixed bug #52

Integrated most of the NetBSD and DragonFly patches at:
ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/devel/SDL/patches/

Thanks to Thomas Klausner for defailed information on the patches
  • Loading branch information
slouken committed Mar 21, 2006
1 parent 13dae1c commit d3e3cb6a6eb3dfd0228e013e6e04418f07772479
@@ -50,10 +50,13 @@ else
fi

dnl Set up the compiler and linker flags
INCLUDE="-I$srcdir/include"
INCLUDE="-I$srcdir/include $INCLUDE"
if test x$srcdir != x.; then
INCLUDE="-Iinclude $INCLUDE"
fi
if test -d /usr/local/include; then
INCLUDE="$INCLUDE -I/usr/local/include"
fi
case "$host" in
*-*-cygwin*)
# We build SDL on cygwin without the UNIX emulation layer
@@ -284,7 +287,7 @@ AC_HELP_STRING([--enable-oss], [support the OSS audio API [default=yes]]),
SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
have_audio=yes

# OpenBSD needs linking with ossaudio emulation library
# We may need to link with ossaudio emulation library
case "$host" in
*-*-openbsd*|*-*-netbsd*)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
@@ -1499,7 +1502,7 @@ AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [default=yes]]),
# causes Carbon.p complaints?
# pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
;;
*-*-freebsd*)
*-*-freebsd*|*-*-dragonfly*)
pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
pthread_lib="-pthread"
;;
@@ -1761,14 +1764,17 @@ dnl Check for the usbhid(3) library on *BSD
CheckUSBHID()
{
if test x$enable_joystick = xyes; then
AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
if test x$have_libusbhid = xyes; then
AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
USB_LIBS="$USB_LIBS -lusbhid"
else
AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
fi

AC_CHECK_LIB(usbhid, hid_init, [USB_LIBS="$USB_LIBS -lusbhid"])
AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])

save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $USB_CFLAGS"

@@ -1779,8 +1785,13 @@ CheckUSBHID()
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
@@ -1805,8 +1816,13 @@ CheckUSBHID()
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#ifdef __DragonFly__
# include <bus/usb/usb.h>
# include <bus/usb/usbhid.h>
#else
# include <dev/usb/usb.h>
# include <dev/usb/usbhid.h>
#endif
#if defined(HAVE_USBHID_H)
#include <usbhid.h>
#elif defined(HAVE_LIBUSB_H)
@@ -1852,6 +1868,20 @@ CheckUSBHID()
fi
AC_MSG_RESULT($have_usbhid_new)

AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
have_machine_joystick=no
AC_TRY_COMPILE([
#include <machine/joystick.h>
],[
struct joystick t;
],[
have_machine_joystick=yes
])
if test x$have_machine_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
fi
AC_MSG_RESULT($have_machine_joystick)

AC_DEFINE(SDL_JOYSTICK_USBHID)
SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
@@ -1862,6 +1892,7 @@ CheckUSBHID()
fi
}


dnl Check for clock_gettime()
CheckClockGettime()
{
@@ -1907,7 +1938,7 @@ case "$host" in
have_timers=yes
fi
;;
*-*-linux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
*-*-linux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
case "$host" in
*-*-linux*) ARCH=linux ;;
*-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;;
@@ -1916,6 +1947,7 @@ case "$host" in
*-*-gnu*) ARCH=gnu ;; # must be last of the gnu variants
*-*-bsdi*) ARCH=bsdi ;;
*-*-freebsd*) ARCH=freebsd ;;
*-*-dragonfly*) ARCH=freebsd ;;
*-*-netbsd*) ARCH=netbsd ;;
*-*-openbsd*) ARCH=openbsd ;;
*-*-sysv5*) ARCH=sysv5 ;;
@@ -1961,12 +1993,12 @@ case "$host" in
# Set up files for the audio library
if test x$enable_audio = xyes; then
case $ARCH in
netbsd|sysv5|solaris|hpux)
sysv5|solaris|hpux)
AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
have_audio=yes
;;
openbsd)
netbsd|openbsd)
AC_DEFINE(SDL_AUDIO_DRIVER_OPENBSD)
SOURCES="$SOURCES $srcdir/src/audio/openbsd/*.c"
have_audio=yes
@@ -2388,7 +2420,7 @@ SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects
# Set runtime shared library paths as needed

if test "x$enable_rpath" = "xyes"; then
if test $ARCH = linux -o $ARCH = freebsd -o $ARCH = bsdi -o $ARCH = irix; then
if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib"
fi
if test $ARCH = solaris; then
@@ -208,6 +208,7 @@
#undef SDL_JOYSTICK_RISCOS
#undef SDL_JOYSTICK_WINMM
#undef SDL_JOYSTICK_USBHID
#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H

/* Enable various shared object loading systems */
#undef SDL_LOADSO_BEOS
@@ -45,7 +45,7 @@
#undef __DREAMCAST__
#define __DREAMCAST__ 1
#endif
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
#undef __FREEBSD__
#define __FREEBSD__ 1
#endif
@@ -42,8 +42,12 @@
#include "../SDL_audiodev_c.h"
#include "SDL_openbsdaudio.h"

/* The tag name used by OpenBSD audio */
/* The tag name used by NetBSD/OpenBSD audio */
#ifdef __NETBSD__
#define OBSD_DRIVER_NAME "netbsd"
#else
#define OBSD_DRIVER_NAME "openbsd"
#endif

/* Open the audio device for playback, and don't block if busy */
/* #define USE_BLOCKING_WRITES */
@@ -128,26 +132,18 @@ static SDL_AudioDevice
}

AudioBootStrap OPENBSD_AUDIO_bootstrap = {
#ifdef __NETBSD__
OBSD_DRIVER_NAME, "Native NetBSD audio",
#else
OBSD_DRIVER_NAME, "Native OpenBSD audio",
#endif
Audio_Available, Audio_CreateDevice
};

/* This function waits until it is possible to write a full sound buffer */
static void
OBSD_WaitAudio(_THIS)
{
/* Check to see if the thread-parent process is still alive */
{ static int cnt = 0;
/* Note that this only works with thread implementations
that use a different process id for each thread.
*/
if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
if ( kill(parent, 0) < 0 ) {
this->enabled = 0;
}
}
}

#ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */
/* See if we need to use timed audio synchronization */
if ( frame_ticks ) {
@@ -384,6 +380,9 @@ OBSD_OpenAudio(_THIS, SDL_AudioSpec *spec)
spec->channels = 1;
AUDIO_INITINFO(&info);
info.play.sample_rate = spec->freq;
info.blocksize = spec->size;
info.hiwat = 5;
info.lowat = 3;
(void)ioctl(audio_fd, AUDIO_SETINFO, &info);
(void)ioctl(audio_fd, AUDIO_GETINFO, &info);
spec->freq = info.play.sample_rate;
@@ -37,8 +37,13 @@
#if defined(HAVE_USB_H)
#include <usb.h>
#endif
#ifdef __DragonFly__
#include <bus/usb/usb.h>
#include <bus/usb/usbhid.h>
#else
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#endif

#if defined(HAVE_USBHID_H)
#include <usbhid.h>
@@ -49,11 +54,13 @@
#endif

#ifdef __FREEBSD__
#ifndef __DragonFly__
#include <osreldate.h>
#endif
#include <sys/joystick.h>
#endif

#if defined(__NETBSD__) || (defined(__OPENBSD__) && defined(__i386__))
#if SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
#include <machine/joystick.h>
#endif

@@ -231,6 +238,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
struct hid_data *hdata;
struct report *rep;
int fd;
int i;

fd = open(path, O_RDONLY);
if (fd == -1) {
@@ -297,6 +305,8 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
joy->nbuttons = 0;
joy->nhats = 0;
joy->nballs = 0;
for (i=0; i<JOYAXE_count; i++)
hw->axis_map[i] = -1;

while (hid_get_item(hdata, &hitem) > 0) {
char *sp;
@@ -323,8 +333,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
unsigned usage = HID_USAGE(hitem.usage);
int joyaxe = usage_to_joyaxe(usage);
if (joyaxe >= 0) {
hw->axis_map[joyaxe] = joy->naxes;
joy->naxes++;
hw->axis_map[joyaxe] = 1;
} else if (usage == HUG_HAT_SWITCH) {
joy->nhats++;
}
@@ -342,6 +351,9 @@ SDL_SYS_JoystickOpen(SDL_Joystick *joy)
}
}
hid_end_parse(hdata);
for (i=0; i<JOYAXE_count; i++)
if (hw->axis_map[i] > 0)
hw->axis_map[i] = joy->naxes++;

usbend:
/* The poll blocks the event thread. */
@@ -364,7 +376,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy)
int nbutton, naxe = -1;
Sint32 v;

#if defined(__FREEBSD__) || defined(__NETBSD__) || (defined(__OPENBSD__) && defined(__i386__))
#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
struct joystick gameport;
static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;

@@ -413,7 +425,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy)
}
return;
}
#endif /* defined(__FREEBSD__) || defined(__NETBSD__) || defined(__OPENBSD__) */
#endif /* defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */

rep = &joy->hwdata->inreport;

@@ -451,7 +463,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy)
} else if (usage == HUG_HAT_SWITCH) {
v = (Sint32)hid_get_data(REP_BUF_DATA(rep),
&hitem);
SDL_PrivateJoystickHat(joy, 0, hatval_to_sdl(v));
SDL_PrivateJoystickHat(joy, 0,
hatval_to_sdl(v)-hitem.logical_minimum);
}
break;
}
@@ -512,7 +525,9 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
{
int len;

#ifdef __FREEBSD__
#ifdef __DragonFly__
len = hid_report_size(rd, r->rid, repinfo[repind].kind);
#elif __FREEBSD__
# if (__FreeBSD_version >= 460000)
# if (__FreeBSD_version <= 500111)
len = hid_report_size(rd, r->rid, repinfo[repind].kind);
@@ -521,12 +536,12 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
# endif
# else
len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
#endif
# endif
#else
# ifdef USBHID_NEW
len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
# else
len = hid_report_size(rd, repinfo[repind].kind, r->rid);
# else
len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
# endif
#endif

@@ -555,7 +555,7 @@ VGLListModes(int depth, int mem_model)
case V_INFO_MM_VGAX:
vminfop->Type = VIDBUF8X;
break;
#if defined(__FREEBSD__) && __FreeBSD_version >= 500000
#if defined(__FREEBSD__) && (defined(__DragonFly__) || __FreeBSD_version >= 500000)
case V_INFO_MM_DIRECT:
vminfop->PixelBytes = minfo.vi_pixel_size;
switch (vminfop->PixelBytes) {

0 comments on commit d3e3cb6

Please sign in to comment.