Commit 8a13a759 authored by Rémi Bernon's avatar Rémi Bernon Committed by Vitaly Lipatov

winex11.drv: Simplify XInput2 valuator lookup.

Valuator names aren't well specified, and although they usually are Rel X/Y or Abs X/Y, there are cases where the X/Y names are something else. Just assume that the first two valuators are the X/Y axes, as it seems to be generally the case.
parent e664ba0c
...@@ -328,26 +328,25 @@ void X11DRV_InitMouse( Display *display ) ...@@ -328,26 +328,25 @@ void X11DRV_InitMouse( Display *display )
/*********************************************************************** /***********************************************************************
* update_relative_valuators * update_relative_valuators
*/ */
static void update_relative_valuators(XIAnyClassInfo **valuators, int n_valuators) static void update_relative_valuators( XIAnyClassInfo **classes, int num_classes )
{ {
struct x11drv_thread_data *thread_data = x11drv_thread_data(); struct x11drv_thread_data *thread_data = x11drv_thread_data();
int i; XIValuatorClassInfo *valuator;
thread_data->x_valuator.number = -1; thread_data->x_valuator.number = -1;
thread_data->y_valuator.number = -1; thread_data->y_valuator.number = -1;
for (i = 0; i < n_valuators; i++) while (num_classes--)
{ {
XIValuatorClassInfo *class = (XIValuatorClassInfo *)valuators[i]; valuator = (XIValuatorClassInfo *)classes[num_classes];
if (valuators[i]->type != XIValuatorClass) continue; if (classes[num_classes]->type != XIValuatorClass) continue;
if (class->label == x11drv_atom( Rel_X ) || if (valuator->number == 0 && valuator->mode == XIModeRelative) thread_data->x_valuator = *valuator;
(!class->label && class->number == 0 && class->mode == XIModeRelative)) if (valuator->number == 1 && valuator->mode == XIModeRelative) thread_data->y_valuator = *valuator;
thread_data->x_valuator = *class;
else if (class->label == x11drv_atom( Rel_Y ) ||
(!class->label && class->number == 1 && class->mode == XIModeRelative))
thread_data->y_valuator = *class;
} }
if (thread_data->x_valuator.number < 0 || thread_data->y_valuator.number < 0)
WARN( "X/Y axis valuators not found, ignoring RawMotion events\n" );
thread_data->x_valuator.value = 0; thread_data->x_valuator.value = 0;
thread_data->y_valuator.value = 0; thread_data->y_valuator.value = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment