Commit 33d708e2 authored by Peter Hutterer's avatar Peter Hutterer

touchpad: convert normalized_length to physical coordinates

Now that the acceleration code doesn't use dpi-normalized coordinates anymore,
we don't need to use them in the touchpad code. Switch to physical distances
instead, it makes debugging a lot saner.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 43352590
......@@ -186,18 +186,20 @@ tp_gesture_get_direction(struct tp_dispatch *tp, struct tp_touch *touch,
unsigned int nfingers)
{
struct normalized_coords normalized;
struct phys_coords mm;
struct device_float_coords delta;
double move_threshold = TP_MM_TO_DPI_NORMALIZED(1);
double move_threshold = 1.0; /* mm */
move_threshold *= (nfingers - 1);
delta = device_delta(touch->point, touch->gesture.initial);
mm = tp_phys_delta(tp, delta);
normalized = tp_normalize_delta(tp, delta);
if (normalized_length(normalized) < move_threshold)
if (length_in_mm(mm) < move_threshold)
return UNDEFINED_DIRECTION;
normalized = tp_normalize_delta(tp, delta);
return normalized_get_direction(normalized);
}
......
......@@ -36,7 +36,7 @@
#define DEFAULT_TAP_INITIAL_TIMEOUT_PERIOD ms2us(100)
#define DEFAULT_TAP_TIMEOUT_PERIOD ms2us(180)
#define DEFAULT_DRAG_TIMEOUT_PERIOD ms2us(300)
#define DEFAULT_TAP_MOVE_THRESHOLD TP_MM_TO_DPI_NORMALIZED(1.3)
#define DEFAULT_TAP_MOVE_THRESHOLD 1.3 /* mm */
enum tap_event {
TAP_EVENT_TOUCH = 12,
......@@ -734,11 +734,10 @@ static bool
tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp,
struct tp_touch *t)
{
struct normalized_coords norm =
tp_normalize_delta(tp, device_delta(t->point,
t->tap.initial));
struct phys_coords mm =
tp_phys_delta(tp, device_delta(t->point, t->tap.initial));
return normalized_length(norm) > DEFAULT_TAP_MOVE_THRESHOLD;
return length_in_mm(mm) > DEFAULT_TAP_MOVE_THRESHOLD;
}
static bool
......
......@@ -751,12 +751,11 @@ tp_thumb_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
t->thumb.initial = t->point;
else if (t->state == TOUCH_UPDATE) {
struct device_float_coords delta;
struct normalized_coords normalized;
struct phys_coords mm;
delta = device_delta(t->point, t->thumb.initial);
normalized = tp_normalize_delta(tp, delta);
if (normalized_length(normalized) >
TP_MM_TO_DPI_NORMALIZED(7)) {
mm = tp_phys_delta(tp, delta);
if (length_in_mm(mm) > 7) {
t->thumb.state = THUMB_STATE_NO;
goto out;
}
......
......@@ -399,6 +399,18 @@ tp_normalize_delta(const struct tp_dispatch *tp,
return normalized;
}
static inline struct phys_coords
tp_phys_delta(const struct tp_dispatch *tp,
struct device_float_coords delta)
{
struct phys_coords mm;
mm.x = delta.x / tp->device->abs.absinfo_x->resolution;
mm.y = delta.y / tp->device->abs.absinfo_y->resolution;
return mm;
}
/**
* Takes a dpi-normalized set of coordinates, returns a set of coordinates
* in the x-axis' coordinate space.
......
......@@ -699,6 +699,12 @@ normalized_is_zero(struct normalized_coords norm)
return norm.x == 0.0 && norm.y == 0.0;
}
static inline double
length_in_mm(struct phys_coords mm)
{
return hypot(mm.x, mm.y);
}
enum directions {
N = 1 << 0,
NE = 1 << 1,
......
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