evdev: keep the absinfo struct around instead of min/max

We'll need that later for conversion to mm.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2014-06-19 11:11:36 +10:00
parent 92a67a3a94
commit df212db2a3
4 changed files with 31 additions and 22 deletions

View file

@ -565,6 +565,7 @@ tp_init_buttons(struct tp_dispatch *tp,
struct tp_touch *t;
int width, height;
double diagonal;
const struct input_absinfo *absinfo_x, *absinfo_y;
tp->buttons.is_clickpad = libevdev_has_property(device->evdev,
INPUT_PROP_BUTTONPAD);
@ -580,8 +581,11 @@ tp_init_buttons(struct tp_dispatch *tp,
log_bug_kernel("non clickpad without right button?\n");
}
width = abs(device->abs.max_x - device->abs.min_x);
height = abs(device->abs.max_y - device->abs.min_y);
absinfo_x = device->abs.absinfo_x;
absinfo_y = device->abs.absinfo_y;
width = abs(absinfo_x->maximum - absinfo_x->minimum);
height = abs(absinfo_y->maximum - absinfo_y->minimum);
diagonal = sqrt(width*width + height*height);
tp->buttons.motion_dist = diagonal * DEFAULT_BUTTON_MOTION_THRESHOLD;
@ -590,13 +594,15 @@ tp_init_buttons(struct tp_dispatch *tp,
tp->buttons.use_clickfinger = true;
if (tp->buttons.is_clickpad && !tp->buttons.use_clickfinger) {
tp->buttons.bottom_area.top_edge = height * .8 + device->abs.min_y;
tp->buttons.bottom_area.rightbutton_left_edge = width/2 + device->abs.min_x;
int xoffset = absinfo_x->minimum,
yoffset = absinfo_y->minimum;
tp->buttons.bottom_area.top_edge = height * .8 + yoffset;
tp->buttons.bottom_area.rightbutton_left_edge = width/2 + xoffset;
if (tp->buttons.has_topbuttons) {
tp->buttons.top_area.bottom_edge = height * .08 + device->abs.min_y;
tp->buttons.top_area.rightbutton_left_edge = width * .58 + device->abs.min_x;
tp->buttons.top_area.leftbutton_right_edge = width * .42 + device->abs.min_x;
tp->buttons.top_area.bottom_edge = height * .08 + yoffset;
tp->buttons.top_area.rightbutton_left_edge = width * .58 + xoffset;
tp->buttons.top_area.leftbutton_right_edge = width * .42 + xoffset;
} else {
tp->buttons.top_area.bottom_edge = INT_MIN;
}

View file

@ -750,8 +750,10 @@ tp_init(struct tp_dispatch *tp,
if (tp_init_slots(tp, device) != 0)
return -1;
width = abs(device->abs.max_x - device->abs.min_x);
height = abs(device->abs.max_y - device->abs.min_y);
width = abs(device->abs.absinfo_x->maximum -
device->abs.absinfo_x->minimum);
height = abs(device->abs.absinfo_y->maximum -
device->abs.absinfo_y->minimum);
diagonal = sqrt(width*width + height*height);
tp->hysteresis.margin_x =

View file

@ -89,13 +89,19 @@ transform_absolute(struct evdev_device *device, int32_t *x, int32_t *y)
}
}
static inline double
scale_axis(const struct input_absinfo *absinfo, double val, double to_range)
{
return (val - absinfo->minimum) * to_range /
(absinfo->maximum - absinfo->minimum + 1);
}
double
evdev_device_transform_x(struct evdev_device *device,
double x,
uint32_t width)
{
return (x - device->abs.min_x) * width /
(device->abs.max_x - device->abs.min_x + 1);
return scale_axis(device->abs.absinfo_x, x, width);
}
double
@ -103,8 +109,7 @@ evdev_device_transform_y(struct evdev_device *device,
double y,
uint32_t height)
{
return (y - device->abs.min_y) * height /
(device->abs.max_y - device->abs.min_y + 1);
return scale_axis(device->abs.absinfo_y, y, height);
}
static void
@ -606,13 +611,11 @@ evdev_configure_device(struct evdev_device *device)
if (libevdev_has_event_type(evdev, EV_ABS)) {
if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
device->abs.min_x = absinfo->minimum;
device->abs.max_x = absinfo->maximum;
device->abs.absinfo_x = absinfo;
has_abs = 1;
}
if ((absinfo = libevdev_get_abs_info(evdev, ABS_Y))) {
device->abs.min_y = absinfo->minimum;
device->abs.max_y = absinfo->maximum;
device->abs.absinfo_y = absinfo;
has_abs = 1;
}
/* We only handle the slotted Protocol B in weston.
@ -621,11 +624,9 @@ evdev_configure_device(struct evdev_device *device)
if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y)) {
absinfo = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X);
device->abs.min_x = absinfo->minimum;
device->abs.max_x = absinfo->maximum;
device->abs.absinfo_x = absinfo;
absinfo = libevdev_get_abs_info(evdev, ABS_MT_POSITION_Y);
device->abs.min_y = absinfo->minimum;
device->abs.max_y = absinfo->maximum;
device->abs.absinfo_y = absinfo;
device->is_mt = 1;
has_touch = 1;
has_mt = 1;

View file

@ -66,7 +66,7 @@ struct evdev_device {
const char *devname;
int fd;
struct {
int min_x, max_x, min_y, max_y;
const struct input_absinfo *absinfo_x, *absinfo_y;
int32_t x, y;
int32_t seat_slot;