diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2011-01-09 18:44:21 +0100 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2011-01-09 18:44:21 +0100 |
commit | 844253e815bbd512d293aa5953586ff731bd5a97 (patch) | |
tree | 82c312a77d3adfe9ff657bb05eeac3428dbd933e /src | |
parent | f01bc74feac05af3cf1b321d6a7684b6218e1087 (diff) |
simplify setup
Diffstat (limited to 'src')
-rw-r--r-- | src/frame-xi2.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/frame-xi2.c b/src/frame-xi2.c index 9bc4bb3..b1e71da 100644 --- a/src/frame-xi2.c +++ b/src/frame-xi2.c @@ -19,6 +19,7 @@ * ****************************************************************************/ #include <utouch/frame-xi2.h> +#include <xorg/xserver-properties.h> #include <linux/input.h> #include "frame-impl.h" #include <stdlib.h> @@ -27,6 +28,10 @@ #include <stdio.h> +#define set_field(fh, name, number, field) \ + if (!strcmp(name, AXIS_LABEL_PROP_##field) && \ + (fh->evmap[number] = field)) + int utouch_frame_is_supported_xi2(Display *dpy, const XIDeviceInfo *dev) { @@ -72,46 +77,37 @@ int utouch_frame_init_xi2(utouch_frame_handle fh, continue; v = (void *)dev->classes[i]; name = XGetAtomName(dpy, v->label); - fprintf(stderr, "VAL: %d %s\n", v->number, name); - if (!strcmp(name, "Abs MT Position X")) { - fh->evmap[v->number] = ABS_MT_POSITION_X; + set_field(fh, name, v->number, ABS_MT_POSITION_X) { s->min_x = v->min; s->max_x = v->max; if (v->resolution <= 0) break; s->phys_width = (v->max - v->min) / v->resolution; } - if (!strcmp(name, "Abs MT Position Y")) { - fh->evmap[v->number] = ABS_MT_POSITION_Y; + set_field(fh, name, v->number, ABS_MT_POSITION_Y) { s->min_y = v->min; s->max_y = v->max; if (v->resolution <= 0) break; s->phys_height = (v->max - v->min) / v->resolution; } - if (!strcmp(name, "Abs MT Touch Major")) { - fh->evmap[v->number] = ABS_MT_TOUCH_MAJOR; + set_field(fh, name, v->number, ABS_MT_TOUCH_MAJOR) { s->use_touch_major = 1; } - if (!strcmp(name, "Abs MT Touch Minor")) { - fh->evmap[v->number] = ABS_MT_TOUCH_MINOR; + set_field(fh, name, v->number, ABS_MT_TOUCH_MINOR) { s->use_touch_minor = 1; } - if (!strcmp(name, "Abs MT Width Major")) { - fh->evmap[v->number] = ABS_MT_WIDTH_MAJOR; + set_field(fh, name, v->number, ABS_MT_WIDTH_MAJOR) { s->use_width_major = 1; } - if (!strcmp(name, "Abs MT Width Minor")) { - fh->evmap[v->number] = ABS_MT_WIDTH_MINOR; + set_field(fh, name, v->number, ABS_MT_WIDTH_MINOR) { s->use_width_minor = 1; } - if (!strcmp(name, "Abs MT Orientation")) { - fh->evmap[v->number] = ABS_MT_ORIENTATION; + set_field(fh, name, v->number, ABS_MT_ORIENTATION) { s->use_orientation = 1; fh->max_orient = v->max > 0 ? v->max : 1; } - if (!strcmp(name, "Abs MT Pressure")) { - fh->evmap[v->number] = ABS_MT_PRESSURE; + set_field(fh, name, v->number, ABS_MT_PRESSURE) { s->use_pressure = 1; s->max_pressure = v->max > 0 ? v->max : 256; if (v->resolution <= 0) @@ -119,8 +115,7 @@ int utouch_frame_init_xi2(utouch_frame_handle fh, s->phys_pressure = v->max / v->resolution; } #ifdef ABS_MT_DISTANCE - if (!strcmp(name, "Abs MT Distance")) { - fh->evmap[v->number] = ABS_MT_DISTANCE; + set_field(fh, name, v->number, ABS_MT_DISTANCE) { s->use_distance = 1; } #endif |