eli5: How does a computer mouse work besides the basics?

170 views

Not how does it record the signal and send to the computer,

but how does moving my mouse over the back sign and clicking cause the actual webpage to change?

what’s actually happening inside the computer

In: 0

5 Answers

Anonymous 0 Comments

The web browser application has a “stack” of pages you’ve visited for each tab. When you click on the back button it sends out a request to the website you visited previously to load the data required to display that page, then it renders it for you to see (along with using preloaded data already on your computer from visiting the site before)

Going down a layer, the operating system receives the input from the mouse, and tells the web browser application that a click was received on the back button.

Anonymous 0 Comments

So that’s very different than the mouse. That’s the programming in the computer doing that, the mouse really isn’t controlling anything there. It just sends signals telling the computer you *did* click.

As for what’s actually happening inside the computer, it’s a coordinated series of electrical signals that combine and create new signals, or block signals, all happening according to how the computer was designed. This series of signals eventually results in the pixels on the screen receiving different signals, which changes what you see.

Your question is really more “how does a computer work” than “how does a mouse work”, and that’s a very complicated question. You might get someone more knowledgeable than me to answer if you post you question again with a different title.

Anonymous 0 Comments

At a high level, the mouse uses what are called events to interface with the application, or OS. Specifically, when you click on an area within the application, you are creating a click event. That click event executes a set of instructions. In the case of clicking the back button, the instructions would more than likely be to get the previous page URL and reload it within the browser.

Anonymous 0 Comments

Hardware like a mouse are designed to send electrical signals. That goes for your keyboard, monitor and everything inside the computer – it’s all electrical signals. For devices that are external to the main board, like a mouse, you have a connection to an “outside” connection like USB – which can then be a wire to the mouse or wireless, regardless this device that plugs into the port will send/receive electrical signals following a specific protocol. Technically, the hardware signals are accumulated into registers/buffers that to the world of software are known as ports. Other electrical features like interrupts exist, but let’s keep it simple.

At that point, software is needed. Software can read the state of a large number of ports. Every device, every potential device, has a port. When the computer boots, it assign ports to things it sees plugged in, USB has it’s own ports. The first layer of programming is called the Operating System. For some that’s Linux, others that’s Window, IOS etc. – they will implement the next slightly different, but they do share the main lines. The OS will make a translation from ports to something a programmer understands. Ie. the OS will convert the USB device the mouse is on into a USB address, which a programmer can use to send/receive data to. Once this is done, the mouse’s protocol is implemented in an optional part of the OS, which Windows calls drivers. A driver is just a particular technical piece of program that translates the protocol into a standard set of actions defined by the OS. In most cases, to help programmers a GUI implements a “bus” – like a road way – where messages from devices like mice are sent and received. Every movement, every keypress, every event like opening an application, moving a window are one or more messages on this bus.

When the OS creates the GUI that makes windows (Window Manager) it uses this bus to read/write events to. The programmers of the GUI makes it easy for the programmers that make the software you run, easy. They make it so a “normal” programmer doesn’t have to known the whole OS, but instead can just concentrate on looking for the events that matter for their application. For most applications created, they simply need to create code in a function that may say myButton.onPush() – and the OS software calls this function when it determines the click of the mouse (determined by reading the port values) happened exactly on the button, and the OS often implements some graphical changes so it looks like the button is depressed into the screen. Then the programmers code is called, it may write “Hello World” to the screen, and return or something else.

The actual translation from the port values to x,y of the screen, which window is being clicked on, which line of text etc. is tricky and full of geometry/math. The OS records the cursor location right now, and uses the mouse movements relative to this. The mouse tracks (electrically) movements forward/backward/left/right and between. Some advance mice can record more directions, some mice have a ton of buttons, some have just one etc. It’s up to the OS to convert the movements into relative x,y values on the mouse and change those values. Changing them makes the OS change the display with a new mouse pointer location. When the port values indicate a mouse button push, a signal is sent on the bus that a button was pushed, and the OS determines what part of the OS needs to know about the push.

A computer in other words is a layered system. With hardware on top of hardware, software on top of software. The WAST majority of programmers do not see the hardware at all – they simply make functions that are automatically called when the OS/browser detects movement/pushes.

A browser is just an application. There’s no difference from a mouse perspective between a simple “hello world” with a few buttons and a browser, other than a browser is dynamically creating a page where most traditional programs have a more static look. Which means the browser programmers use the exact same “tricks” to react to a button push. Programmers can also react to a mouse moving over something, moving while holding a key down etc. and take different action depending on the user action.

ELI5 – the computer is complex but not magical. Software translates the hardware electrical signals into software ‘signals’ which programmers use to react to hardware actions.

Anonymous 0 Comments

Inside the computer, the mouse can be thought of as two numbers and a button. Where is the mouse and is it being clicked?

When you click, the computer tells a program where the mouse was when it clicked.

If the mouse was on something like a button, the program will follow its instructions on what to do when the button is clicked.

So, in your example, when you click your mouse on the back button, the computer tells the back button that it was clicked. The button then does what it was programmed to do, in this case, going back to the previous page.