From 963d6f71bb64125603d59c8bb70eaeec38c6fd72 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 10 Apr 2010 22:57:26 +0200 Subject: Introduce the MTState The HWState keeps, for good reason, both touching fingers and fingers going away. However, this implies that additional logic is needed to keep track of the number of actual touching fingers. In particular the test for touching fingers is somewhat misplaced in hwstate.c. Moreover, HWState should only exist in one instance, since it contains data which does not need to be referred to during gesture extraction. This patch introduces the MTState structure, which keeps more digested data for gesture extraction. In particular, it only keeps the actual touches. Signed-off-by: Henrik Rydberg --- src/gestures.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/gestures.c') diff --git a/src/gestures.c b/src/gestures.c index 5dd6861..ebf103f 100644 --- a/src/gestures.c +++ b/src/gestures.c @@ -25,16 +25,16 @@ void extract_gestures(struct Gestures *gs, struct MTouch* mt) { - const struct FingerState *b = mt->nhs.finger; - const struct FingerState *e = b + mt->nhs.nfinger; + const struct FingerState *b = mt->state.finger; + const struct FingerState *e = b + mt->state.nfinger; const struct FingerState *p, *fs; - int nof = count_fingers(&mt->ohs); - int nsf = count_fingers(&mt->nhs); + int nof = mt->prev_state.nfinger; + int nsf = mt->state.nfinger; int dn = 0, i; memset(gs, 0, sizeof(struct Gestures)); if (nof == nsf) { for (p = b; p != e; p++) { - fs = find_finger(&mt->ohs, p->id); + fs = find_finger(&mt->prev_state, p->id); if (fs) { gs->dx += p->hw.position_x - fs->hw.position_x; gs->dy += p->hw.position_y - fs->hw.position_y; @@ -52,14 +52,15 @@ void extract_gestures(struct Gestures *gs, struct MTouch* mt) if (nsf == 3) SETBIT(gs->type, GS_HSCROLL); } - if (mt->nhs.button == BITMASK(MT_BUTTON_LEFT)) { + if (mt->state.button == BITMASK(MT_BUTTON_LEFT)) { if (nsf == 2) - mt->nhs.button = BITMASK(MT_BUTTON_RIGHT); + mt->state.button = BITMASK(MT_BUTTON_RIGHT); if (nsf == 3) - mt->nhs.button = BITMASK(MT_BUTTON_MIDDLE); + mt->state.button = BITMASK(MT_BUTTON_MIDDLE); } - gs->btmask = (mt->nhs.button ^ mt->ohs.button) & BITONES(DIM_BUTTON); - gs->btdata = mt->nhs.button & BITONES(DIM_BUTTON); - mt->ohs = mt->nhs; + gs->btmask = (mt->state.button ^ mt->prev_state.button) & + BITONES(DIM_BUTTON); + gs->btdata = mt->state.button & BITONES(DIM_BUTTON); + mt->prev_state = mt->state; } -- cgit v1.2.3