touchscreen: Add gesture velocity helper

Add a helper for computing the motion velocity during a touchscreen press.

Change-Id: I1ef7452ba9815897fd3ec01f8980c89aeef5418f
This commit is contained in:
Aidan MacDonald 2022-04-23 19:20:48 +01:00 committed by Solomon Peachy
parent 7aa823215b
commit bb1e0b48a0
2 changed files with 76 additions and 0 deletions

View file

@ -120,4 +120,18 @@ static inline bool gesture_is_pressed(struct gesture *g)
return !!(g->flags & GESTURE_F_PRESSED);
}
/* Helper for computing velocity vectors */
struct gesture_vel
{
size_t idx;
size_t cnt;
short xsamp[4];
short ysamp[4];
long tsamp[4];
};
void gesture_vel_reset(struct gesture_vel *gv);
void gesture_vel_process(struct gesture_vel *gv, const struct touchevent *ev);
bool gesture_vel_get(struct gesture_vel *gv, int *xvel, int *yvel);
#endif /* _GESTURE_H_ */