We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4

Summary: multiple sticks on one USB node
Product: SDL Reporter: Ryan C. Gordon <icculus>
Component: joystickAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: mactalla.obair, shattered
Version: don't know   
Hardware: All   
OS: Linux   
Attachments: sdl multi stick one usb node patch
query report ID of HID device

Description Ryan C. Gordon 2006-01-03 11:35:04 UTC
Date: Mon, 21 Mar 2005 09:41:11 -0500
From: Chris Nelson <chrisn1@bu.edu>
To: "Ryan C. Gordon" <icculus@clutteredmind.org>
Subject: SDL Patch

Hey, Ryan.

I submitted the following patch about a year ago. It's just a simple 
patch for the linux port, to make multiple joysticks each appear to SDL 
as their own device, if they are on the same USB port (specifically, 
these guys 
<http://www.consoleplus.co.uk/product_info.php?pName=super-joybox-5-quad-joypad-converter>,

which allow 4 Playstation2 controllers to be accessed via a single USB 
port). Without this patch, SDL pretty much drops the ball, and reports 
that there are 4 joysticks available when less than that number  are 
plugged in.

My work built upon the work of another person with the same device. When 
I submitted the patch to the list, he tested it, but it didn't work for 
him, so the patch was never accepted. Maybe about 3 times in the past 
year, I've tried to email the guy, to see if he couldn't run my new 
version, complete with debug code to diagnose the problem he was having. 
He never got back  to me.

So, I'm attaching the patch. I wish I knew why it didn't work for him, 
but I've been using it for the last year with no problems. Let me know 
if you need any more information, or have any ideas as to how I could 
test it. I'd like to see it in the tree, but I want to make sure it works.

-Chris
Comment 1 Ryan C. Gordon 2006-01-03 11:36:02 UTC
Created attachment 3 [details]
sdl multi stick one usb node patch
Comment 2 Ryan C. Gordon 2006-01-03 11:37:00 UTC
This one was just waiting for confirmation that it was a good patch...I'm inclined to apply it now and see if anyone yells.

--ryan.

Comment 3 Ryan C. Gordon 2006-01-27 11:23:00 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 4 Andrew Fuller 2006-02-10 22:52:26 UTC
(In reply to comment #2)
> This one was just waiting for confirmation that it was a good patch...I'm
> inclined to apply it now and see if anyone yells.
> 
> --ryan.
> 

I tested this with my 8866 (the two joystick version), and it's working for me... except that my system isn't reading the name for my adapter, so is falling back to the USB ID as the name.  So I do need to change the two lines in the patch to have it take effect.  But then it works great.  I would love to see this patch merged into CVS.

-Andrew
Comment 5 Sam Lantinga 2006-02-10 23:46:27 UTC
> I tested this with my 8866 (the two joystick version), and it's working for
> me... except that my system isn't reading the name for my adapter, so is
> falling back to the USB ID as the name.  So I do need to change the two lines
> in the patch to have it take effect.  But then it works great.  I would love to
> see this patch merged into CVS.

Can you attach a diff relative to the patched source that shows what you need to change to make it work?

Thank!
Comment 6 Andrew Fuller 2006-03-06 17:37:41 UTC
(In reply to comment #5)
> > I tested this with my 8866 (the two joystick version), and it's working for
> > me... except that my system isn't reading the name for my adapter, so is
> > falling back to the USB ID as the name.  So I do need to change the two lines
> > in the patch to have it take effect.  But then it works great.  I would love to
> > see this patch merged into CVS.
> 
> Can you attach a diff relative to the patched source that shows what you need
> to change to make it work?
> 
> Thank!

I've been working with this further, and this patch is not needed for the dual version of this adapter (MP-8866) any longer.  A patch has been committed to the linux kernel (as of 2.6.16 post rc5) which retrieves all the inputs from this device, meaning we have access to the individual joysticks at a lower level than SDL -- where it belongs.

Essentially, this device falsely advertises that it has a single input.  It's a two-line fix to tell the kernel to ignore what what is advertised and search for all inputs.

Perhaps the original author of this patch can see if HID_QUIRK_MULTI_INPUT also works for his quad version and SDL won't need to worry about it.

See here for the patch of the dual version:
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e65335ef187c9cbc50bbc56be0fe966b593beb49
Comment 7 Sam Lantinga 2006-03-19 01:32:49 UTC
I added this patch to CVS anyway, since it's a cleaner version of what was already implemented.  Can you verify that it works correctly on older kernels, and doesn't break anything on newer kernels?

Thanks!
Comment 8 shattered 2006-03-19 12:35:41 UTC
I've made a similar patch to BSD-specific USB driver, please review it too.
Comment 9 shattered 2006-03-19 12:37:20 UTC
Created attachment 85 [details]
query report ID of HID device
Comment 10 Sam Lantinga 2006-03-20 03:00:25 UTC
(In reply to comment #9)
> Created an attachment (id=85) [edit]
> query report ID of HID device
> 

Looks good to me...