mouse 4th byte, H and V wheel

Programming, for all ages and all languages.
Post Reply
User avatar
edfed
Member
Member
Posts: 42
Joined: Wed Apr 09, 2008 5:44 pm
Location: Mars

mouse 4th byte, H and V wheel

Post by edfed »

when i read the wiki, and a lot of other sources, it appears that it is confusing about the H and V scroll wheel movment in the Z field of the 4th byte.

Code: Select all

b field
0 Z0
1 Z1
2 Z2
3 Z3
4 4th button
5 5th button
6 0
7 0
and the explanation is:
if Z = 0, then no movment
if Z = 1 then increment on V
if Z = F then decrement on V
if Z = 2 then increment on H
if Z = E then decrement on H

but, it is confusing, because other sources says:
if Z is incremented by 1, it means one click up on V axis
if Z is incremented by 2, it means one click up on H axis...

what about the values 3, 4, 5, 6, 7, 8, 9, A, B, C and D?

can the simple explanation be:
odd values are for V axis, and even values are for H axis??? because it looks more logical.
then, if the bit Z0 is set, it is a movment of the vertical wheel, and if Z0 is clear, it is a movment on H axis...
it seems really more logical like this, but i know that sometimes, computer design is everything but logical...

thanks.
welcome in my dream.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: mouse 4th byte, H and V wheel

Post by bewing »

Yes, it is confusing, and I am going to have to rewrite that article soon.

The point is that the mouse wheels only report movement on one axis at a time, and they only report one unit of movement, maximum, no matter how much the wheel has been rotated.

Yes, within that limitation, the "one bit" represents vertical movement, and the "two bit" represents horizontal movement -- but if you look at the values for moving "down" (0xE and 0xF), you have to think of it as a signed value. The values 3 through 0xC are impossible, which is why they are not listed.
User avatar
edfed
Member
Member
Posts: 42
Joined: Wed Apr 09, 2008 5:44 pm
Location: Mars

Re: mouse 4th byte, H and V wheel

Post by edfed »

perfect!

thank you.

maybe a truth table would be good for this point.
then

truth table for the dual scroll wheel Z field (bits 0 to 3 of 4th byte)
0 no scroll
1 one positive step on vertical scroll
2 one positive step on horizontal scroll
3 to D invalid
E one négative step on horinzontal scroll
F one négative step on vertical scroll

:)
welcome in my dream.
Post Reply