Bug 132150 - [PATCH] devel/sdl: fix build with new usb stack
Summary: [PATCH] devel/sdl: fix build with new usb stack
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Marcus von Appen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-27 03:50 UTC by Yuri Pankov
Modified: 2009-03-13 16:40 UTC (History)
1 user (show)

See Also:


Attachments
sdl-1.2.13_3,2.patch (1.48 KB, patch)
2009-02-27 03:50 UTC, Yuri Pankov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Pankov 2009-02-27 03:50:01 UTC
Fix build with new usb stack.

Added file(s):
- files/usb2

Port maintainer (mva@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.77
Comment 1 Marcus von Appen freebsd_committer freebsd_triage 2009-02-27 18:43:57 UTC
Responsible Changed
From-To: freebsd-ports-bugs->mva

I'll take it.
Comment 2 Mark Linimon 2009-03-02 01:08:03 UTC
Here's an alternative patch posted to the mailing lists by hps.

mcl

----- Forwarded message from Hans Petter Selasky <hselasky@c2i.net> -----

From: Hans Petter Selasky <hselasky@c2i.net>
To: Mark Linimon <linimon@lonesome.com>
Subject: Re: list of ports broken by USB switchover?
Cc: freebsd-ports@freebsd.org

Quick and dirty patch for "/usr/ports/devel/sdl12" is attached.

.libs/SDL_sysjoystick.o
./src/joystick/bsd/SDL_sysjoystick.c: In function 'SDL_SYS_JoystickOpen':
./src/joystick/bsd/SDL_sysjoystick.c:297: error: 'USB_GET_REPORT_ID' 
undeclared 
(first use in this function)
./src/joystick/bsd/SDL_sysjoystick.c:297: error: (Each undeclared identifier 
is 
reported only once
./src/joystick/bsd/SDL_sysjoystick.c:297: error: for each function it appears 
in
.)
./src/joystick/bsd/SDL_sysjoystick.c: In function 'SDL_SYS_JoystickUpdate':
./src/joystick/bsd/SDL_sysjoystick.c:445: error: dereferencing pointer to 
incomp
lete type
./src/joystick/bsd/SDL_sysjoystick.c:469: error: dereferencing pointer to 
incomp
lete type
./src/joystick/bsd/SDL_sysjoystick.c:477: error: dereferencing pointer to 
incomp
lete type
./src/joystick/bsd/SDL_sysjoystick.c:485: error: dereferencing pointer to 
incomp


Solution:

Use new functions from libusbhid. See "man libusbhid" !

--HPS

--- work/SDL-1.2.13/./src/joystick/bsd/SDL_sysjoystick.c	2007-12-31 05:47:55.000000000 +0100
+++ ./SDL_sysjoystick.c	2009-03-01 19:06:23.000000000 +0100
@@ -36,24 +36,8 @@
 #include <fcntl.h>
 #include <errno.h>
 
-#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>
-#elif defined(HAVE_LIBUSB_H)
-#include <libusb.h>
-#elif defined(HAVE_LIBUSBHID_H)
-#include <libusbhid.h>
-#endif
+#include <dev/usb/usbhid.h>
 
 #ifdef __FREEBSD__
 #ifndef __DragonFly__
@@ -74,6 +58,11 @@
 #define MAX_JOY_JOYS	2
 #define MAX_JOYS	(MAX_UHID_JOYS + MAX_JOY_JOYS)
 
+struct usb_ctl_report {
+        int     ucr_report;
+        u_char  ucr_data[1024]; /* filled data size will vary */
+};
+
 struct report {
 	struct	usb_ctl_report *buf;	/* Buffer */
 	size_t	size;			/* Buffer size */
@@ -137,11 +126,7 @@
 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)
@@ -294,7 +279,8 @@
 	}
 
 	rep = &hw->inreport;
-	if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) {
+	rep->rid = hid_get_report_id(fd);
+	if (rep->rid < 0) {
 		rep->rid = -1; /* XXX */
 	}
 	if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) {
@@ -306,11 +292,7 @@
 		goto usberr;
 	}
 
-#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_version >= 500111)
 	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;
@@ -390,7 +372,7 @@
 	int nbutton, naxe = -1;
 	Sint32 v;
 
-#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
+#if defined(__FreeBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
 	struct joystick gameport;
  
 	if (joy->hwdata->type == BSDJOY_JOY) {
@@ -445,11 +427,7 @@
 	if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
 		return;
 	}
-#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_version >= 500111)
 	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);
@@ -538,25 +516,7 @@
 {
 	int len;
 
-#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);
-#  else
-	len = hid_report_size(rd, repinfo[repind].kind, r->rid);
-#  endif
-# else
-	len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
-# 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);
-# endif
-#endif
 
 	if (len < 0) {
 		SDL_SetError("Negative HID report size");


----- End forwarded message -----
Comment 3 Yuri Pankov 2009-03-04 01:53:22 UTC
Please close this PR, another fix was already comitted.
Comment 4 Stanislav Sedov freebsd_committer 2009-03-08 09:19:38 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

I think the patch proposed by hps should be commited, as
it fixes joysticks with SDL, while the current solution
is to disable it, which is a regression.

- -- 
Stanislav Sedov
ST4096-RIPE
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkmzjaoACgkQK/VZk+smlYHAfgCcD6rPPuGI3veRBsLhp2Kta5I3
/T8AnAlRmMS/knfWMNG5RzhMUj3TI8LN
=dUt0
-----END PGP SIGNATURE-----

!DSPAM:49b38d92967001875713468!
Comment 5 Marcus von Appen freebsd_committer freebsd_triage 2009-03-08 22:25:46 UTC
On, Sun Mar 08, 2009, Stanislav Sedov wrote:

> Hi!
> 
> I think the patch proposed by hps should be commited, as
> it fixes joysticks with SDL, while the current solution
> is to disable it, which is a regression.


Unfortunately hps' patch is untested, which is why I'm currently working
on a proper tested version that should be ready soon. Until then I'll
leave this open for reference.

Regards
Marcus
Comment 6 dfilter service freebsd_committer 2009-03-13 16:33:16 UTC
mva         2009-03-13 16:32:58 UTC

  FreeBSD ports repository

  Modified files:
    devel/sdl12          Makefile 
  Added files:
    devel/sdl12/files    patch-src_joystick_bsd_SDL_sysjoystick.c 
  Log:
  Reactivate USB joystick support on -CURRENT.
  
  PR:     ports/132150
  Submitted by:   hps
  Approved by:    miwi (mentor)
  
  Revision  Changes    Path
  1.118     +1 -5      ports/devel/sdl12/Makefile
  1.1       +40 -0     ports/devel/sdl12/files/patch-src_joystick_bsd_SDL_sysjoystick.c (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 Marcus von Appen freebsd_committer freebsd_triage 2009-03-13 16:36:40 UTC
State Changed
From-To: open->closed

Committed, with minor changes. Thanks!