diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-05-14 01:10:17 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-05-14 01:41:39 +0200 |
| commit | 2b271ed5348daec2bcf90b83da47781e2d8b964c (patch) | |
| tree | 1828f251cf4b7d4f6a66a6af67c2681998f2483e /src/hwstate.c | |
| parent | f02210172efc6bfc05c4598c14e1268d2828097e (diff) | |
janitor: Move min/max and dist functions up to common.h
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/hwstate.c')
| -rw-r--r-- | src/hwstate.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/src/hwstate.c b/src/hwstate.c index 07bab31..a68b81a 100644 --- a/src/hwstate.c +++ b/src/hwstate.c | |||
| @@ -25,27 +25,11 @@ | |||
| 25 | 25 | ||
| 26 | #define NOTOUCH(hw, c) ((hw)->touch_major == 0 && (c)->has_touch_major) | 26 | #define NOTOUCH(hw, c) ((hw)->touch_major == 0 && (c)->has_touch_major) |
| 27 | 27 | ||
| 28 | const int XMAX = 32767; | ||
| 29 | |||
| 30 | void init_hwstate(struct HWState *s) | 28 | void init_hwstate(struct HWState *s) |
| 31 | { | 29 | { |
| 32 | memset(s, 0, sizeof(struct HWState)); | 30 | memset(s, 0, sizeof(struct HWState)); |
| 33 | } | 31 | } |
| 34 | 32 | ||
| 35 | static inline int clamp15(int x) | ||
| 36 | { | ||
| 37 | return x < -XMAX ? -XMAX : x > XMAX ? XMAX : x; | ||
| 38 | } | ||
| 39 | |||
| 40 | /* abslute scale is assumed to fit in 15 bits */ | ||
| 41 | inline int dist2(const struct FingerData *a, const struct FingerData *b) | ||
| 42 | { | ||
| 43 | int dx = clamp15(a->position_x - b->position_x); | ||
| 44 | int dy = clamp15(a->position_y - b->position_y); | ||
| 45 | |||
| 46 | return dx * dx + dy * dy; | ||
| 47 | } | ||
| 48 | |||
| 49 | /* Dmitry Torokhov's code from kernel/driver/input/input.c */ | 33 | /* Dmitry Torokhov's code from kernel/driver/input/input.c */ |
| 50 | static int defuzz(int value, int old_val, int fuzz) | 34 | static int defuzz(int value, int old_val, int fuzz) |
| 51 | { | 35 | { |
| @@ -104,7 +88,7 @@ void modify_hwstate(struct HWState *s, | |||
| 104 | sid[j] = 0; | 88 | sid[j] = 0; |
| 105 | row = A + hw->nfinger * j; | 89 | row = A + hw->nfinger * j; |
| 106 | for (i = 0; i < hw->nfinger; i++) | 90 | for (i = 0; i < hw->nfinger; i++) |
| 107 | row[i] = dist2(&hw->finger[i], &s->finger[j].hw); | 91 | row[i] = finger_dist2(&hw->finger[i], &s->finger[j].hw); |
| 108 | } | 92 | } |
| 109 | 93 | ||
| 110 | match_fingers(hw2s, A, hw->nfinger, s->nfinger); | 94 | match_fingers(hw2s, A, hw->nfinger, s->nfinger); |
