I’m trying to determine what would be the maximum and minimum values of:
By observation, I’ve determined that my mouse’s ScrollWheel range of values is exactly (-0.5, 0, 0.5).
On my machine I can write code to capture these values when I move the mouse rapidly, but how can I determine that concretely on a user’s machine?
Can I read these values from the system?
There are no maximum values as those are all delta inputs. If you somehow manage to move your mouse 1 light year in a millisecond (assumed your mouse could still detect this movement) the value would be off the charts. The same is theoritically possible for the scroll wheel as well but since the “notches” of the scroll wheel are usually quite far apart and your update rate is relatively high you usually only ever see one notch movement at a time. However you can’t really be sure what value you get for one notch as it depends on the hardware and sometimes even on the mouse settings in the OS.
In general delta values tell you how much the mouse / screll wheel has been moved since the last frame. Of course there are some hard limitations on how large the values can get. AFAIK most APIs and hardware send the relative delta as 16 bit numbers. Though specific hardware might use higher precision. Just as an example windows WM_MOUSEWHEEL message actually encodes the wheel delta in a 16 bit word as a multiple of 120. This allows for a delta of about “±273 notches” per update. Nobody will be able to rotate the wheel that fast within a few milli seconds and no (common) hardware would be actually able to detect this ^^. Thouse with a mouse like this you might be able to get more than one notch per update and therefore higher delta values.
A lot software just ignores how far the wheel actually moved but they just determine if the delta was positive or negative. Personally I don’t like this approach. Since the amount returned by Mouse X or the scrollwheel can vary heavily from device to device it’s common to provide a sensitivity setting for the user to adjust.
Why would you ever want to know the maximum of a delta value anyways? If you just want to make sure that a single delta is not above a certain value, you might just clamp the value between certain limits you want for example to prevent cheating by a user who increases his mouse sensitivity in the OS which would allow him to get larger delta values with less actual movement.