Subject: USB joystick can't work with xmame-0.56.2 correctly
To: None <current-users@netbsd.org>
From: Rui-Xiang Guo <rxg@ms25.url.com.tw>
List: tech-pkg
Date: 01/06/2002 16:53:18
Hi,
first thing to say:
xmame-0.56.2 doesn't compile with USB joystick under -current,
the Makefile will check /usr/lib/libusb.a but I only have
/usr/lib/libusbhid* on my box, so we need to change the Makefile with

--- /usr/pkgsrc/emulators/xmame/Makefile        Sat Jan  5 17:52:53 2002
+++ ./Makefile
@@ -97,7 +97,7 @@
 MAKE_FLAGS+=           JOY_I386=1
 .endif
 .if ${OPSYS} == "NetBSD"
-.  if exists(/usr/lib/libusb.a)
+.  if exists(/usr/lib/libusbhid.a)
 MAKE_FLAGS+=           JOY_USB=1
 .  endif
 .endif

We also need to add these two patches:

patch-af:
$NetBSD$

--- src/unix/joystick-drivers/joy_usb.c.orig    Sat Nov  3 09:22:56 2001
+++ src/unix/joystick-drivers/joy_usb.c
@@ -21,7 +21,7 @@
 #endif
 
 #if defined(__ARCH_netbsd)
-#include <usb.h>
+#include <usbhid.h>
 #elif defined(__ARCH_freebsd)
 #include <libusb.h>
 #endif
@@ -69,7 +69,7 @@
 
 static int joy_initialize_hid(int i)
 {
-  int size, is_joystick, report_id;
+  int size, is_joystick, report_id = i;
   struct hid_data *d;
   struct hid_item h;
   report_desc_t rd;
@@ -82,7 +82,7 @@
 
   priv_joy_data[i].hids = NULL;
 
-  size = hid_report_size(rd, hid_input, &report_id);
+  size = hid_report_size(rd, hid_input, report_id);
   if ((priv_joy_data[i].data_buf = malloc(size)) == NULL)
     {
       fprintf(stderr_file, "error: couldn't malloc %d bytes\n", size);
@@ -93,7 +93,7 @@
   priv_joy_data[i].offset = (report_id != 0);
 
   is_joystick = 0;
-  for (d = hid_start_parse(rd, 1 << hid_input); hid_get_item(d, &h); )
+  for (d = hid_start_parse(rd, 1 << hid_input, report_id); hid_get_item(d, &h);
 )
     {
       int axis, usage, page, interesting_hid;
 
patch-ag:
$NetBSD$

--- src/unix/unix.mak.orig      Sun Jan  6 16:08:10 2002
+++ src/unix/unix.mak
@@ -210,7 +210,7 @@
 endif
 ifdef JOY_USB
 CONFIG += -DUSB_JOYSTICK
-MY_LIBS += -lusb
+MY_LIBS += -lusbhid
 endif
 
 ifdef EFENCE

Then I use my USB joystick with xmame-0.56.2, the buttons all works well,
but the man in the xmame screen always go to left. I want him go to right! :)
It seems the joy_usb.c driver doesn't decide the 'center' value properly with
some devices.
Can we find the better way to get more correctly 'center' value?
Need your help! :)

Regards
-rxg