diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame-impl.h | 1 | ||||
| -rw-r--r-- | src/frame-mtdev.c | 22 | ||||
| -rw-r--r-- | src/frame.c | 21 |
3 files changed, 33 insertions, 11 deletions
diff --git a/src/frame-impl.h b/src/frame-impl.h index 63cbc7c..38affe7 100644 --- a/src/frame-impl.h +++ b/src/frame-impl.h | |||
| @@ -30,7 +30,6 @@ struct utouch_frame_engine { | |||
| 30 | int hold_ms; | 30 | int hold_ms; |
| 31 | int frame; | 31 | int frame; |
| 32 | int slot; | 32 | int slot; |
| 33 | float max_orient; | ||
| 34 | struct utouch_surface *surface; | 33 | struct utouch_surface *surface; |
| 35 | struct utouch_frame **frames; | 34 | struct utouch_frame **frames; |
| 36 | struct utouch_frame *next; | 35 | struct utouch_frame *next; |
diff --git a/src/frame-mtdev.c b/src/frame-mtdev.c index 9192510..caf90ae 100644 --- a/src/frame-mtdev.c +++ b/src/frame-mtdev.c | |||
| @@ -104,12 +104,12 @@ int utouch_frame_init_mtdev(utouch_frame_handle fh, | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | s->max_pressure = evemu_get_abs_maximum(dev, ABS_MT_PRESSURE); | 106 | s->max_pressure = evemu_get_abs_maximum(dev, ABS_MT_PRESSURE); |
| 107 | if (s->use_pressure && s->max_pressure == 0) | 107 | if (s->max_pressure == 0) |
| 108 | s->max_pressure = 256; | 108 | s->max_pressure = 256; |
| 109 | 109 | ||
| 110 | fh->max_orient = evemu_get_abs_maximum(dev, ABS_MT_ORIENTATION); | 110 | s->max_orient = evemu_get_abs_maximum(dev, ABS_MT_ORIENTATION); |
| 111 | if (s->use_orientation && fh->max_orient == 0) | 111 | if (s->max_orient == 0) |
| 112 | fh->max_orient = 1; | 112 | s->max_orient = 1; |
| 113 | 113 | ||
| 114 | tmp = evemu_get_abs_resolution(dev, ABS_MT_POSITION_X); | 114 | tmp = evemu_get_abs_resolution(dev, ABS_MT_POSITION_X); |
| 115 | if (tmp > 0) | 115 | if (tmp > 0) |
| @@ -133,12 +133,14 @@ int utouch_frame_init_mtdev(utouch_frame_handle fh, | |||
| 133 | else | 133 | else |
| 134 | s->phys_pressure = 10; | 134 | s->phys_pressure = 10; |
| 135 | 135 | ||
| 136 | return 0; | 136 | /* defaults expected by initial frame version */ |
| 137 | } | 137 | s->mapped_min_x = s->min_x; |
| 138 | s->mapped_min_y = s->min_y; | ||
| 139 | s->mapped_max_x = s->max_x; | ||
| 140 | s->mapped_max_y = s->max_y; | ||
| 141 | s->mapped_max_pressure = s->max_pressure; | ||
| 138 | 142 | ||
| 139 | static float touch_angle(utouch_frame_handle fh, int orient) | 143 | return 0; |
| 140 | { | ||
| 141 | return orient / fh->max_orient * M_PI_2; | ||
| 142 | } | 144 | } |
| 143 | 145 | ||
| 144 | static int handle_abs_event(utouch_frame_handle fh, | 146 | static int handle_abs_event(utouch_frame_handle fh, |
| @@ -169,7 +171,7 @@ static int handle_abs_event(utouch_frame_handle fh, | |||
| 169 | t->width_minor = ev->value; | 171 | t->width_minor = ev->value; |
| 170 | return 1; | 172 | return 1; |
| 171 | case ABS_MT_ORIENTATION: | 173 | case ABS_MT_ORIENTATION: |
| 172 | t->orientation = touch_angle(fh, ev->value); | 174 | t->orientation = ev->value; |
| 173 | return 1; | 175 | return 1; |
| 174 | case ABS_MT_PRESSURE: | 176 | case ABS_MT_PRESSURE: |
| 175 | t->pressure = ev->value; | 177 | t->pressure = ev->value; |
diff --git a/src/frame.c b/src/frame.c index 9c4be97..e722adf 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -205,6 +205,25 @@ int utouch_frame_set_current_slot(utouch_frame_handle fh, int slot) | |||
| 205 | return 0; | 205 | return 0; |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | static void transform_slot(struct utouch_contact *slot, | ||
| 209 | const struct utouch_surface *s) | ||
| 210 | { | ||
| 211 | float fx = (s->mapped_max_x - s->mapped_min_x) / (s->max_x - s->min_x); | ||
| 212 | float fy = (s->mapped_max_y - s->mapped_min_y) / (s->max_y - s->min_y); | ||
| 213 | /* assume clipped view for asymmetrical scaling */ | ||
| 214 | float f = MAX(fx, fy); | ||
| 215 | |||
| 216 | slot->x = fx * (slot->x - s->min_x) + s->mapped_min_x; | ||
| 217 | slot->y = fy * (slot->y - s->min_y) + s->mapped_min_y; | ||
| 218 | slot->touch_major *= f; | ||
| 219 | slot->touch_minor *= f; | ||
| 220 | slot->width_major *= f; | ||
| 221 | slot->width_minor *= f; | ||
| 222 | slot->orientation *= M_PI_2 / s->max_orient; | ||
| 223 | slot->pressure *= s->mapped_max_pressure / s->max_pressure; | ||
| 224 | slot->distance *= f; | ||
| 225 | } | ||
| 226 | |||
| 208 | static void copy_contact(utouch_frame_handle fh, | 227 | static void copy_contact(utouch_frame_handle fh, |
| 209 | struct utouch_contact *a, | 228 | struct utouch_contact *a, |
| 210 | const struct utouch_contact *b) | 229 | const struct utouch_contact *b) |
| @@ -225,6 +244,8 @@ static void copy_contact(utouch_frame_handle fh, | |||
| 225 | a->orientation = b->orientation; | 244 | a->orientation = b->orientation; |
| 226 | a->pressure = b->pressure; | 245 | a->pressure = b->pressure; |
| 227 | a->distance = b->distance; | 246 | a->distance = b->distance; |
| 247 | |||
| 248 | transform_slot(a, s); | ||
| 228 | } | 249 | } |
| 229 | 250 | ||
| 230 | static int detect_addrem(const struct utouch_contact *a, | 251 | static int detect_addrem(const struct utouch_contact *a, |
