The PointerMotionSensorScaleHandler
scales pointer motion, to improve the usability of mice and touchpads.
Mice and touchpads must simultaneously support two different use cases, working with motion that is constrained to a small surface area.
If the system maps a given amount of motion (e.g. 1mm) of/on the sensor to the same amount of motion of the pointer on the screen, the user will be able to make fine motions suitable for uses like
However, such a mapping makes it difficult to navigate across the whole width or height of the display. The user might have to, e.g., swipe three or four times across the touchpad to move the cursor from the left edge of the display to the right edge.
This effect grows with the resolution of the display. So, for example, 4K and higher displays are more difficult to use. (See, however, PointerMotionDisplayScaleHandler
for a complementary stage that's useful when the additional physical pixels are used for smooth rendering, rather than fitting more context onto the display.)
Conversely, choosing a linear mapping that optimizes for large motions sacrifices the ease of making small motions.
To resolve the dilemma, this handler maps sensor motion to pointer motion using not just the distance of the motion, but also the speed of the motion.
The graph below illustrates the scaling curve, where x
is the count read from the sensor, and y
is the scaled count computed by this handler.
The graph assumes a sensor with 12 counts per millimeter, and a 125 HZ polling rate. Under such a configuration:
The X and Y axes, while both linear, are drawn at different scales. This highlights the change in the shape of the curve, but obscures its absolute slope.
The graph below plots the first derivative of the function in the count scaling section.
The X and Y axes, while both linear, are drawn at different scales. This highlights the change in the shape of the curve, but obscures its absolute slope.
The graph below plots the second derivate of the function in the count scaling section.
The X and Y axes, while both linear, are drawn at different scales. This highlights the change in the shape of the curve, but obscures its absolute slope.
UnhandledInputEvent
s. That's because most handlers send an event to a FIDL peer before marking the event as handled. Scaling an event that has already been sent to FIDL peers might lead to inconsistencies, if another handler downstream from this handler also sends pointer events to FIDL peers.