struct normalized_coords
tp_get_delta(struct tp_touch *t)
{
- struct delta_coords delta;
+ struct device_float_coords delta;
const struct normalized_coords zero = { 0.0, 0.0 };
if (t->history.count < TOUCHPAD_MIN_SAMPLES)
return zero;
- delta.dx = tp_estimate_delta(tp_motion_history_offset(t, 0)->x,
- tp_motion_history_offset(t, 1)->x,
- tp_motion_history_offset(t, 2)->x,
- tp_motion_history_offset(t, 3)->x);
- delta.dy = tp_estimate_delta(tp_motion_history_offset(t, 0)->y,
- tp_motion_history_offset(t, 1)->y,
- tp_motion_history_offset(t, 2)->y,
- tp_motion_history_offset(t, 3)->y);
+ delta.x = tp_estimate_delta(tp_motion_history_offset(t, 0)->x,
+ tp_motion_history_offset(t, 1)->x,
+ tp_motion_history_offset(t, 2)->x,
+ tp_motion_history_offset(t, 3)->x);
+ delta.y = tp_estimate_delta(tp_motion_history_offset(t, 0)->y,
+ tp_motion_history_offset(t, 1)->y,
+ tp_motion_history_offset(t, 2)->y,
+ tp_motion_history_offset(t, 3)->y);
return tp_normalize_delta(t->tp, delta);
}
for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++)
static inline struct normalized_coords
-tp_normalize_delta(struct tp_dispatch *tp, struct delta_coords delta)
+tp_normalize_delta(struct tp_dispatch *tp, struct device_float_coords delta)
{
struct normalized_coords normalized;
- normalized.x = delta.dx * tp->accel.x_scale_coeff;
- normalized.y = delta.dy * tp->accel.y_scale_coeff;
+ normalized.x = delta.x * tp->accel.x_scale_coeff;
+ normalized.y = delta.y * tp->accel.y_scale_coeff;
return normalized;
}
};
/*
- * A delta between 2 device coordinates,
- * may be non-discrete because of averaging.
+ * A coordinate pair in device coordinates, capable of holding non discrete
+ * values, this is necessary e.g. when device coordinates get averaged.
*/
-struct delta_coords {
- double dx, dy;
+struct device_float_coords {
+ double x, y;
};
/* A dpi-normalized coordinate pair */
return ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000;
}
-static inline struct delta_coords
+static inline struct device_float_coords
device_delta(struct device_coords a, struct device_coords b)
{
- struct delta_coords delta;
+ struct device_float_coords delta;
- delta.dx = a.x - b.x;
- delta.dy = a.y - b.y;
+ delta.x = a.x - b.x;
+ delta.y = a.y - b.y;
return delta;
}