}
}
+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
}
static void
-evdev_process_touch_button(struct evdev_device *device, int time, int value)
+evdev_process_touch_button(struct evdev_device *device,
+ uint64_t time, int value)
{
if (device->pending_event != EVDEV_NONE &&
device->pending_event != EVDEV_ABSOLUTE_MOTION)
}
static inline void
-evdev_process_key(struct evdev_device *device, struct input_event *e, int time)
+evdev_process_key(struct evdev_device *device,
+ struct input_event *e, uint64_t time)
{
/* ignore kernel key repeat */
if (e->value == 2)
&device->base,
time,
e->code,
- e->value ? LIBINPUT_KEYBOARD_KEY_STATE_PRESSED :
- LIBINPUT_KEYBOARD_KEY_STATE_RELEASED);
+ e->value ? LIBINPUT_KEY_STATE_PRESSED :
+ LIBINPUT_KEY_STATE_RELEASED);
break;
}
}
pointer_notify_axis(
base,
time,
- LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL,
+ LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
-1 * e->value * DEFAULT_AXIS_STEP_DISTANCE);
break;
case REL_HWHEEL:
pointer_notify_axis(
base,
time,
- LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL,
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
e->value * DEFAULT_AXIS_STEP_DISTANCE);
break;
default:
{
struct libevdev *evdev = device->evdev;
const struct input_absinfo *absinfo;
+ struct input_absinfo fixed;
int has_abs, has_rel, has_mt;
int has_button, has_keyboard, has_touch;
struct mt_slot *slots;
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;
+ if (absinfo->resolution == 0) {
+ fixed = *absinfo;
+ fixed.resolution = 1;
+ libevdev_set_abs_info(evdev, ABS_X, &fixed);
+ }
+ 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;
+ if (absinfo->resolution == 0) {
+ fixed = *absinfo;
+ fixed.resolution = 1;
+ libevdev_set_abs_info(evdev, ABS_Y, &fixed);
+ }
+ 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;
+ if (absinfo->resolution == 0) {
+ fixed = *absinfo;
+ fixed.resolution = 1;
+ libevdev_set_abs_info(evdev,
+ ABS_MT_POSITION_X,
+ &fixed);
+ }
+ 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;
+ if (absinfo->resolution == 0) {
+ fixed = *absinfo;
+ fixed.resolution = 1;
+ libevdev_set_abs_info(evdev,
+ ABS_MT_POSITION_Y,
+ &fixed);
+ }
+ device->abs.absinfo_y = absinfo;
device->is_mt = 1;
has_touch = 1;
has_mt = 1;
}
}
+int
+evdev_device_get_size(struct evdev_device *device,
+ double *width,
+ double *height)
+{
+ const struct input_absinfo *x, *y;
+
+ x = libevdev_get_abs_info(device->evdev, ABS_X);
+ y = libevdev_get_abs_info(device->evdev, ABS_Y);
+
+ if (!x || !y || !x->resolution || !y->resolution)
+ return -1;
+
+ *width = evdev_convert_to_mm(x, x->maximum);
+ *height = evdev_convert_to_mm(y, y->maximum);
+
+ return 0;
+}
+
void
evdev_device_remove(struct evdev_device *device)
{