diff options
Diffstat (limited to 'src/hwstate.c')
| -rw-r--r-- | src/hwstate.c | 69 |
1 files changed, 2 insertions, 67 deletions
diff --git a/src/hwstate.c b/src/hwstate.c index 7e40b50..50e34de 100644 --- a/src/hwstate.c +++ b/src/hwstate.c | |||
| @@ -23,8 +23,6 @@ | |||
| 23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
| 24 | #include <limits.h> | 24 | #include <limits.h> |
| 25 | 25 | ||
| 26 | const double FTW = 0.05; | ||
| 27 | const double FTS = 0.05; | ||
| 28 | const int XMAX = 32767; | 26 | const int XMAX = 32767; |
| 29 | 27 | ||
| 30 | void init_hwstate(struct HWState *s) | 28 | void init_hwstate(struct HWState *s) |
| @@ -63,17 +61,6 @@ static void set_finger(struct FingerState *fs, | |||
| 63 | fs->hw.width_minor = hw->width_major; | 61 | fs->hw.width_minor = hw->width_major; |
| 64 | } | 62 | } |
| 65 | 63 | ||
| 66 | static int touching_finger(const struct FingerData *hw, | ||
| 67 | const struct Capabilities *caps) | ||
| 68 | { | ||
| 69 | if (caps->has_touch_major && caps->has_width_major) | ||
| 70 | return hw->width_major > 0 && | ||
| 71 | hw->touch_major > FTW * hw->width_major; | ||
| 72 | if (caps->has_touch_major) | ||
| 73 | return hw->touch_major > FTS * caps->abs_touch_major.maximum; | ||
| 74 | return 1; | ||
| 75 | } | ||
| 76 | |||
| 77 | void modify_hwstate(struct HWState *s, | 64 | void modify_hwstate(struct HWState *s, |
| 78 | const struct HWData *hw, | 65 | const struct HWData *hw, |
| 79 | const struct Capabilities *caps) | 66 | const struct Capabilities *caps) |
| @@ -96,11 +83,8 @@ void modify_hwstate(struct HWState *s, | |||
| 96 | for (hwk = 0; hwk < hw->nfinger; hwk++) { | 83 | for (hwk = 0; hwk < hw->nfinger; hwk++) { |
| 97 | sk = hw2s[hwk]; | 84 | sk = hw2s[hwk]; |
| 98 | id = sk >= 0 ? sid[sk] : 0; | 85 | id = sk >= 0 ? sid[sk] : 0; |
| 99 | if (!touching_finger(&hw->finger[hwk], caps)) | 86 | while (!id) |
| 100 | id = 0; | 87 | id = ++s->lastid; |
| 101 | else | ||
| 102 | while (!id) | ||
| 103 | id = ++s->lastid; | ||
| 104 | set_finger(&s->finger[hwk], &hw->finger[hwk], id, caps); | 88 | set_finger(&s->finger[hwk], &hw->finger[hwk], id, caps); |
| 105 | } | 89 | } |
| 106 | 90 | ||
| @@ -111,52 +95,3 @@ void modify_hwstate(struct HWState *s, | |||
| 111 | /* sort fingers in touching order */ | 95 | /* sort fingers in touching order */ |
| 112 | qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp); | 96 | qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp); |
| 113 | } | 97 | } |
| 114 | |||
| 115 | const struct FingerState *find_finger(const struct HWState *s, int id) | ||
| 116 | { | ||
| 117 | int i; | ||
| 118 | |||
| 119 | if (!id) | ||
| 120 | return NULL; | ||
| 121 | for (i = 0; i < s->nfinger; i++) | ||
| 122 | if (s->finger[i].id == id) | ||
| 123 | return s->finger + i; | ||
| 124 | |||
| 125 | return NULL; | ||
| 126 | } | ||
| 127 | |||
| 128 | int count_fingers(const struct HWState *s) | ||
| 129 | { | ||
| 130 | int i, n = 0; | ||
| 131 | for (i = 0; i < s->nfinger; i++) | ||
| 132 | if (s->finger[i].id) | ||
| 133 | n++; | ||
| 134 | return n; | ||
| 135 | } | ||
| 136 | |||
| 137 | void output_hwstate(const struct HWState *s) | ||
| 138 | { | ||
| 139 | int i; | ||
| 140 | xf86Msg(X_INFO, "buttons: %d%d%d\n", | ||
| 141 | GETBIT(s->button, MT_BUTTON_LEFT), | ||
| 142 | GETBIT(s->button, MT_BUTTON_MIDDLE), | ||
| 143 | GETBIT(s->button, MT_BUTTON_RIGHT)); | ||
| 144 | xf86Msg(X_INFO, "fingers: %d\n", | ||
| 145 | s->nfinger); | ||
| 146 | xf86Msg(X_INFO, "evtime: %lld\n", | ||
| 147 | s->evtime); | ||
| 148 | for (i = 0; i < s->nfinger; i++) { | ||
| 149 | xf86Msg(X_INFO, | ||
| 150 | " %+02d %+05d:%+05d +%05d:%+05d " | ||
| 151 | "%+06d %+06d %+05d:%+05d\n", | ||
| 152 | s->finger[i].id, | ||
| 153 | s->finger[i].hw.touch_major, | ||
| 154 | s->finger[i].hw.touch_minor, | ||
| 155 | s->finger[i].hw.width_major, | ||
| 156 | s->finger[i].hw.width_minor, | ||
| 157 | s->finger[i].hw.orientation, | ||
| 158 | s->finger[i].hw.pressure, | ||
| 159 | s->finger[i].hw.position_x, | ||
| 160 | s->finger[i].hw.position_y); | ||
| 161 | } | ||
| 162 | } | ||
