That is a big question and there are many parts. ‘Douglas Engelbart invented the computer mouse to make computers easier to use’
The wires pass electrical signals, or wireless mice encode the information on radio waves.
The mouse either has a ball or a light and a detector, to monitor the movements.
Computers are logical, so that movement needs to be made into a number, that moves up/down (y) or left/right (x); diagonal movements are a combination of this. You can change the sensitivity which multiplies the number that the mouse has received onto the screen in number of pixels to move.
Great question. So have I. I would also like to know how a touch screen works. I have no answers yet. If you find out let me know.
This shows that one engineer cannot know everything about every subject and why you will often need to get engineers with different expertise that you to come on your team to solve a problem.