summaryrefslogtreecommitdiff
path: root/devel/SDL
diff options
context:
space:
mode:
authorkristerw <kristerw@pkgsrc.org>2002-07-14 07:28:39 +0000
committerkristerw <kristerw@pkgsrc.org>2002-07-14 07:28:39 +0000
commit3eea6e55017ba5fe337242406ee93e310c86224a (patch)
tree1f7c557091bc09d62b4f343f8c5b59d9ba77de28 /devel/SDL
parentce0885ea7220f84e521897aac45f788eae3d3c58 (diff)
downloadpkgsrc-3eea6e55017ba5fe337242406ee93e310c86224a.tar.gz
Add USB joystick support (and bump version to 1.2.3nb1). The implementation
is taken from the SDL development repository, with some bugfixes from me. Solves PR 17374.
Diffstat (limited to 'devel/SDL')
-rw-r--r--devel/SDL/Makefile5
-rw-r--r--devel/SDL/distinfo6
-rw-r--r--devel/SDL/files/Makefile.am8
-rw-r--r--devel/SDL/files/Makefile.in335
-rw-r--r--devel/SDL/files/SDL_sysjoystick.c436
-rw-r--r--devel/SDL/patches/patch-aj179
-rw-r--r--devel/SDL/patches/patch-am445
7 files changed, 1375 insertions, 39 deletions
diff --git a/devel/SDL/Makefile b/devel/SDL/Makefile
index 965e6274d71..58d70fd4620 100644
--- a/devel/SDL/Makefile
+++ b/devel/SDL/Makefile
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.35 2002/07/13 16:17:33 wiz Exp $
+# $NetBSD: Makefile,v 1.36 2002/07/14 07:28:39 kristerw Exp $
#
DISTNAME= SDL-1.2.3
+PKGREVISION= 1
CATEGORIES= devel games
MASTER_SITES= http://www.libsdl.org/release/
@@ -47,6 +48,8 @@ CONFIGURE_ENV+= SYSTEM_LIBS="${LDFLAGS}"
pre-patch:
cd ${WRKSRC} && ${MKDIR} src/audio/netbsd
+ cd ${WRKSRC} && ${MKDIR} src/joystick/bsd
+ ${CP} ${FILESDIR}/[MS]* ${WRKSRC}/src/joystick/bsd
post-configure:
cd ${WRKSRC}/src/audio && ${CP} *.[ch] netbsd/
diff --git a/devel/SDL/distinfo b/devel/SDL/distinfo
index 6c4e93c7cd9..ab6a479bcb1 100644
--- a/devel/SDL/distinfo
+++ b/devel/SDL/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.11 2002/07/13 16:17:33 wiz Exp $
+$NetBSD: distinfo,v 1.12 2002/07/14 07:28:39 kristerw Exp $
SHA1 (SDL-1.2.3.tar.gz) = f74f5bf47a472083da8700d2354cb90062e2a845
Size (SDL-1.2.3.tar.gz) = 1568671 bytes
@@ -10,10 +10,10 @@ SHA1 (patch-af) = f5e824addf308f9c467de02e3b262afbc0ef77c0
SHA1 (patch-ag) = 989c3464686a3158c538034ad7ea012a4e4b4b9e
SHA1 (patch-ah) = f509c0c146002cf2525bd9b7c7532fbca7aa4fb6
SHA1 (patch-ai) = 0edabed555e3fc4b0a92aff9240359fc6637f022
-SHA1 (patch-aj) = 450364c3f779e923f3cfc59edaf3e1d5ffdc70c9
+SHA1 (patch-aj) = b12b50ee78f5d905d28ed2e948b47e644a2b7890
SHA1 (patch-ak) = 657947be674831c98850f044315e4681fe58ea29
SHA1 (patch-al) = 0fe579ae0358d59f87a78fe4b5b006ef991d44f0
-SHA1 (patch-am) = 39de95c727fbd5276729b8591554a7b9664166e3
+SHA1 (patch-am) = 55b6fb31a3e0a29db281cd41ca2b671f0a22ed5c
SHA1 (patch-an) = b875bc9e173d69cb5fcc1b4ea3e7039b7633d187
SHA1 (patch-ap) = ca979b24a57a8f115f5e1bdf6b1e5672a60d20a9
SHA1 (patch-aq) = 45f63636a9caa338274db68596c8cf8c1d3cd0f0
diff --git a/devel/SDL/files/Makefile.am b/devel/SDL/files/Makefile.am
new file mode 100644
index 00000000000..5d2ce1602ef
--- /dev/null
+++ b/devel/SDL/files/Makefile.am
@@ -0,0 +1,8 @@
+
+## Makefile.am for the BSD joystick driver for SDL
+
+noinst_LTLIBRARIES = libjoystick_bsd.la
+libjoystick_bsd_la_SOURCES = $(SRCS)
+
+# The SDL joystick driver sources
+SRCS = SDL_sysjoystick.c
diff --git a/devel/SDL/files/Makefile.in b/devel/SDL/files/Makefile.in
new file mode 100644
index 00000000000..4096e5d5746
--- /dev/null
+++ b/devel/SDL/files/Makefile.in
@@ -0,0 +1,335 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ../../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+ARCH = @ARCH@
+ARTSCCONFIG = @ARTSCCONFIG@
+AS = @AS@
+ASFLAGS = @ASFLAGS@
+AUDIO_DRIVERS = @AUDIO_DRIVERS@
+AUDIO_SUBDIRS = @AUDIO_SUBDIRS@
+CC = @CC@
+CDROM_DRIVERS = @CDROM_DRIVERS@
+CDROM_SUBDIRS = @CDROM_SUBDIRS@
+CXX = @CXX@
+DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@
+DIRECTFB_LIBS = @DIRECTFB_LIBS@
+DLLTOOL = @DLLTOOL@
+ESD_CFLAGS = @ESD_CFLAGS@
+ESD_CONFIG = @ESD_CONFIG@
+ESD_LIBS = @ESD_LIBS@
+JOYSTICK_DRIVERS = @JOYSTICK_DRIVERS@
+JOYSTICK_SUBDIRS = @JOYSTICK_SUBDIRS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAKEINFO = @MAKEINFO@
+NASM = @NASM@
+NASMFLAGS = @NASMFLAGS@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJDUMP = @OBJDUMP@
+PACKAGE = @PACKAGE@
+PKG_CONFIG = @PKG_CONFIG@
+PTH_CONFIG = @PTH_CONFIG@
+RANLIB = @RANLIB@
+SDL_BINARY_AGE = @SDL_BINARY_AGE@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_EXTRADIRS = @SDL_EXTRADIRS@
+SDL_EXTRALIBS = @SDL_EXTRALIBS@
+SDL_INTERFACE_AGE = @SDL_INTERFACE_AGE@
+SDL_LIBS = @SDL_LIBS@
+SDL_MAJOR_VERSION = @SDL_MAJOR_VERSION@
+SDL_MICRO_VERSION = @SDL_MICRO_VERSION@
+SDL_MINOR_VERSION = @SDL_MINOR_VERSION@
+SDL_RLD_FLAGS = @SDL_RLD_FLAGS@
+SDL_VERSION = @SDL_VERSION@
+SHARED_SYSTEM_LIBS = @SHARED_SYSTEM_LIBS@
+STATIC_SYSTEM_LIBS = @STATIC_SYSTEM_LIBS@
+SYSTEM_LIBS = @SYSTEM_LIBS@
+VERSION = @VERSION@
+VIDEO_DRIVERS = @VIDEO_DRIVERS@
+VIDEO_SUBDIRS = @VIDEO_SUBDIRS@
+arts_lib = @arts_lib@
+esd_lib = @esd_lib@
+
+noinst_LTLIBRARIES = libjoystick_bsd.la
+libjoystick_bsd_la_SOURCES = $(SRCS)
+
+# The SDL joystick driver sources
+SRCS = SDL_sysjoystick.c
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir)
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+libjoystick_bsd_la_LDFLAGS =
+libjoystick_bsd_la_LIBADD =
+libjoystick_bsd_la_OBJECTS = SDL_sysjoystick.lo
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+SOURCES = $(libjoystick_bsd_la_SOURCES)
+OBJECTS = $(libjoystick_bsd_la_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps src/joystick/bsd/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLTLIBRARIES:
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+
+distclean-noinstLTLIBRARIES:
+
+maintainer-clean-noinstLTLIBRARIES:
+
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.c.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+libjoystick_bsd.la: $(libjoystick_bsd_la_OBJECTS) $(libjoystick_bsd_la_DEPENDENCIES)
+ $(LINK) $(libjoystick_bsd_la_LDFLAGS) $(libjoystick_bsd_la_OBJECTS) $(libjoystick_bsd_la_LIBADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = src/joystick/bsd
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile $(LTLIBRARIES)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \
+ clean-tags clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-noinstLTLIBRARIES distclean-compile \
+ distclean-libtool distclean-tags distclean-generic \
+ clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-generic \
+ distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
+clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
+dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/devel/SDL/files/SDL_sysjoystick.c b/devel/SDL/files/SDL_sysjoystick.c
new file mode 100644
index 00000000000..39a42180c83
--- /dev/null
+++ b/devel/SDL/files/SDL_sysjoystick.c
@@ -0,0 +1,436 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@devolution.com
+*/
+
+/*
+ * Joystick driver for the uhid(4) interface found in OpenBSD,
+ * NetBSD and FreeBSD.
+ *
+ * Maintainer: <vedge at csoft.org>
+ */
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: SDL_sysjoystick.c,v 1.1 2002/07/14 07:28:40 kristerw Exp $";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+#if defined(HAVE_USB_H)
+#include <usb.h>
+#endif
+#include <dev/usb/usb.h>
+#include <dev/usb/usbhid.h>
+
+#if defined(HAVE_USBHID_H)
+#include <usbhid.h>
+#elif defined(HAVE_LIBUSB_H)
+#include <libusb.h>
+#elif defined(HAVE_LIBUSBHID_H)
+#include <libusbhid.h>
+#endif
+
+#include "SDL_error.h"
+#include "SDL_joystick.h"
+#include "SDL_sysjoystick.h"
+#include "SDL_joystick_c.h"
+
+#define MAX_UHID_JOYS 4
+#define MAX_JOY_JOYS 2
+#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS)
+
+struct report {
+ struct usb_ctl_report *buf; /* Buffer */
+ size_t size; /* Buffer size */
+ int rid; /* Report ID */
+ enum {
+ SREPORT_UNINIT,
+ SREPORT_CLEAN,
+ SREPORT_DIRTY
+ } status;
+};
+
+static struct {
+ int uhid_report;
+ hid_kind_t kind;
+ const char *name;
+} const repinfo[] = {
+ { UHID_INPUT_REPORT, hid_input, "input" },
+ { UHID_OUTPUT_REPORT, hid_output, "output" },
+ { UHID_FEATURE_REPORT, hid_feature, "feature" }
+};
+
+enum {
+ REPORT_INPUT = 0,
+ REPORT_OUTPUT = 1,
+ REPORT_FEATURE = 2
+};
+
+enum {
+ JOYAXE_X,
+ JOYAXE_Y,
+ JOYAXE_Z,
+ JOYAXE_SLIDER,
+ JOYAXE_WHEEL
+};
+
+struct joystick_hwdata {
+ int fd;
+ char *path;
+ enum {
+ BSDJOY_UHID, /* uhid(4) */
+ BSDJOY_JOY /* joy(4) */
+ } type;
+ struct report_desc *repdesc;
+ struct report inreport;
+#if 0
+ int axismin[];
+ int axismax[];
+#endif
+};
+
+static char *joynames[MAX_JOYS];
+static char *joydevnames[MAX_JOYS];
+
+static int report_alloc(struct report *, struct report_desc *, int);
+static void report_free(struct report *);
+
+#ifdef USBHID_UCR_DATA
+#define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
+#else
+#define REP_BUF_DATA(rep) ((rep)->buf->data)
+#endif
+
+int
+SDL_SYS_JoystickInit(void)
+{
+ char s[10];
+ int i, fd;
+
+ SDL_numjoysticks = 0;
+
+ memset(joynames, NULL, sizeof(joynames));
+ memset(joydevnames, NULL, sizeof(joydevnames));
+
+ for (i = 0; i < MAX_UHID_JOYS; i++) {
+ sprintf(s, "/dev/uhid%d", i);
+ fd = open(s, O_RDWR);
+ if (fd > 0) {
+ joynames[SDL_numjoysticks++] = strdup(s);
+ close(fd);
+ }
+ }
+ for (i = 0; i < MAX_JOY_JOYS; i++) {
+ sprintf(s, "/dev/joy%d", i);
+ fd = open(s, O_RDWR);
+ if (fd > 0) {
+ joynames[SDL_numjoysticks++] = strdup(s);
+ close(fd);
+ }
+ }
+
+ /* Read the default USB HID usage table. */
+ hid_init(NULL);
+
+ return (SDL_numjoysticks);
+}
+
+const char *
+SDL_SYS_JoystickName(int index)
+{
+ if (joydevnames[index] != NULL) {
+ return (joydevnames[index]);
+ }
+ return (joynames[index]);
+}
+
+int
+SDL_SYS_JoystickOpen(SDL_Joystick *joy)
+{
+ char *path = joynames[joy->index];
+ struct joystick_hwdata *hw;
+ struct hid_item hitem;
+ struct hid_data *hdata;
+ struct report *rep;
+ int fd;
+
+ fd = open(path, O_RDWR);
+ if (fd < 0) {
+ SDL_SetError("%s: %s", path, strerror(errno));
+ return (-1);
+ }
+
+ hw = (struct joystick_hwdata *)malloc(sizeof(struct joystick_hwdata));
+ if (hw == NULL) {
+ SDL_OutOfMemory();
+ close(fd);
+ return (-1);
+ }
+ joy->hwdata = hw;
+ hw->fd = fd;
+ hw->path = strdup(path);
+ hw->type = BSDJOY_UHID;
+ hw->repdesc = hid_get_report_desc(fd);
+ if (hw->repdesc == NULL) {
+ SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path,
+ strerror(errno));
+ goto usberr;
+ }
+
+ rep = &hw->inreport;
+ if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {
+ goto usberr;
+ }
+ if (rep->size <= 0) {
+ SDL_SetError("%s: Input report descriptor has invalid length",
+ hw->path);
+ goto usberr;
+ }
+
+#ifdef USBHID_NEW
+ hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
+#else
+ hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
+#endif
+ if (hdata == NULL) {
+ SDL_SetError("%s: Cannot start HID parser", hw->path);
+ goto usberr;
+ }
+ joy->naxes = 0;
+ joy->nbuttons = 0;
+ joy->nhats = 0;
+ joy->nballs = 0;
+
+ while (hid_get_item(hdata, &hitem) > 0) {
+ char *sp;
+ const char *s;
+
+ switch (hitem.kind) {
+ case hid_collection:
+ switch (HID_PAGE(hitem.usage)) {
+ case HUP_GENERIC_DESKTOP:
+ switch (HID_USAGE(hitem.usage)) {
+ case HUG_JOYSTICK:
+ case HUG_GAME_PAD:
+ s = hid_usage_in_page(hitem.usage);
+ sp = malloc(strlen(s) + 5);
+ sprintf(sp, "%s (%d)", s,
+ joy->index);
+ joydevnames[joy->index] = sp;
+ }
+ }
+ break;
+ case hid_input:
+ switch (HID_PAGE(hitem.usage)) {
+ case HUP_GENERIC_DESKTOP:
+ switch (HID_USAGE(hitem.usage)) {
+ case HUG_X:
+ case HUG_Y:
+ case HUG_Z:
+ case HUG_SLIDER:
+ case HUG_WHEEL:
+#if 0
+ hw->axismin[joy->naxes] =
+ hitem.logical_minimum;
+ hw->axismax[joy->naxes] =
+ hitem.logical_maximum;
+#endif
+ joy->naxes++;
+ break;
+ }
+ break;
+ case HUP_BUTTON:
+ joy->nbuttons++;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ hid_end_parse(hdata);
+
+ /* The poll blocks the event thread. */
+ fcntl(fd, F_SETFL, O_NONBLOCK);
+
+ return (0);
+usberr:
+ close(hw->fd);
+ free(hw->path);
+ free(hw);
+ return (-1);
+}
+
+void
+SDL_SYS_JoystickUpdate(SDL_Joystick *joy)
+{
+ struct hid_item hitem;
+ struct hid_data *hdata;
+ struct report *rep;
+ int nbutton, naxe = -1;
+ Sint32 v;
+
+ rep = &joy->hwdata->inreport;
+
+ if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
+ return;
+ }
+#ifdef USBHID_NEW
+ hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
+#else
+ hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
+#endif
+ if (hdata == NULL) {
+ fprintf(stderr, "%s: Cannot start HID parser\n",
+ joy->hwdata->path);
+ return;
+ }
+
+ for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) {
+ switch (hitem.kind) {
+ case hid_input:
+ switch (HID_PAGE(hitem.usage)) {
+ case HUP_GENERIC_DESKTOP:
+ switch (HID_USAGE(hitem.usage)) {
+ case HUG_X:
+ naxe = JOYAXE_X;
+ goto scaleaxe;
+ case HUG_Y:
+ naxe = JOYAXE_Y;
+ goto scaleaxe;
+ case HUG_Z:
+ naxe = JOYAXE_Z;
+ goto scaleaxe;
+ case HUG_SLIDER:
+ naxe = JOYAXE_SLIDER;
+ goto scaleaxe;
+ case HUG_WHEEL:
+ naxe = JOYAXE_WHEEL;
+ goto scaleaxe;
+ default:
+ continue;
+ }
+scaleaxe:
+ v = (Sint32)hid_get_data(REP_BUF_DATA(rep),
+ &hitem);
+ v -= (hitem.logical_maximum + hitem.logical_minimum + 1)/2;
+ v *= 32768/((hitem.logical_maximum - hitem.logical_minimum + 1)/2);
+ if (v != joy->axes[naxe]) {
+ SDL_PrivateJoystickAxis(joy, naxe, v);
+ }
+ break;
+ case HUP_BUTTON:
+ v = (Sint32)hid_get_data(REP_BUF_DATA(rep),
+ &hitem);
+ if (joy->buttons[nbutton] != v) {
+ SDL_PrivateJoystickButton(joy,
+ nbutton, v);
+ }
+ nbutton++;
+ break;
+ default:
+ continue;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ hid_end_parse(hdata);
+
+ return;
+}
+
+/* Function to close a joystick after use */
+void
+SDL_SYS_JoystickClose(SDL_Joystick *joy)
+{
+ report_free(&joy->hwdata->inreport);
+ hid_dispose_report_desc(joy->hwdata->repdesc);
+ close(joy->hwdata->fd);
+ free(joy->hwdata->path);
+ free(joy->hwdata);
+
+ return;
+}
+
+void
+SDL_SYS_JoystickQuit(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_JOYS; i++) {
+ if (joynames[i] != NULL)
+ free(joynames[i]);
+ if (joydevnames[i] != NULL)
+ free(joydevnames[i]);
+ }
+
+ return;
+}
+
+static int
+report_alloc(struct report *r, struct report_desc *rd, int repind)
+{
+ int len;
+
+#ifdef USBHID_NEW
+ len = hid_report_size(rd, repinfo[repind].kind, r->rid);
+#else
+ len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
+#endif
+ if (len < 0) {
+ SDL_SetError("Negative HID report size");
+ return (-1);
+ }
+ r->size = len;
+
+ if (r->size > 0) {
+ r->buf = malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) +
+ r->size);
+ if (r->buf == NULL) {
+ SDL_OutOfMemory();
+ return (-1);
+ }
+ } else {
+ r->buf = NULL;
+ }
+
+ r->status = SREPORT_CLEAN;
+ return (0);
+}
+
+static void
+report_free(struct report *r)
+{
+ if (r->buf != NULL) {
+ free(r->buf);
+ }
+ r->status = SREPORT_UNINIT;
+}
+
diff --git a/devel/SDL/patches/patch-aj b/devel/SDL/patches/patch-aj
index 4f200e3c4a6..cc84cdfe75c 100644
--- a/devel/SDL/patches/patch-aj
+++ b/devel/SDL/patches/patch-aj
@@ -1,16 +1,14 @@
-$NetBSD: patch-aj,v 1.10 2002/07/13 16:17:33 wiz Exp $
-
+$NetBSD: patch-aj,v 1.11 2002/07/14 07:28:40 kristerw Exp $
--- configure.in.orig Thu Nov 8 08:28:00 2001
-+++ configure.in
++++ configure.in Sun Jul 14 06:02:41 2002
@@ -374,10 +374,7 @@
, enable_nas=yes)
if test x$enable_audio = xyes -a x$enable_nas = xyes; then
AC_MSG_CHECKING(for NAS audio support)
- have_nas=no
- if test -r /usr/X11R6/include/audio/audiolib.h; then
-- have_nas=yes
+ have_nas=yes
- fi
-+ have_nas=yes
AC_MSG_RESULT($have_nas)
if test x$have_nas = xyes; then
CFLAGS="$CFLAGS -DNAS_SUPPORT"
@@ -34,7 +32,132 @@ $NetBSD: patch-aj,v 1.10 2002/07/13 16:17:33 wiz Exp $
;;
*-*-openbsd*)
pthread_cflags="-D_REENTRANT"
-@@ -1465,11 +1462,13 @@
+@@ -1281,6 +1278,124 @@
+ VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la"
+ }
+
++dnl Check for the usbhid(3) library on *BSD
++CheckUSBHID()
++{
++ if test x$enable_joystick = xyes; then
++ have_libusbhid=no
++ have_libusb=no
++ AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
++ AC_CHECK_LIB(usb, hid_init, have_libusb=yes)
++ if test x$have_libusbhid = xyes; then
++ SYSTEM_LIBS="$SYSTEM_LIBS -lusbhid"
++ fi
++ if test x$have_libusb = xyes; then
++ SYSTEM_LIBS="$SYSTEM_LIBS -lusb"
++ fi
++
++ AC_CHECK_HEADER(usb.h, have_usb_h=yes)
++ AC_CHECK_HEADER(usbhid.h, have_usbhid_h=yes)
++ AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
++ AC_CHECK_HEADER(libusbhid.h, have_libusbhid_h=yes)
++ if test x$have_usb_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_USB_H"
++ fi
++ if test x$have_usbhid_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_USBHID_H"
++ fi
++ if test x$have_libusb_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_LIBUSB_H"
++ fi
++ if test x$have_libusbhid_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_LIBUSBHID_H"
++ fi
++
++ AC_MSG_CHECKING(for usbhid)
++ have_usbhid=no
++ AC_TRY_COMPILE([
++ #include <sys/types.h>
++ #if defined(HAVE_USB_H)
++ #include <usb.h>
++ #endif
++ #include <dev/usb/usb.h>
++ #include <dev/usb/usbhid.h>
++ #if defined(HAVE_USBHID_H)
++ #include <usbhid.h>
++ #elif defined(HAVE_LIBUSB_H)
++ #include <libusb.h>
++ #elif defined(HAVE_LIBUSBHID_H)
++ #include <libusbhid.h>
++ #endif
++ ],[
++ struct report_desc *repdesc;
++ struct usb_ctl_report *repbuf;
++ hid_kind_t hidkind;
++ ],[
++ have_usbhid=yes
++ ])
++ AC_MSG_RESULT($have_usbhid)
++
++ if test x$have_usbhid = xyes; then
++ AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
++ have_usbhid_ucr_data=no
++ AC_TRY_COMPILE([
++ #include <sys/types.h>
++ #if defined(HAVE_USB_H)
++ #include <usb.h>
++ #endif
++ #include <dev/usb/usb.h>
++ #include <dev/usb/usbhid.h>
++ #if defined(HAVE_USBHID_H)
++ #include <usbhid.h>
++ #elif defined(HAVE_LIBUSB_H)
++ #include <libusb.h>
++ #elif defined(HAVE_LIBUSBHID_H)
++ #include <libusbhid.h>
++ #endif
++ ],[
++ struct usb_ctl_report buf;
++ if (buf.ucr_data) { }
++ ],[
++ have_usbhid_ucr_data=yes
++ ])
++ if test x$have_usbhid_ucr_data = xyes; then
++ CFLAGS="$CFLAGS -DUSBHID_UCR_DATA"
++ fi
++ AC_MSG_RESULT($have_usbhid_ucr_data)
++
++ AC_MSG_CHECKING(for new usbhid API)
++ have_usbhid_new=no
++ AC_TRY_COMPILE([
++ #include <sys/types.h>
++ #if defined(HAVE_USB_H)
++ #include <usb.h>
++ #endif
++ #include <dev/usb/usb.h>
++ #include <dev/usb/usbhid.h>
++ #if defined(HAVE_USBHID_H)
++ #include <usbhid.h>
++ #elif defined(HAVE_LIBUSB_H)
++ #include <libusb.h>
++ #elif defined(HAVE_LIBUSBHID_H)
++ #include <libusbhid.h>
++ #endif
++ ],[
++ report_desc_t d;
++ hid_start_parse(d, 1, 1);
++ ],[
++ have_usbhid_new=yes
++ ])
++ if test x$have_usbhid_new = xyes; then
++ CFLAGS="$CFLAGS -DUSBHID_NEW"
++ fi
++ AC_MSG_RESULT($have_usbhid_new)
++
++ JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
++ JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
++ fi
++ fi
++}
++
+ case "$target" in
+ *-*-linux*)
+ ARCH=linux
+@@ -1465,14 +1580,17 @@
CheckDummyVideo
CheckDiskAudio
CheckNASM
@@ -48,27 +171,51 @@ $NetBSD: patch-aj,v 1.10 2002/07/13 16:17:33 wiz Exp $
CheckAAlib
CheckOpenGL
CheckPTHREAD
-@@ -1770,7 +1769,11 @@
++ CheckUSBHID
+ # Set up files for the main() stub
+ COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+ # Set up files for the audio library
+@@ -1481,12 +1599,6 @@
+ AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+ AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+ fi
+- # Set up files for the joystick library
+- # (No joystick support yet)
+- if test x$enable_joystick = xyes; then
+- JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+- JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+- fi
+ # Set up files for the cdrom library
+ if test x$enable_cdrom = xyes; then
+ CDROM_SUBDIRS="$CDROM_SUBDIRS openbsd"
+@@ -1770,7 +1882,11 @@
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
-- COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+ if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
+ COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+ else
-+ COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+ COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+ fi
COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
-@@ -2157,6 +2160,10 @@
-
- if test $ARCH = solaris; then
+@@ -2159,6 +2275,10 @@
SDL_RLD_FLAGS="-R\${exec_prefix}/lib"
-+fi
-+
-+if test $ARCH = netbsd; then
-+ SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib -Wl,-rpath,${X11BASE}/lib"
fi
++if test $ARCH = netbsd; then
++ SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib -Wl,-rpath,${X11BASE}/lib"
++fi
++
if test $ARCH = openbsd; then
+ SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib $SYSTEM_LIBS"
+ fi
+@@ -2277,6 +2397,7 @@
+ src/joystick/Makefile
+ src/joystick/amigaos/Makefile
+ src/joystick/beos/Makefile
++src/joystick/bsd/Makefile
+ src/joystick/darwin/Makefile
+ src/joystick/dummy/Makefile
+ src/joystick/linux/Makefile
diff --git a/devel/SDL/patches/patch-am b/devel/SDL/patches/patch-am
index 9a715c5e3e2..8027f582aaa 100644
--- a/devel/SDL/patches/patch-am
+++ b/devel/SDL/patches/patch-am
@@ -1,16 +1,14 @@
-$NetBSD: patch-am,v 1.3 2002/07/13 16:17:33 wiz Exp $
-
---- configure.orig Thu Nov 8 08:28:08 2001
-+++ configure
+$NetBSD: patch-am,v 1.4 2002/07/14 07:28:40 kristerw Exp $
+--- configure.orig Sun Jul 14 05:59:37 2002
++++ configure Sun Jul 14 06:02:55 2002
@@ -3588,10 +3588,7 @@
if test x$enable_audio = xyes -a x$enable_nas = xyes; then
echo $ac_n "checking for NAS audio support""... $ac_c" 1>&6
echo "configure:3591: checking for NAS audio support" >&5
- have_nas=no
- if test -r /usr/X11R6/include/audio/audiolib.h; then
-- have_nas=yes
+ have_nas=yes
- fi
-+ have_nas=yes
echo "$ac_t""$have_nas" 1>&6
if test x$have_nas = xyes; then
CFLAGS="$CFLAGS -DNAS_SUPPORT"
@@ -34,7 +32,385 @@ $NetBSD: patch-am,v 1.3 2002/07/13 16:17:33 wiz Exp $
;;
*-*-openbsd*)
pthread_cflags="-D_REENTRANT"
-@@ -6588,11 +6585,13 @@
+@@ -6034,6 +6031,377 @@
+ VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la"
+ }
+
++CheckUSBHID()
++{
++ if test x$enable_joystick = xyes; then
++ have_libusbhid=no
++ have_libusb=no
++ echo $ac_n "checking for hid_init in -lusbhid""... $ac_c" 1>&6
++echo "configure:6041: checking for hid_init in -lusbhid" >&5
++ac_lib_var=`echo usbhid'_'hid_init | sed 'y%./+-%__p_%'`
++if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
++ echo $ac_n "(cached) $ac_c" 1>&6
++else
++ ac_save_LIBS="$LIBS"
++LIBS="-lusbhid $LIBS"
++cat > conftest.$ac_ext <<EOF
++#line 6049 "configure"
++#include "confdefs.h"
++/* Override any gcc2 internal prototype to avoid an error. */
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char hid_init();
++
++int main() {
++hid_init()
++; return 0; }
++EOF
++if { (eval echo configure:6060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++ rm -rf conftest*
++ eval "ac_cv_lib_$ac_lib_var=yes"
++else
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ rm -rf conftest*
++ eval "ac_cv_lib_$ac_lib_var=no"
++fi
++rm -f conftest*
++LIBS="$ac_save_LIBS"
++
++fi
++if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
++ echo "$ac_t""yes" 1>&6
++ have_libusbhid=yes
++else
++ echo "$ac_t""no" 1>&6
++fi
++
++ echo $ac_n "checking for hid_init in -lusb""... $ac_c" 1>&6
++echo "configure:6081: checking for hid_init in -lusb" >&5
++ac_lib_var=`echo usb'_'hid_init | sed 'y%./+-%__p_%'`
++if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
++ echo $ac_n "(cached) $ac_c" 1>&6
++else
++ ac_save_LIBS="$LIBS"
++LIBS="-lusb $LIBS"
++cat > conftest.$ac_ext <<EOF
++#line 6089 "configure"
++#include "confdefs.h"
++/* Override any gcc2 internal prototype to avoid an error. */
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char hid_init();
++
++int main() {
++hid_init()
++; return 0; }
++EOF
++if { (eval echo configure:6100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++ rm -rf conftest*
++ eval "ac_cv_lib_$ac_lib_var=yes"
++else
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ rm -rf conftest*
++ eval "ac_cv_lib_$ac_lib_var=no"
++fi
++rm -f conftest*
++LIBS="$ac_save_LIBS"
++
++fi
++if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
++ echo "$ac_t""yes" 1>&6
++ have_libusb=yes
++else
++ echo "$ac_t""no" 1>&6
++fi
++
++ if test x$have_libusbhid = xyes; then
++ SYSTEM_LIBS="$SYSTEM_LIBS -lusbhid"
++ fi
++ if test x$have_libusb = xyes; then
++ SYSTEM_LIBS="$SYSTEM_LIBS -lusb"
++ fi
++
++ ac_safe=`echo "usb.h" | sed 'y%./+-%__p_%'`
++echo $ac_n "checking for usb.h""... $ac_c" 1>&6
++echo "configure:6129: checking for usb.h" >&5
++if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
++ echo $ac_n "(cached) $ac_c" 1>&6
++else
++ cat > conftest.$ac_ext <<EOF
++#line 6134 "configure"
++#include "confdefs.h"
++#include <usb.h>
++EOF
++ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
++{ (eval echo configure:6139: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
++if test -z "$ac_err"; then
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=yes"
++else
++ echo "$ac_err" >&5
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=no"
++fi
++rm -f conftest*
++fi
++if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
++ echo "$ac_t""yes" 1>&6
++ have_usb_h=yes
++else
++ echo "$ac_t""no" 1>&6
++fi
++
++ ac_safe=`echo "usbhid.h" | sed 'y%./+-%__p_%'`
++echo $ac_n "checking for usbhid.h""... $ac_c" 1>&6
++echo "configure:6162: checking for usbhid.h" >&5
++if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
++ echo $ac_n "(cached) $ac_c" 1>&6
++else
++ cat > conftest.$ac_ext <<EOF
++#line 6167 "configure"
++#include "confdefs.h"
++#include <usbhid.h>
++EOF
++ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
++{ (eval echo configure:6172: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
++if test -z "$ac_err"; then
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=yes"
++else
++ echo "$ac_err" >&5
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=no"
++fi
++rm -f conftest*
++fi
++if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
++ echo "$ac_t""yes" 1>&6
++ have_usbhid_h=yes
++else
++ echo "$ac_t""no" 1>&6
++fi
++
++ ac_safe=`echo "libusb.h" | sed 'y%./+-%__p_%'`
++echo $ac_n "checking for libusb.h""... $ac_c" 1>&6
++echo "configure:6195: checking for libusb.h" >&5
++if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
++ echo $ac_n "(cached) $ac_c" 1>&6
++else
++ cat > conftest.$ac_ext <<EOF
++#line 6200 "configure"
++#include "confdefs.h"
++#include <libusb.h>
++EOF
++ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
++{ (eval echo configure:6205: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
++if test -z "$ac_err"; then
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=yes"
++else
++ echo "$ac_err" >&5
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=no"
++fi
++rm -f conftest*
++fi
++if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
++ echo "$ac_t""yes" 1>&6
++ have_libusb_h=yes
++else
++ echo "$ac_t""no" 1>&6
++fi
++
++ ac_safe=`echo "libusbhid.h" | sed 'y%./+-%__p_%'`
++echo $ac_n "checking for libusbhid.h""... $ac_c" 1>&6
++echo "configure:6228: checking for libusbhid.h" >&5
++if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
++ echo $ac_n "(cached) $ac_c" 1>&6
++else
++ cat > conftest.$ac_ext <<EOF
++#line 6233 "configure"
++#include "confdefs.h"
++#include <libusbhid.h>
++EOF
++ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
++{ (eval echo configure:6238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
++if test -z "$ac_err"; then
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=yes"
++else
++ echo "$ac_err" >&5
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++ rm -rf conftest*
++ eval "ac_cv_header_$ac_safe=no"
++fi
++rm -f conftest*
++fi
++if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
++ echo "$ac_t""yes" 1>&6
++ have_libusbhid_h=yes
++else
++ echo "$ac_t""no" 1>&6
++fi
++
++ if test x$have_usb_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_USB_H"
++ fi
++ if test x$have_usbhid_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_USBHID_H"
++ fi
++ if test x$have_libusb_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_LIBUSB_H"
++ fi
++ if test x$have_libusbhid_h = xyes; then
++ CFLAGS="$CFLAGS -DHAVE_LIBUSBHID_H"
++ fi
++
++ echo $ac_n "checking for usbhid""... $ac_c" 1>&6
++echo "configure:6273: checking for usbhid" >&5
++ have_usbhid=no
++ cat > conftest.$ac_ext <<EOF
++#line 6276 "configure"
++#include "confdefs.h"
++
++ #include <sys/types.h>
++ #if defined(HAVE_USB_H)
++ #include <usb.h>
++ #endif
++ #include <dev/usb/usb.h>
++ #include <dev/usb/usbhid.h>
++ #if defined(HAVE_USBHID_H)
++ #include <usbhid.h>
++ #elif defined(HAVE_LIBUSB_H)
++ #include <libusb.h>
++ #elif defined(HAVE_LIBUSBHID_H)
++ #include <libusbhid.h>
++ #endif
++
++int main() {
++
++ struct report_desc *repdesc;
++ struct usb_ctl_report *repbuf;
++ hid_kind_t hidkind;
++
++; return 0; }
++EOF
++if { (eval echo configure:6301: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++ rm -rf conftest*
++
++ have_usbhid=yes
++
++else
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++fi
++rm -f conftest*
++ echo "$ac_t""$have_usbhid" 1>&6
++
++ if test x$have_usbhid = xyes; then
++ echo $ac_n "checking for ucr_data member of usb_ctl_report""... $ac_c" 1>&6
++echo "configure:6315: checking for ucr_data member of usb_ctl_report" >&5
++ have_usbhid_ucr_data=no
++ cat > conftest.$ac_ext <<EOF
++#line 6318 "configure"
++#include "confdefs.h"
++
++ #include <sys/types.h>
++ #if defined(HAVE_USB_H)
++ #include <usb.h>
++ #endif
++ #include <dev/usb/usb.h>
++ #include <dev/usb/usbhid.h>
++ #if defined(HAVE_USBHID_H)
++ #include <usbhid.h>
++ #elif defined(HAVE_LIBUSB_H)
++ #include <libusb.h>
++ #elif defined(HAVE_LIBUSBHID_H)
++ #include <libusbhid.h>
++ #endif
++
++int main() {
++
++ struct usb_ctl_report buf;
++ if (buf.ucr_data) { }
++
++; return 0; }
++EOF
++if { (eval echo configure:6342: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++ rm -rf conftest*
++
++ have_usbhid_ucr_data=yes
++
++else
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++fi
++rm -f conftest*
++ if test x$have_usbhid_ucr_data = xyes; then
++ CFLAGS="$CFLAGS -DUSBHID_UCR_DATA"
++ fi
++ echo "$ac_t""$have_usbhid_ucr_data" 1>&6
++
++ echo $ac_n "checking for new usbhid API""... $ac_c" 1>&6
++echo "configure:6358: checking for new usbhid API" >&5
++ have_usbhid_new=no
++ cat > conftest.$ac_ext <<EOF
++#line 6361 "configure"
++#include "confdefs.h"
++
++ #include <sys/types.h>
++ #if defined(HAVE_USB_H)
++ #include <usb.h>
++ #endif
++ #include <dev/usb/usb.h>
++ #include <dev/usb/usbhid.h>
++ #if defined(HAVE_USBHID_H)
++ #include <usbhid.h>
++ #elif defined(HAVE_LIBUSB_H)
++ #include <libusb.h>
++ #elif defined(HAVE_LIBUSBHID_H)
++ #include <libusbhid.h>
++ #endif
++
++int main() {
++
++ report_desc_t d;
++ hid_start_parse(d, 1, 1);
++
++; return 0; }
++EOF
++if { (eval echo configure:6385: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++ rm -rf conftest*
++
++ have_usbhid_new=yes
++
++else
++ echo "configure: failed program was:" >&5
++ cat conftest.$ac_ext >&5
++fi
++rm -f conftest*
++ if test x$have_usbhid_new = xyes; then
++ CFLAGS="$CFLAGS -DUSBHID_NEW"
++ fi
++ echo "$ac_t""$have_usbhid_new" 1>&6
++
++ JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS bsd"
++ JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS bsd/libjoystick_bsd.la"
++ fi
++ fi
++}
++
+ case "$target" in
+ *-*-linux*)
+ ARCH=linux
+@@ -6588,14 +6956,17 @@
CheckDummyVideo
CheckDiskAudio
CheckNASM
@@ -48,11 +424,27 @@ $NetBSD: patch-am,v 1.3 2002/07/13 16:17:33 wiz Exp $
CheckAAlib
CheckOpenGL
CheckPTHREAD
-@@ -7553,7 +7552,20 @@
++ CheckUSBHID
+ # Set up files for the main() stub
+
+ echo "Copying src/main/linux/SDL_main.c -> src/main/SDL_main.c"
+@@ -6614,12 +6985,6 @@
+ AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+ AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+ fi
+- # Set up files for the joystick library
+- # (No joystick support yet)
+- if test x$enable_joystick = xyes; then
+- JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+- JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+- fi
+ # Set up files for the cdrom library
+ if test x$enable_cdrom = xyes; then
+ CDROM_SUBDIRS="$CDROM_SUBDIRS openbsd"
+@@ -7553,6 +7918,19 @@
__EOF__
cat >>$new <$old
--
+ if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
+
+ echo "Copying src/thread/generic/SDL_syssem.c -> src/thread/SDL_syssem.c"
@@ -66,11 +458,10 @@ $NetBSD: patch-am,v 1.3 2002/07/13 16:17:33 wiz Exp $
+ cat >>$new <$old
+
+ else
-+
+
echo "Copying src/thread/linux/SDL_syssem.c -> src/thread/SDL_syssem.c"
old="$srcdir/src/thread/linux/SDL_syssem.c"
- new="$srcdir/src/thread/SDL_syssem.c"
-@@ -7564,6 +7576,7 @@
+@@ -7564,6 +7942,7 @@
__EOF__
cat >>$new <$old
@@ -78,14 +469,30 @@ $NetBSD: patch-am,v 1.3 2002/07/13 16:17:33 wiz Exp $
echo "Copying src/thread/generic/SDL_syssem_c.h -> src/thread/SDL_syssem_c.h"
old="$srcdir/src/thread/generic/SDL_syssem_c.h"
-@@ -8842,6 +8855,10 @@
-
- if test $ARCH = solaris; then
+@@ -8844,6 +9223,10 @@
SDL_RLD_FLAGS="-R\${exec_prefix}/lib"
-+fi
-+
-+if test $ARCH = netbsd; then
-+ SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib -Wl,-rpath,${X11BASE}/lib"
fi
++if test $ARCH = netbsd; then
++ SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib -Wl,-rpath,${X11BASE}/lib"
++fi
++
if test $ARCH = openbsd; then
+ SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib $SYSTEM_LIBS"
+ fi
+@@ -9068,6 +9451,7 @@
+ src/joystick/Makefile
+ src/joystick/amigaos/Makefile
+ src/joystick/beos/Makefile
++src/joystick/bsd/Makefile
+ src/joystick/darwin/Makefile
+ src/joystick/dummy/Makefile
+ src/joystick/linux/Makefile
+@@ -9328,6 +9712,7 @@
+ src/joystick/Makefile
+ src/joystick/amigaos/Makefile
+ src/joystick/beos/Makefile
++src/joystick/bsd/Makefile
+ src/joystick/darwin/Makefile
+ src/joystick/dummy/Makefile
+ src/joystick/linux/Makefile