9 | | == General flow of mouse input == #General |
| 9 | == How mouse input reaches guest systems == #General |
| 10 | |
| 11 | In order to let the user control the guest system with the host input devices, !VirtualBox emulates input devices inside the virtual machine. The simplest case is when the host pointer is captured and !VirtualBox is only emulating a standard (PS/2 or USB) mouse. In this case, when the user moves the host pointer to the left, !VirtualBox simulates left movement on the emulated mouse, and when the user clicks the right button a right button click is simulated on the guest mouse. |
| 12 | |
| 13 | When mouse integration is enabled, this becomes slightly more complicated. !VirtualBox emulates a graphics tablet (similar to a touch screen), which can send exact positions instead of just "left", "right", "up", "down". Unfortunately these positions are not in pixels on the screen, but in percentages - e.g. 56 percent along the X axis from the left to the right edge and 73 percent along the Y axis from the top to the bottom edge. For this to work correctly, the guest and the host have to agree about which positions on the tablet correspond to which positions on the guest screens - e.g. virtual screen one might go from 0 to 50 percent along the X axis and from 0 to 100 on the Y axis, while virtual screen two might go from 50 to 100 on X and also from 0 to 100 on Y. This corresponds to screen two laid out to the right of screen one, with the right edge of screen one exactly matching the left edge of screen two. If host and guest agree about this layout then mouse integration can work. Otherwise the position of clicks in the guest will not correctly match the pointer location. |
| 14 | |
| 15 | This is further complicate by the fact that for historical reasons (i.e. it seemed like a good idea at the time), the Guest Additions input device sends position information but not button information. So it needs to be used in conjunction with another device which can send the button information (this can actually happen on physical laptops too, which multiple touch pad and touch point devices and various sets of buttons), and the two can get very slightly out of synchronisation, causing strange effects. This will be fixed as soon as there is nothing else more important needing fixing, which is not likely to happen for a long time. This does not happen when using the emulated USB graphics tablet device, which also has buttons, but that device does not always map well to multiple guest screens. |
| 16 | |
| 17 | == General flow of mouse input == #Flow |