Assigning discrete actions to joystick buttons in Settings > Controls.
Assigning joystick axis to mouse axis using joystick_x and joystick_y configuration variables in the console.
Limitations
Supported only a single joystick (the first one that was detected by SDL with index 0). Multi-joystick support could be implemented as a separate PR, maybe even by somebody else (not feeling it today).