Assign unique IDs to joysticks

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
Dryer Lint
New Member
Posts: 7
Joined: Tue Jan 02, 2007 12:03 pm

Assign unique IDs to joysticks

Post by Dryer Lint »

I frequently attach and remove different USB joysticks of all kinds, so on one boot-up my Wingman Gamepad (that is usually my "player 1 pad") might be /dev/input/js0 and sometimes js3 or 4 or anything. (note: I'm using Linux)

Before I started using Mednafen I was used to re-mapping my controls in every emulator again and again. But Mednafen somehow assigns each different joystick a unique ID and it recognizes each joystick individually, no matter what js-device it is right now.

It would be really great if something like this could be implemented for ZSNES, it is SO convenient not to have to re-map the controls all the time.

Mednafen's source-code is available and it also uses SDL (at least for the input), AFAIK.
PHoNyMiKe
Retrosexual
Posts: 1011
Joined: Wed Jul 28, 2004 2:09 am
Location: Rapture

Post by PHoNyMiKe »

I think it'd be even more convenient if you spend $30 on a PCI 6 port usb card and just left all your play sticks plugged in at all times. if you got more than 1 controller hooked up to your computer at any time then you have problems that cannot be solved by zsnes developers anyways.

p.s. if you used windows you wouldn't be having this problem :wink:
[url=http://www.alexchiu.com/affiliates/clickthru.cgi?id=phonymike]ultimate immortality[/url]
[url=http://www.sloganizer.net/en/][img]http://www.sloganizer.net/en/image,zsnes,white,purple.png[/img][/url]
Dryer Lint
New Member
Posts: 7
Joined: Tue Jan 02, 2007 12:03 pm

Post by Dryer Lint »

I already have plenty of USB ports, thank you.
I just don't like to have a mess of cables around my desk, also those controllers waste space when they are not needed, especially my Guitar Hero controller. In fact, I often remove all controllers.
Also, when friends come over they often bring the controllers we need, so I can't have them attached all time.

Sorry, but you didn't convince me. :)

I can't be the only one that thinks this is a good idea?
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

The joystick code system in general needs to be reworked anyways, on the other hand, it is not a priority to be changed.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Dasaan
New Member
Posts: 5
Joined: Sat Feb 24, 2007 4:52 pm

Post by Dasaan »

This sounds more like something that udev would help with.

Create some rule thats look at the vendor and model IDs and create the device nodes based on that.

For example if you had a wingman and a psx adaptor. You plug in the wingman udev would notice that and create a device node called /dev/input/js0 every time bu if you plugged in the psx adaptor then it'd create the node /dev/input/js1 every time instead.

udev is pretty easy to write basic rules for and there are plenty of howtos on the net.

The only problem with this method that I can think of, off the top of my head, is if you and your friend both have a gamepad with the same vendor and model IDs and you still wanted your gamepad to be /dev/input/js0 and theirs to be /dev/input/js1. That could be a bit more tricky.

Also you may need to create the /dev/input/event nodes too.

If you have any luck or find anything else out shout up as I have to get around to doing this myself at some point and it'd be nice to have a bit of a heads up on any unforeseen problems.
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

in all cases, the USB port ID should be included in the udev rules if possible.
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
Dasaan
New Member
Posts: 5
Joined: Sat Feb 24, 2007 4:52 pm

Post by Dasaan »

Hmm, yes that'd work all right.

Thanks for pointing that out :)

EDIT: Having had a little play around trying to get this working nicely I have managed to find half a solution.

I have a psx adaptor and a gravis gamepad. When I plug in the psx adaptor I have udev create a symlink called input/psx which links to input/js[09]* and I also have a similar rule for the gravis pad. However most programs I've encountered, including zsnes, still use the, flawed nowadays, assumption that gamepads will always have a device node called either /dev/js<foo> or /dev/input/js<foo>.

I would like to see an option in the input device tabs to select which node to use for each device. If I've missed just such an option then I do apologise, I have looked but lack of sleep may have caused me to miss it ;)
Post Reply