[PATCH v9 7/8] winex11.drv: Implement native mouse-button raw-input using RawButton*.

Rémi Bernon rbernon at codeweavers.com
Mon Jul 29 09:21:55 CDT 2019


On 7/27/19 1:19 AM, Derek Lesho wrote:
> Signed-off-by: Derek Lesho <dereklesho52 at Gmail.com>
> ---
>   dlls/winex11.drv/mouse.c  | 97 +++++++++++++++++++++++++++++++++++++--
>   dlls/winex11.drv/x11drv.h |  1 +
>   2 files changed, 93 insertions(+), 5 deletions(-)
> 
> diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
> index 7423f946b9..9259907eb5 100644
> --- a/dlls/winex11.drv/mouse.c
> +++ b/dlls/winex11.drv/mouse.c
> @@ -257,6 +257,7 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
>   
>       thread_data->x_rel_valuator.number = -1;
>       thread_data->y_rel_valuator.number = -1;
> +    thread_data->wheel_valuator.number = -1;
>   
>       for (i = 0; i < n_valuators; i++)
>       {
> @@ -274,6 +275,10 @@ static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuator
>           {
>               valuator_data = &thread_data->y_rel_valuator;
>           }
> +        else if (class->number == 3) /* scroll wheel */
> +        {
> +            valuator_data = &thread_data->wheel_valuator;
> +        }
>   

You can do the same check as the other ifs here, just add a 
Rel_Vert_Scroll enumeration in x11drv.h (and the corresponding string 
with spaces, in x11drv_main.c).

>   
> -    TRACE("raw event %f,%f\n",  raw_dx, raw_dy);
> +    if (dwheel)
> +    {
> +        raw_input.data.mouse.u.usButtonFlags = RI_MOUSE_WHEEL;
> +        raw_input.data.mouse.u.usButtonData  = dwheel;
> +    }
> +
> +    TRACE("raw event %f,%f + %f\n",  raw_dx, raw_dy, dwheel);
>       __wine_send_raw_input( &raw_input );
>   
>       return TRUE;
>   }

As said in my other mail, I believe there may be a 8x scaling factor for 
the mouse wheel between XInput2 and Windows.

> +/***********************************************************************
> + *           X11DRV_RawButton
> + */
> +static BOOL X11DRV_RawButton( XGenericEventCookie *xev )
> +{
> +    RAWINPUT ri;
> +
> +    static const unsigned short raw_button_press_flags[] = {
> +        0,                              /* 0 = unused */
> +        RI_MOUSE_LEFT_BUTTON_DOWN,      /* 1 */
> +        RI_MOUSE_MIDDLE_BUTTON_DOWN,    /* 2 */
> +        RI_MOUSE_RIGHT_BUTTON_DOWN,     /* 3 */
> +        0,                              /* 4 = unknown */
> +        0,                              /* 5 = unknown */
> +        0,                              /* 6 = unknown */
> +        0,                              /* 7 = unknown */
> +        RI_MOUSE_BUTTON_4_DOWN,         /* 8 */
> +        RI_MOUSE_BUTTON_5_DOWN          /* 9 */
> +    };
> +
> +    static const unsigned short raw_button_release_flags[] = {
> +        0,                            /* 0 = unused */
> +        RI_MOUSE_LEFT_BUTTON_UP,      /* 1 */
> +        RI_MOUSE_MIDDLE_BUTTON_UP,    /* 2 */
> +        RI_MOUSE_RIGHT_BUTTON_UP,     /* 3 */
> +        0,                            /* 4 = unknown */
> +        0,                            /* 5 = unknown */
> +        0,                            /* 6 = unknown */
> +        0,                            /* 7 = unknown */
> +        RI_MOUSE_BUTTON_4_UP,         /* 8 */
> +        RI_MOUSE_BUTTON_5_UP          /* 9 */
> +    };
> +
> +    int detail = ((XIRawEvent*)xev->data)->detail;
> +    if (detail > 9) return TRUE;
> +
> +    ri.header.dwType = RIM_TYPEMOUSE;
> +    ri.data.mouse.u.usButtonFlags = xev->evtype == XI_RawButtonPress ? raw_button_press_flags[detail] : raw_button_release_flags[detail] ;
> +    ri.data.mouse.u.usButtonData = 0;
> +    ri.data.mouse.lLastX = 0;
> +    ri.data.mouse.lLastY = 0;
> +    ri.data.mouse.ulExtraInformation = 0;
> +
> +    __wine_send_raw_input( &ri );
> +
> +    return TRUE;
> +}
> +
It may worth it to skip sending empty rawinput here, it looks like that 
XInput2 sends RawButton events in addition to the RawMotion events for 
the mouse wheel.
-- 
Rémi Bernon <rbernon at codeweavers.com>



More information about the wine-devel mailing list