How to interface a C64/Atari joystick port with the ESP8266 (level shifting from 5 to 3.3V)?
On the C64, all pins (up, down, left, right, button) are pulled high internally by resistors and will show 5V.

When a classic joystick is moved, it will mechanically connect the corresponding pin to GND, forcing it to 0V.

To emulate this from a microcontroller you can use either:


An NPN transistor with emitter to ground, collector to joystick pin, base to the microcontroller output via a resistor
A N-channel logic-level MOSFET with source to ground, drain to joystick pin, gate to microcontroller output


Replicate this circuit for each of the 5 signals and you're good to go.