[Xcb] Xinput: units of the coordinates in motion-events?

Uli Schlachter psychon at znc.in
Fri Oct 26 16:44:22 UTC 2018


On 26.10.2018 11:54, Christophe Lohr wrote:
> Hi,

Hi again,

>   May I ask another question on how to manage the scroll wheel with Xinput?
> I have noticed that this triggers  XCB_INPUT_MOTION events also (and not
> only button events). This is the "Z" axis.
> 
> I should get information via the "Valuators", isn't it?
> (https://www.x.org/releases/X11R7.7/doc/inputproto/XI2proto.txt)
> 
> How to get Valuators that are reported on motion events?

I do not really know much about xinput. Via Google, I found "xinput
--test-xi2 --root". This prints out events that are received. So, now I
know at least what to look for. :-)

For me, the mouse wheel generates three events: ButtonPress,
ButtonRelease (both with flags: emulated) and a Motion event that looks
like this:

EVENT type 6 (Motion)
    device: 2 (10)
    detail: 0
    flags:
    root: 1057.09/539.66
    event: 1057.09/539.66
    buttons:
    modifiers: locked 0x10 latched 0 base 0 effective: 0x10
    group: locked 0 latched 0 base 0 effective: 0
    valuators:
        3: 66570.00
    windows: root 0x14d event 0x14d child 0xa002f8

Running "xinput --test-xi2 --root" under xtrace produces the following
output for this:

000:>:0012: Event Generic(35) XInputExtension(131) Motion(6)
deviceid=0x02 time=0x0728377f detail=0x00000000 root=0x0000014d
event=0x0000014d child=0x00a002f8 root_x=1057.087524 root_y=539.655518
event_x=1057.087524 event_y=539.655518 sourceid=0x000a flags=0x00000000
mods={base_mods=0x00000000 latched_mods=0x00000000
locked_mods=0x00000010 effective_mods=0x00000010};
group={base_group=0x00 latched_group=0x00 locked_group=0x00
effective_group=0x00};
buttons=0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000;
valuators=0x00000008,0x00000000; axisvalues=66570.00000000000;

Uhm, yeah...

Okay, so looking at the code that xcb generates for this... First:

  typedef xcb_input_button_press_event_t xcb_input_motion_event_t;

And then there are lots of acessor functions. These seem to be the ones
that could be interesting for you:

uint32_t *
xcb_input_button_press_button_mask (const xcb_input_button_press_event_t
*R);

int
xcb_input_button_press_button_mask_length (const
xcb_input_button_press_event_t *R);

uint32_t *
xcb_input_button_press_valuator_mask (const
xcb_input_button_press_event_t *R);

int
xcb_input_button_press_valuator_mask_length (const
xcb_input_button_press_event_t *R);

xcb_input_fp3232_t *
xcb_input_button_press_axisvalues (const xcb_input_button_press_event_t *R);

int
xcb_input_button_press_axisvalues_length (const
xcb_input_button_press_event_t *R);

So, I guess you have to cast your event to
xcb_input_button_press_event_t and then use these accessors to get all
the data you want out of the event.
Does this somehow help you? Could you test if my guess here is right?

Good luck,
Uli
-- 
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?" -- A. P. J.


More information about the Xcb mailing list