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>
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);
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;
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;
}
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 =
}
}
+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
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
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.
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;
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;