diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2008-11-09 04:20:53 +0100 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2008-11-09 04:20:53 +0100 |
commit | b8f7fdfe1b8974a6677e73cfe7c83da70a35f4ae (patch) | |
tree | 544cbe58102898d9eab3c80fc5be1414670810bf /src/gestures.c | |
parent | 7952ef288f490045a4ab19b510be32512f217324 (diff) | |
download | xorg-input-kobomultitouch-b8f7fdfe1b8974a6677e73cfe7c83da70a35f4ae.tar.gz xorg-input-kobomultitouch-b8f7fdfe1b8974a6677e73cfe7c83da70a35f4ae.tar.bz2 xorg-input-kobomultitouch-b8f7fdfe1b8974a6677e73cfe7c83da70a35f4ae.zip |
Gesture interface in place
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/gestures.c')
-rw-r--r-- | src/gestures.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gestures.c b/src/gestures.c new file mode 100644 index 0000000..8dfb939 --- /dev/null +++ b/src/gestures.c @@ -0,0 +1,39 @@ +#include "gestures.h" + +/******************************************************/ + +void extract_gestures(struct Gestures *gs, struct MTouch* mt) +{ + const struct FingerState *b = mt->ns.finger; + const struct FingerState *e = b + mt->ns.nfinger; + const struct FingerState *p, *fs; + int nof = count_fingers(&mt->os); + int nsf = count_fingers(&mt->ns); + int dn = 0, i; + memset(gs, 0, sizeof(struct Gestures)); + if (nof == nsf) { + for (p = b; p != e; p++) { + if (fs = find_finger(&mt->os, p->id)) { + gs->dx += p->hw.position_x - fs->hw.position_x; + gs->dy += p->hw.position_y - fs->hw.position_y; + dn++; + } + } + } + if (gs->dx || gs->dy) { + gs->dx /= dn; + gs->dy /= dn; + if (nsf == 1) + SETBIT(gs->type, GS_MOVE); + } + for (i = 0; i < DIM_BUTTON; i++) { + if (GETBIT(mt->ns.button, i) != GETBIT(mt->os.button, i)) { + SETBIT(gs->type, GS_BUTTON); + gs->btix[gs->nbt] = i + 1; + gs->btval[gs->nbt] = GETBIT(mt->ns.button, i); + gs->nbt++; + } + } + mt->os = mt->ns; +} + |