The Whirlwind computer tried joysticks early on, but testing showed that it was slow and difficult to zero in on a selected item, so they invented the light pen. Some other early computers also had joysticks, often for games. Joysticks became popular with the advent of personal computer games.
The simplest implemention provided only 4 bits of output (for the 4 directions), but better ones included two potentiometers (variable resistors), to give the X-Y coordintes of the current stick location.
The output of the latter type was fed into an analog-to-digital converter; often, a very simple one was used, which used a voltage source and a capacitor, and a counter to measure how long it took the voltage to reach a fixed level.