In the standard joystick design, the handle moves a narrow rod that sits in two rotatable, slotted shafts. Tilting the stick forward and backward pivots the Y-axis shaft from side to side. Tilting it left to right pivots the X-axis shaft. When you move the stick diagonally, it pivots both shafts. Several springs center the stick when you let go of it.
To determine the location of the stick, the joystick control system simply monitors the position of each shaft. The conventional analog joystick design does this with two potentiometers, or variable resistors. The diagram below shows a typical arrangement.
More Options: