diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2010-05-14 01:14:04 +0200 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2010-05-14 01:41:39 +0200 |
commit | ebaf307ab1b22d4786cc5fb55170204759e887ce (patch) | |
tree | 933487729ab47354f29cb1fbda38e6438ca8d22c /src | |
parent | 2b271ed5348daec2bcf90b83da47781e2d8b964c (diff) | |
download | xorg-input-kobomultitouch-ebaf307ab1b22d4786cc5fb55170204759e887ce.tar.gz xorg-input-kobomultitouch-ebaf307ab1b22d4786cc5fb55170204759e887ce.tar.bz2 xorg-input-kobomultitouch-ebaf307ab1b22d4786cc5fb55170204759e887ce.zip |
Introduce MTFinger structure
Switch from the FingerData structure to the MTFinger structure, making
room for more computed finger details in MTState.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/gestures.c | 10 | ||||
-rw-r--r-- | src/mtstate.c | 19 | ||||
-rw-r--r-- | src/mtstate.h | 9 |
3 files changed, 27 insertions, 11 deletions
diff --git a/src/gestures.c b/src/gestures.c index a0ef5d4..9426226 100644 --- a/src/gestures.c +++ b/src/gestures.c @@ -31,18 +31,18 @@ static const int FINGER_ATTACK_MS = 70; static const int FINGER_DECAY_MS = 120; -inline int dxval(const struct FingerState *a, const struct FingerState *b) +inline int dxval(const struct MTFinger *a, const struct MTFinger *b) { return a->hw.position_x - b->hw.position_x; } -inline int dyval(const struct FingerState *a, const struct FingerState *b) +inline int dyval(const struct MTFinger *a, const struct MTFinger *b) { return a->hw.position_y - b->hw.position_y; } static void extract_finger_configuration(struct Gestures *gs, struct MTouch* mt) { - const struct FingerState *f = mt->state.finger; + const struct MTFinger *f = mt->state.finger; int i, same = mt->state.nfinger == mt->prev_state.nfinger; for (i = 0; i < mt->state.nfinger; i++) same = same && find_finger(&mt->prev_state, f[i].id); @@ -51,7 +51,7 @@ static void extract_finger_configuration(struct Gestures *gs, struct MTouch* mt) static void extract_pointers(struct Gestures *gs, struct MTouch* mt) { - const struct FingerState *f = mt->state.finger; + const struct MTFinger *f = mt->state.finger; int i; if (mt->state.nfinger < 2) { @@ -86,7 +86,7 @@ static void extract_pointers(struct Gestures *gs, struct MTouch* mt) static void extract_movement(struct Gestures *gs, struct MTouch* mt) { - const struct FingerState *prev, *f = mt->state.finger; + const struct MTFinger *prev, *f = mt->state.finger; int i, x = 0, y = 0; int dx, dy, xcut, ycut, xmax = 0, ymax = 0; diff --git a/src/mtstate.c b/src/mtstate.c index a8541dc..c3bcc78 100644 --- a/src/mtstate.c +++ b/src/mtstate.c @@ -39,6 +39,14 @@ static int touching_finger(const struct FingerData *hw, return 1; } +static int set_finger(struct MTFinger *f, + const struct FingerState *fs, + const struct Capabilities *caps) +{ + f->hw = fs->hw; + f->id = fs->id; +} + void extract_mtstate(struct MTState *s, const struct HWState *hs, const struct Capabilities *caps) @@ -46,15 +54,18 @@ void extract_mtstate(struct MTState *s, int i; s->nfinger = 0; - for (i = 0; i < hs->nfinger; i++) - if (touching_finger(&hs->finger[i].hw, caps)) - s->finger[s->nfinger++] = hs->finger[i]; + for (i = 0; i < hs->nfinger; i++) { + if (!touching_finger(&hs->finger[i].hw, caps)) + continue; + set_finger(&s->finger[s->nfinger], &hs->finger[i], caps); + s->nfinger++; + } s->button = hs->button; s->evtime = hs->evtime; } -const struct FingerState *find_finger(const struct MTState *s, int id) +const struct MTFinger *find_finger(const struct MTState *s, int id) { int i; diff --git a/src/mtstate.h b/src/mtstate.h index f8790dd..fa297cd 100644 --- a/src/mtstate.h +++ b/src/mtstate.h @@ -24,8 +24,13 @@ #include "hwstate.h" +struct MTFinger { + struct FingerData hw; + int id; +}; + struct MTState { - struct FingerState finger[DIM_FINGER]; + struct MTFinger finger[DIM_FINGER]; int nfinger; unsigned button; mstime_t evtime; @@ -37,7 +42,7 @@ void extract_mtstate(struct MTState *s, const struct Capabilities *caps); void output_mtstate(const struct MTState *s); -const struct FingerState *find_finger(const struct MTState *s, int id); +const struct MTFinger *find_finger(const struct MTState *s, int id); #endif |