2012-05-17 12:18:17 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2012 Jonas Ådahl
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and
|
|
|
|
|
* its documentation for any purpose is hereby granted without fee, provided
|
|
|
|
|
* that the above copyright notice appear in all copies and that both that
|
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
|
* documentation, and that the name of the copyright holders not be used in
|
|
|
|
|
* advertising or publicity pertaining to distribution of the software
|
|
|
|
|
* without specific, written prior permission. The copyright holders make
|
|
|
|
|
* no representations about the suitability of this software for any
|
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
|
|
|
|
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
|
|
|
|
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
#ifndef FILTER_H
|
|
|
|
|
#define FILTER_H
|
2012-05-17 12:18:17 +02:00
|
|
|
|
2013-08-15 01:10:24 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
struct motion_params {
|
2012-05-17 12:18:17 +02:00
|
|
|
double dx, dy;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
struct motion_filter;
|
2012-05-17 12:18:17 +02:00
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
void
|
|
|
|
|
filter_dispatch(struct motion_filter *filter,
|
|
|
|
|
struct motion_params *motion,
|
2014-04-08 12:29:45 +02:00
|
|
|
void *data, uint64_t time);
|
2012-05-17 12:18:17 +02:00
|
|
|
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
struct motion_filter_interface {
|
|
|
|
|
void (*filter)(struct motion_filter *filter,
|
|
|
|
|
struct motion_params *motion,
|
2014-04-08 12:29:45 +02:00
|
|
|
void *data, uint64_t time);
|
2013-11-10 17:55:40 +01:00
|
|
|
void (*destroy)(struct motion_filter *filter);
|
2012-05-17 12:18:17 +02:00
|
|
|
};
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
struct motion_filter {
|
|
|
|
|
struct motion_filter_interface *interface;
|
2012-05-17 12:18:17 +02:00
|
|
|
};
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
struct motion_filter *
|
2012-05-17 12:18:17 +02:00
|
|
|
create_linear_acceleration_filter(double speed);
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
typedef double (*accel_profile_func_t)(struct motion_filter *filter,
|
2012-05-17 12:18:17 +02:00
|
|
|
void *data,
|
|
|
|
|
double velocity,
|
2014-04-08 12:29:45 +02:00
|
|
|
uint64_t time);
|
2012-05-17 12:18:17 +02:00
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
struct motion_filter *
|
2012-05-17 12:18:17 +02:00
|
|
|
create_pointer_accelator_filter(accel_profile_func_t filter);
|
|
|
|
|
|
2014-05-26 23:20:42 +02:00
|
|
|
void
|
|
|
|
|
motion_filter_destroy(struct motion_filter *filter);
|
|
|
|
|
|
2014-05-18 19:20:39 +02:00
|
|
|
/*
|
|
|
|
|
* Pointer acceleration profiles.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Profile similar which is similar to nonaccelerated but with a smooth
|
|
|
|
|
* transition between accelerated and non-accelerated.
|
|
|
|
|
*/
|
|
|
|
|
double
|
|
|
|
|
pointer_accel_profile_smooth_simple(struct motion_filter *filter,
|
|
|
|
|
void *data,
|
|
|
|
|
double velocity,
|
|
|
|
|
uint64_t time);
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
#endif /* FILTER_H */
|