diff options
| -rw-r--r-- | include/utouch/frame.h | 30 | ||||
| -rw-r--r-- | src/frame-impl.h | 1 | ||||
| -rw-r--r-- | src/frame-mtdev.c | 22 | ||||
| -rw-r--r-- | src/frame.c | 21 |
4 files changed, 57 insertions, 17 deletions
diff --git a/include/utouch/frame.h b/include/utouch/frame.h index f136eb1..5b5f4d2 100644 --- a/include/utouch/frame.h +++ b/include/utouch/frame.h | |||
| @@ -28,7 +28,7 @@ extern "C" { | |||
| 28 | 28 | ||
| 29 | #include <stdint.h> | 29 | #include <stdint.h> |
| 30 | 30 | ||
| 31 | #define UTOUCH_FRAME_VERSION 0x00001000 | 31 | #define UTOUCH_FRAME_VERSION 0x00001010 |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * struct utouch_surface - device surface details | 34 | * struct utouch_surface - device surface details |
| @@ -46,11 +46,23 @@ extern "C" { | |||
| 46 | * @phys_width: physical width in millimeters (mm) | 46 | * @phys_width: physical width in millimeters (mm) |
| 47 | * @phys_height: physical height in millimeters (mm) | 47 | * @phys_height: physical height in millimeters (mm) |
| 48 | * @phys_pressure: maximal physical pressure (N/cm^2) | 48 | * @phys_pressure: maximal physical pressure (N/cm^2) |
| 49 | * @min_x: minimum horizontal coordinate value | 49 | * @min_x: minimum horizontal device coordinate |
| 50 | * @min_y: minimum vertical coordinate value | 50 | * @min_y: minimum vertical device coordinate |
| 51 | * @max_x: maximum horizontal coordinate value | 51 | * @max_x: maximum horizontal device coordinate |
| 52 | * @max_y: maximum vertical coordinate value | 52 | * @max_y: maximum vertical device coordinate |
| 53 | * @max_pressure: maximum pressure coordinate value | 53 | * @max_pressure: maximum pressure device coordinate |
| 54 | * @max_orient: maximum orientation device coordinate | ||
| 55 | * @mapped_min_x: minimum horizontal mapped coordinate | ||
| 56 | * @mapped_min_y: minimum vertical mapped coordinate | ||
| 57 | * @mapped_max_x: maximum horizontal mapped coordinate | ||
| 58 | * @mapped_max_y: maximum vertical mapped coordinate | ||
| 59 | * @mapped_max_pressure: maximum pressure mapped coordinate | ||
| 60 | * | ||
| 61 | * The mutable contact given by utouch_frame_get_current_slot() should | ||
| 62 | * be set in device coordinates. The contact data is subsequently | ||
| 63 | * transformed to mapped (e.g., screen) coordinates in | ||
| 64 | * utouch_frame_sync(). To a frame user, all data will appear in | ||
| 65 | * mapped coordinates. | ||
| 54 | * | 66 | * |
| 55 | * Device properties and touch surface details. Later versions of this | 67 | * Device properties and touch surface details. Later versions of this |
| 56 | * struct may grow in size, but will remain binary compatible with | 68 | * struct may grow in size, but will remain binary compatible with |
| @@ -76,6 +88,12 @@ struct utouch_surface { | |||
| 76 | float max_x; | 88 | float max_x; |
| 77 | float max_y; | 89 | float max_y; |
| 78 | float max_pressure; | 90 | float max_pressure; |
| 91 | float max_orient; | ||
| 92 | float mapped_min_x; | ||
| 93 | float mapped_min_y; | ||
| 94 | float mapped_max_x; | ||
| 95 | float mapped_max_y; | ||
| 96 | float mapped_max_pressure; | ||
| 79 | }; | 97 | }; |
| 80 | 98 | ||
| 81 | #define UTOUCH_TOOL_FINGER 0 | 99 | #define UTOUCH_TOOL_FINGER 0 |
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, |
