I recently took apart a contoller to sort the analogue stick out which was sticking and it got me wondering how it actually works. I can see the movement of the stick causes a plastic ring on a spring to move up and down, but how does the controller know what that means? How does it recognise left from right etc when all thats happening is this ring movement?

Anyone care to humour my curiosity?