Step 1: What You'll Need
Not pictured are some other requirements like wire strippers, soldering iron, extra wiring, a Dremel, a drill, some nuts and bolts (#10 size works ok with the joystick I'm using), etc. You'll figure it out.
NOTE: if you do use a salvaged controller cable, keep in mind that it matters where you get it from. If plan on adding a paddle (not covered here), a cable from a normal joystick will not work. Likewise, pulling one from a paddle will probably not work if you plan to make a normal joystick, though I don't have a paddle to check. This is all because the paddles use pins 5, 7 and 9 which aren't used on a normal joystick. If you're interested in making a combo controller, pin 5 is B pot input, 7 is +5V and 9 is A pot input.
Step 2: Disassemble the Atari Joystick
Unscrew the sucker and open it up. The one I opened up had six wires in it: Black, Green, Red, White, Yellow and Orange. Using a multimeter, I determined which color matched up with what input. There's a couple of ways you could approach this, but I found it simplest to just put one probe on the wires' solder points and poke the other around until I found what input it was connected to. If you happen to be tearing apart the exact same controller as I did, it lines up like so:
Black -> GND
Green -> Button
Red -> Left
White -> Right
Yellow -> Down
Orange -> Up
However you determine this, write it down.
Cut the wires, disconnecting them from the controller board.
Step 3: Wire Up the Button
One wire will go to pin 6. Ground is pin 8.
Step 4: Drill the Enclosure
I also cut out a chunk near the lid for the db-9 cable. I didn't do a good job here. I'm sure others can do better.
Next, fit the joystick in there and mark some holes for the bolts to hold it in place. Or be smart and whip up a printable template. I was not so smart, and my bolts did not line up in an aesthetically pleasing manner.
Step 5: Finish the Connections
Again, I used the multimeter to figure out what wires correspond with which direction on the joystick. The black wire was GND. Moving right from there, it was Left, Right, Down, Up. But don't take my word for it. All these are are simple buttons closing a connection, so it's simple to test with a multimeter.
Anyway, solder them to the correct wires from the plug. I used rubber shrink tube again to insulate and protect the solders. Use electrical tape if you don't have that.
The pins are: