summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-03-09 10:17:43 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-03-09 10:17:43 +1000
commit49a8bd3ca76d11b1ec604df741f5c4fdccf0b9d3 (patch)
tree4dff1d2c3abadfa9dbe6e1e6e7988ff155effa9c /src
parente9e134a18d46da20ddf835efe3df1dab2b29e9f1 (diff)
parent1523d8bb2e066bec297f7a03ce4a0d8cada8f383 (diff)
Merge branch 'wip/hysteresis-wobbles'
Diffstat (limited to 'src')
-rw-r--r--src/evdev-fallback.c7
-rw-r--r--src/evdev-mt-touchpad.c24
-rw-r--r--src/evdev.c39
-rw-r--r--src/evdev.h3
4 files changed, 64 insertions, 9 deletions
diff --git a/src/evdev-fallback.c b/src/evdev-fallback.c
index d1ca81f0..269b3f5a 100644
--- a/src/evdev-fallback.c
+++ b/src/evdev-fallback.c
@@ -130,12 +130,13 @@ fallback_filter_defuzz_touch(struct fallback_dispatch *dispatch,
point = evdev_hysteresis(&slot->point,
&slot->hysteresis_center,
&dispatch->mt.hysteresis_margin);
+ slot->point = point;
- slot->hysteresis_center = slot->point;
- if (point.x == slot->point.x && point.y == slot->point.y)
+ if (point.x == slot->hysteresis_center.x &&
+ point.y == slot->hysteresis_center.y)
return true;
- slot->point = point;
+ slot->hysteresis_center = point;
return false;
}
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 3c9539f2..fe3b3404 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -3099,13 +3099,25 @@ tp_init_default_resolution(struct tp_dispatch *tp,
static inline void
tp_init_hysteresis(struct tp_dispatch *tp)
{
- int res_x, res_y;
+ int xmargin, ymargin;
+ const struct input_absinfo *ax = tp->device->abs.absinfo_x,
+ *ay = tp->device->abs.absinfo_y;
- res_x = tp->device->abs.absinfo_x->resolution;
- res_y = tp->device->abs.absinfo_y->resolution;
- tp->hysteresis.margin.x = res_x/2;
- tp->hysteresis.margin.y = res_y/2;
- tp->hysteresis.enabled = false;
+ if (ax->fuzz)
+ xmargin = ax->fuzz;
+ else
+ xmargin = ax->resolution/4;
+
+ if (ay->fuzz)
+ ymargin = ay->fuzz;
+ else
+ ymargin = ay->resolution/4;
+
+ tp->hysteresis.margin.x = xmargin;
+ tp->hysteresis.margin.y = ymargin;
+ tp->hysteresis.enabled = (ax->fuzz || ay->fuzz);
+ if (tp->hysteresis.enabled)
+ evdev_log_debug(tp->device, "hysteresis enabled\n");
}
static void
diff --git a/src/evdev.c b/src/evdev.c
index 5c979ed1..b5fedf09 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1511,6 +1511,7 @@ static void
evdev_extract_abs_axes(struct evdev_device *device)
{
struct libevdev *evdev = device->evdev;
+ int fuzz;
if (!libevdev_has_event_code(evdev, EV_ABS, ABS_X) ||
!libevdev_has_event_code(evdev, EV_ABS, ABS_Y))
@@ -1518,6 +1519,12 @@ evdev_extract_abs_axes(struct evdev_device *device)
if (evdev_fix_abs_resolution(device, ABS_X, ABS_Y))
device->abs.is_fake_resolution = true;
+
+ if ((fuzz = evdev_read_fuzz_prop(device, ABS_X)))
+ libevdev_set_abs_fuzz(evdev, ABS_X, fuzz);
+ if ((fuzz = evdev_read_fuzz_prop(device, ABS_Y)))
+ libevdev_set_abs_fuzz(evdev, ABS_Y, fuzz);
+
device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_X);
device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y);
device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum -
@@ -1535,6 +1542,11 @@ evdev_extract_abs_axes(struct evdev_device *device)
ABS_MT_POSITION_Y))
device->abs.is_fake_resolution = true;
+ if ((fuzz = evdev_read_fuzz_prop(device, ABS_MT_POSITION_X)))
+ libevdev_set_abs_fuzz(evdev, ABS_MT_POSITION_X, fuzz);
+ if ((fuzz = evdev_read_fuzz_prop(device, ABS_MT_POSITION_Y)))
+ libevdev_set_abs_fuzz(evdev, ABS_MT_POSITION_Y, fuzz);
+
device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X);
device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_MT_POSITION_Y);
device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum -
@@ -2170,6 +2182,33 @@ evdev_read_calibration_prop(struct evdev_device *device)
calibration[5]);
}
+int
+evdev_read_fuzz_prop(struct evdev_device *device, unsigned int code)
+{
+ const char *prop;
+ char name[32];
+ int rc;
+ int fuzz = 0;
+
+ rc = snprintf(name, sizeof(name), "LIBINPUT_FUZZ_%02x", code);
+ if (rc == -1)
+ return 0;
+
+ prop = udev_device_get_property_value(device->udev_device, name);
+ if (prop == NULL)
+ return 0;
+
+ rc = safe_atoi(prop, &fuzz);
+ if (rc == -1 || fuzz < 0) {
+ evdev_log_bug_libinput(device,
+ "invalid LIBINPUT_FUZZ property value: %s\n",
+ prop);
+ return 0;
+ }
+
+ return fuzz;
+}
+
bool
evdev_device_has_capability(struct evdev_device *device,
enum libinput_device_capability capability)
diff --git a/src/evdev.h b/src/evdev.h
index db2ae545..be74dfc5 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -379,6 +379,9 @@ evdev_init_calibration(struct evdev_device *device,
void
evdev_read_calibration_prop(struct evdev_device *device);
+int
+evdev_read_fuzz_prop(struct evdev_device *device, unsigned int code);
+
enum switch_reliability
evdev_read_switch_reliability_prop(struct evdev_device *device);