123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|681|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> Hacking Controllers - With Spinal

Sun, 17 Feb 2013, 14:37
spinal
im really considering turning my usb snes joypad into usb 2xsnes joypads... thats one converter with 2 joypads attached, but I cant think of a ’good’ way to attach them. Snes connectors are HUGE! I need to find 2 cheap male and female connectors with at least 5 pins...


Update #1
The two SNES gamepads have arrived along with the Gamecube controller extension cables.
Here is a photo of one of each. Look at how cheap the SNES controller is!


So the first step is to open up the SNES controller and replace the cable with the gamecube one.

Even the insides are horribly cheap, no matter...


I made a quick not of the wire colours, so that I'd have a nice little chart comparing this side to the gamecube side.


However, as it turns out, the Gamecube extension cables had the same colour wires as the SNES cable. How useful is that!

Anyway, controller #1 is all set and waiting for the AVR to turn up.


I'll get around to wiring up #2 a different day.

On the SNES plug side, the wires are as follows --

I'll need to remember that.

So the AVR arrived so I done a little soldering.





There were a couple of issues, one being that the AVR was slightly too big to fit inside the usb hub without modification. That was the easy bit. Next after soldering it all together, I found that the usb hub had died somewhere along the line. So rather than having a nice working usb hub with two joypad connectors, I ended up with just the joypad adapter.

I tested both of the joypad connections, both are working fine, now I just need to adapt the software to read both data signals at the same time and output them accordingly. Hopefully that part shouldn't take long. Once I'm done, I'll upload the .hex file as well as the source for it, so anyone else who wants to can build one of these

OK, Here is the first working source code for the joypad converter.

joypad sourcecode

It took a few attempts to stop the damn thing from resetting my Mac whenever I used it (random keycodes perhaps?), but it seems to work fine now.
It took a while to google the correct info for checking if a SNES controller is connected or not, then, as one of my controllers (I reused my old one) is decidedly cheaper than the other, it kept sending random data when connecting and disconnecting, so the ports are now checked twice, the first time without collecting data and only checking the 17th bit (17th bit high = no controller), then again collecting data only if the first check discovered a connected controller.

It's based on the KeyboardMouse example in the LUFA library, which sends two HID descriptors from one device, This was needed for iOS use, as a media controller is required to use the 'eject key' to show/hide the onscreen keyboard. The key layout uses iCade protocol, where two keys are used for each button, one to signal that a button is pressed, the other to signal that a button is released.
Controller #1 uses normal iCade keys with the layout matching that of the Gametel controller. Controller #2 uses the same keys but with capslock/shift enabled. Resulting in player 1 being lower case and player two being upper case.

My previous SNES joypad hack had all sorts of crazy menus and stuff to switch modes (keyboard, iCade, Xperia, Media buttons), but I really can't be bothered with that yet. It would be nice to use this on my computer though.....

Couple more pics.





I added a push button to the device to enable switching modes, currently ICade and keyboard mode are working. It doesn't save the mode, I figured as there's only 2 it isn't really an issue.

I recently rehoused the thing inside an old ADSL adapter to give it a Nintendoish look --


-=-=-
Check out my excellent homepage!
Sun, 17 Feb 2013, 14:37
steve_ancell
How about 9-pin serial connectors, Maplin do them cheap if my memory serves me right.
Sun, 17 Feb 2013, 15:09
9572AD
Stacked would be far smaller than side by side
Sun, 17 Feb 2013, 15:27
Jayenkai
Yeah, some nice classic 9-pin connectors would be smaller, and are nice and retro, too! Maybe even go a step further, and get it to work with actual joysticks, too??

-=-=-
''Load, Next List!''
Sun, 17 Feb 2013, 16:10
steve_ancell
There ya go. (Linkage)



Grab a couple of serial cables and hack them into the controllers and grab a couple of serial port connectors, probably come to less than a tenner.
Mon, 18 Feb 2013, 03:17
waroffice
I replaced my megadrive ones for some shiny copper looking ones from maplin, did the job especially with the nice red paint job I gave it
Mon, 18 Feb 2013, 04:13
spinal
Step one complete, I have ordered a couple of cheap snes controllers from ebay, they have the purple buttons, I'd prefer the euro/japan coloured buttons, but purple will do just fine, especially for the price. After googling around, finding almost nothing and eventually opening a controller to have a look, it seems that the gamecube used 5 of the 6 pins in the controller connector, so , hopefully the set of 2 extension cables will have at least 5 of the 6 pins connected.

The next stage, which can wait a while, it to rewrite the code for my current joypad (using an atmega32u2 chip) to check for and use a second controller. This shouldn't be too hard, I assume it would be a case of copying the current reading routine and changing which pins it's looking at.

Anyway, should I keep you guys up to date with the build, or don't you care that much?

-=-=-
Check out my excellent homepage!
Mon, 18 Feb 2013, 04:15
steve_ancell
waroffice I replaced my megadrive ones for some shiny copper looking ones

Oooo shiny!, I like shiny. My RPi has shiny blue heatsinks.
Mon, 18 Feb 2013, 04:25
Jayenkai
Whilst naming this topic, I thought "Hmmm.. That'd make a nice title for a YouTube series."

Yeah, I'm interested! And the more indepth and techy it is, the better!

-=-=-
''Load, Next List!''
Mon, 18 Feb 2013, 10:05
spinal
step 2 - testing a different set of pins to read a joypad.... fail.

I seem to have switched the device into some sort of useless mode so no it doesn't detect and I can't flash it

While I keep googling the solution to multiple controllers, it seems that I will only require 1 new connection as the other 4 pins can be shared (+5v, gnd, latch, clock) I just need a second data pin. should be nice and easy once I get a new avr to play with.

OK, bit the bullet and ordered a replacement avr. I chose a 'MT-DB-U2' from ebay. It uses the same chip as my current broken doodad, so I shouldn't need to change anything at all in my software to use it. hopefully though, it will fit inside the usb hub that I intend to use...


-=-=-
Check out my excellent homepage!
Mon, 18 Feb 2013, 15:05
rockford
I read that USB has polling limits to keyboard presses of about 6 keys (plus modifiers?). Will multiple joypads suffer the same problem while running through one USB port?
Tue, 19 Feb 2013, 00:18
spinal
probably, but I think it can be overcome, at least on the keyboard side. Not sure how an OS would handle it though. Saying that though, I'm using the iCade method, so a lot less keypresses are sent, 1 to start the button hold, 1 to stop. So even if I alternate the frames that I send them it should be fast enough for use.

-=-=-
Check out my excellent homepage!
Tue, 19 Feb 2013, 04:25
CodersRule
I'm pretty sure you can overcome the polling limits on the keyboard side: it's all about how the OS wants to use the data. The Das Keyboard has full polling when you're connected with PS/2, meaning you can press all the keys at once and they'll be recognized. With the USB adapter plugged in, the limit is 6. What's interesting is that the PS/2 adapter is inserted over top of the USB plug, so PS/2 is getting all its data from what's coming through the USB plug.
Wed, 20 Feb 2013, 03:10
spinal
OK, the joypads would have been delivered yesterday morning had I been home, so today I need to go for a nice walk to the post office... grrrrrr....

-=-=-
Check out my excellent homepage!
Wed, 20 Feb 2013, 06:00
rockford
Exercise is good for you
Wed, 20 Feb 2013, 09:08
spinal
Updated first post... Now just waiting for the AVR to arrive

-=-=-
Check out my excellent homepage!
Wed, 27 Feb 2013, 07:12
spinal
AVR arrived today, first post updated
Wed, 27 Feb 2013, 08:24
rockford
Your soldering is bang on by the look of the photos
Wed, 27 Feb 2013, 14:19
spinal
On the software side, I might as well start over completely. The old code expects the joypad to be permanently connected, as I've made these ones detachable, all hell breaks loose if either of them are not connected.

-=-=-
Check out my excellent homepage!
Fri, 01 Mar 2013, 16:03
spinal
First post updated, Software uploaded!

If anyone tries this, let me know how it goes!

-=-=-
Check out my excellent homepage!
Sat, 30 Mar 2013, 10:28
spinal
New case!!
Wed, 22 Jan 2014, 12:43
spinal
Joystick.zip

Edited the above code, now detects an HID joystick with 8 buttons. Rewired slightly, only single pad supported.

Brown = GND
White = +5v
Orange = D0 --- Clock
Yellow = D1 --- Latch
Red = D2 --- Data




-=-=-
Check out my excellent homepage!