# Working on a driver for a SNES USB gamepad



## lispandtrees (Feb 19, 2013)

2 issues

1. I disabled the uhid module from kernel to test my driver. Emulators will recognize my driver if I create a symbolic link from my driver to /dev/uhid0. Is there a way I can get applications to recognize my driver without doing this?

2. The emulators will recognize only certain buttons. I can't figure out if this is an issue with my driver code or the uhid report descriptor table that I got from this file:
http://lxr.linux.no/linux+v3.7.7/drivers/hid/hid-dr.c


the code is here:
https://github.com/lispandtrees/dragon_rise_driver/blob/master/snes_usb.c


----------



## lispandtrees (Feb 19, 2013)

The descriptor is at line 210 of the hid-dr.c code.


----------



## lispandtrees (Jul 22, 2013)

I finally figured it out and got the driver working! The only problem now is that there's slight lag when pressing buttons but I'm sure I'll be able to fix that.


----------



## fonz (Jul 22, 2013)

Please keep us posted! I have a USB adapter for an actual SNES controller but the driver appears to be responding too quickly, which means emulators can't be properly calibrated and the entire setup is pretty much unusable. It would be great if I could properly play those old SNES games on FreeBSD using a proper SNES controller.


----------



## lispandtrees (Jul 22, 2013)

I'll definitely try and keep you guys updated! I didn't think anyone else would be interested in this. Thanks for the support.


----------



## fonz (Jul 22, 2013)

I get the impression that few people are interested, but I for one certainly am.


----------



## wblock@ (Jul 23, 2013)

I don't have the controller and probably never will, but it's great to see people writing drivers.  That contributes to the code base and makes it easier for the next person who wants to do something similar.


----------



## noeyx (Jul 23, 2013)

+1 to this project. What emulator are you using?


----------



## lispandtrees (Jul 23, 2013)

ZSNES. Snes9x recognizes it but it's not working for some reason.


----------



## fonz (Jul 23, 2013)

I also prefer emulators/zsnes. It's the most convenient one to use and appears to be more tolerant of not-entirely-perfect ROMs than emulators/snes9x.

For what it's worth: both emulators work fine with your average modern USB gamepad meant for PCs. But of course an actual SNES controller just gives that little bit of extra playability. Most games can be played with a standard USB gamepad, but particularly with beat-'em-up games such as Killer Instinct and the Street Fighter and Mortal Kombat series I'm inclined to say that it does make a difference when you have an actual Nintendo controller in your hands.


----------



## noeyx (Jul 25, 2013)

lispandtrees said:
			
		

> ZSNES. Snes9x recognizes it but it's not working for some reason.



Good luck. Keep us posted.


----------



## lispandtrees (Jul 28, 2013)

Turns out there isn't a lag issue. I did a bit of Googling and found out that it's just a problem inherent to the controller itself. People had the same issue on Windows/Linux. Also, I'm running FreeBSD as a virtualized guest so that only exacerbates the latency.

I think I'm done with this. I've accomplished my goal and had a lot of fun in the process. The only issue now is finding out why it's not working with snes9x but


----------



## lispandtrees (Jul 28, 2013)

If you want to read about my development process then go to this site:
http://insomniaandunix.blogspot.com/

It's extremely informal and is pretty much just a review of everything that I went through to get to this point.


----------



## lispandtrees (Jul 29, 2013)

I'm proofreading the blog right now and I'm editing it to be more readable. I initially just copied and pasted my log info without really looking at it. I believe there was even profanity in some of the posts :O. I apologize for that but I'm working on it. Check back in a couple of days for the revision.


----------



## lispandtrees (Jul 29, 2013)

I enlarged the screenshots so you should be able to see them more clearly now.


----------



## lispandtrees (Jul 29, 2013)

This is truly embarrassing but it turns out that the latest release of FreeBSD does in fact support my gamepad out of the box. I originally started working on this driver for the 8.2 release and there wasn't any support _then_. I can't say this was all for nothing though because it was a great learning experience. And let this be a lesson to us all about doing our research. :r


----------

