uint64_t value;
};
+static inline struct pointer_delta_smoothener *
+pointer_delta_smoothener_create(uint64_t event_delta_smooth_threshold,
+ uint64_t event_delta_smooth_value)
+{
+ struct pointer_delta_smoothener *s = zalloc(sizeof(*s));
+ s->threshold = event_delta_smooth_threshold;
+ s->value = event_delta_smooth_value;
+ return s;
+}
+
+static inline void
+pointer_delta_smoothener_destroy(struct pointer_delta_smoothener *smoothener)
+{
+ free(smoothener);
+}
+
struct pointer_trackers {
struct pointer_tracker *trackers;
size_t ntrackers;
bool use_velocity_averaging)
{
struct touchpad_accelerator *filter;
- struct pointer_delta_smoothener *smoothener;
filter = zalloc(sizeof *filter);
filter->last_velocity = 0.0;
filter->base.interface = &accelerator_interface_touchpad;
filter->profile = touchpad_accel_profile_linear;
-
- smoothener = zalloc(sizeof(*smoothener));
- smoothener->threshold = event_delta_smooth_threshold,
- smoothener->value = event_delta_smooth_value,
- filter->trackers.smoothener = smoothener;
+ filter->trackers.smoothener = pointer_delta_smoothener_create(event_delta_smooth_threshold, event_delta_smooth_value);
return &filter->base;
}
create_pointer_accelerator_filter_trackpoint(double multiplier, bool use_velocity_averaging)
{
struct trackpoint_accelerator *filter;
- struct pointer_delta_smoothener *smoothener;
assert(multiplier > 0.0);
trackers_init(&filter->trackers, use_velocity_averaging ? 16 : 2);
filter->base.interface = &accelerator_interface_trackpoint;
-
- smoothener = zalloc(sizeof(*smoothener));
- smoothener->threshold = ms2us(10);
- smoothener->value = ms2us(10);
- filter->trackers.smoothener = smoothener;
+ filter->trackers.smoothener = pointer_delta_smoothener_create(ms2us(10), ms2us(10));
return &filter->base;
}
trackers_free(struct pointer_trackers *trackers)
{
free(trackers->trackers);
- free(trackers->smoothener);
+ pointer_delta_smoothener_destroy(trackers->smoothener);
}
void