From 93e1a5a3904ef2f14110d8b807bcd7d107b3b2a4 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Mon, 14 Feb 2011 12:51:01 +0100 Subject: 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 --- src/frame-mtdev.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/frame-mtdev.c') 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, } s->max_pressure = evemu_get_abs_maximum(dev, ABS_MT_PRESSURE); - if (s->use_pressure && s->max_pressure == 0) + if (s->max_pressure == 0) s->max_pressure = 256; - fh->max_orient = evemu_get_abs_maximum(dev, ABS_MT_ORIENTATION); - if (s->use_orientation && fh->max_orient == 0) - fh->max_orient = 1; + s->max_orient = evemu_get_abs_maximum(dev, ABS_MT_ORIENTATION); + if (s->max_orient == 0) + s->max_orient = 1; tmp = evemu_get_abs_resolution(dev, ABS_MT_POSITION_X); if (tmp > 0) @@ -133,12 +133,14 @@ int utouch_frame_init_mtdev(utouch_frame_handle fh, else s->phys_pressure = 10; - return 0; -} + /* defaults expected by initial frame version */ + s->mapped_min_x = s->min_x; + s->mapped_min_y = s->min_y; + s->mapped_max_x = s->max_x; + s->mapped_max_y = s->max_y; + s->mapped_max_pressure = s->max_pressure; -static float touch_angle(utouch_frame_handle fh, int orient) -{ - return orient / fh->max_orient * M_PI_2; + return 0; } static int handle_abs_event(utouch_frame_handle fh, @@ -169,7 +171,7 @@ static int handle_abs_event(utouch_frame_handle fh, t->width_minor = ev->value; return 1; case ABS_MT_ORIENTATION: - t->orientation = touch_angle(fh, ev->value); + t->orientation = ev->value; return 1; case ABS_MT_PRESSURE: t->pressure = ev->value; -- cgit v1.2.3