blob: 8dfb939e666adb6551b3a26a40e6cd2bd9886d0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
}
|