summaryrefslogtreecommitdiff
path: root/src/frame.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-02-14 12:51:01 +0100
committerHenrik Rydberg <rydberg@euromail.se>2011-02-15 12:42:41 +0100
commit93e1a5a3904ef2f14110d8b807bcd7d107b3b2a4 (patch)
treea50e22d57ae77bcaa7674b4ff4bf8b2b1c3f690f /src/frame.c
parenta06bde2b7aec991b798de9a8e0d7972adaabb40d (diff)
Map device coordinates onto target surface
The current implementation outputs most touch attributes in device coordinates. However, the primary use case is to map the input device onto an area on the screen, needed in particular for multihead setups. Moreover, the XI2.1 backend works with screen coordinates, creating an unnecessary discrepancy between backends. This patch adds the basic transformation layer to the utouch surface, thus serving as the master point of device-to-surface mapping. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c21
1 files changed, 21 insertions, 0 deletions
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
208static 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
208static void copy_contact(utouch_frame_handle fh, 227static 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
230static int detect_addrem(const struct utouch_contact *a, 251static int detect_addrem(const struct utouch_contact *a,