diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/Makefile.am | 4 | ||||
| -rw-r--r-- | tools/common-defs.h | 83 | ||||
| -rw-r--r-- | tools/utouch-frame-test-mtdev.c | 62 | ||||
| -rw-r--r-- | tools/utouch-frame-test-xi2.c | 67 |
4 files changed, 90 insertions, 126 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am index 3b612cc..50027fb 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am | |||
| @@ -2,7 +2,7 @@ bin_PROGRAMS = utouch-frame-test-mtdev | |||
| 2 | 2 | ||
| 3 | INCLUDES=-I$(top_srcdir)/include/ | 3 | INCLUDES=-I$(top_srcdir)/include/ |
| 4 | 4 | ||
| 5 | utouch_frame_test_mtdev_SOURCES = utouch-frame-test-mtdev.c | 5 | utouch_frame_test_mtdev_SOURCES = common-defs.h utouch-frame-test-mtdev.c |
| 6 | utouch_frame_test_mtdev_LDFLAGS = -L$(top_builddir)/src/.libs/ \ | 6 | utouch_frame_test_mtdev_LDFLAGS = -L$(top_builddir)/src/.libs/ \ |
| 7 | -lutouch-frame -lutouch-evemu -lmtdev -lm | 7 | -lutouch-frame -lutouch-evemu -lmtdev -lm |
| 8 | 8 | ||
| @@ -12,7 +12,7 @@ AM_CFLAGS = $(XINPUT_CFLAGS) | |||
| 12 | 12 | ||
| 13 | bin_PROGRAMS += utouch-frame-test-xi2 | 13 | bin_PROGRAMS += utouch-frame-test-xi2 |
| 14 | 14 | ||
| 15 | utouch_frame_test_xi2_SOURCES = utouch-frame-test-xi2.c | 15 | utouch_frame_test_xi2_SOURCES = common-defs.h utouch-frame-test-xi2.c |
| 16 | utouch_frame_test_xi2_LDFLAGS = $(XINPUT_LIBS) $(X11_LIBS) \ | 16 | utouch_frame_test_xi2_LDFLAGS = $(XINPUT_LIBS) $(X11_LIBS) \ |
| 17 | -L$(top_builddir)/src/.libs/ -lutouch-frame | 17 | -L$(top_builddir)/src/.libs/ -lutouch-frame |
| 18 | 18 | ||
diff --git a/tools/common-defs.h b/tools/common-defs.h new file mode 100644 index 0000000..0e08bc5 --- /dev/null +++ b/tools/common-defs.h | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * | ||
| 3 | * utouch-frame - Touch Frame Library | ||
| 4 | * | ||
| 5 | * Copyright (C) 2010-2011 Canonical Ltd. | ||
| 6 | * | ||
| 7 | * This program is free software: you can redistribute it and/or modify it | ||
| 8 | * under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation, either version 3 of the License, or (at your | ||
| 10 | * option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along | ||
| 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | * Authors: | ||
| 21 | * Henrik Rydberg <rydberg@bitmath.org> | ||
| 22 | * | ||
| 23 | ****************************************************************************/ | ||
| 24 | |||
| 25 | static void report_device_caps(utouch_frame_handle fh) | ||
| 26 | { | ||
| 27 | const struct utouch_surface *s = utouch_frame_get_surface(fh); | ||
| 28 | |||
| 29 | fprintf(stderr, "device props:\n"); | ||
| 30 | if (s->needs_pointer) | ||
| 31 | fprintf(stderr, "\tpointer\n"); | ||
| 32 | if (s->is_direct) | ||
| 33 | fprintf(stderr, "\tdirect\n"); | ||
| 34 | if (s->is_buttonpad) | ||
| 35 | fprintf(stderr, "\tbuttonpad\n"); | ||
| 36 | if (s->is_semi_mt) | ||
| 37 | fprintf(stderr, "\tsemi_mt\n"); | ||
| 38 | fprintf(stderr, "device mt events:\n"); | ||
| 39 | if (s->use_touch_major) | ||
| 40 | fprintf(stderr, "\ttouch_major\n"); | ||
| 41 | if (s->use_touch_minor) | ||
| 42 | fprintf(stderr, "\ttouch_minor\n"); | ||
| 43 | if (s->use_width_major) | ||
| 44 | fprintf(stderr, "\twidth_major\n"); | ||
| 45 | if (s->use_width_minor) | ||
| 46 | fprintf(stderr, "\twidth_minor\n"); | ||
| 47 | if (s->use_orientation) | ||
| 48 | fprintf(stderr, "\torientation\n"); | ||
| 49 | if (s->use_pressure) | ||
| 50 | fprintf(stderr, "\tpressure\n"); | ||
| 51 | if (s->use_distance) | ||
| 52 | fprintf(stderr, "\tdistance\n"); | ||
| 53 | } | ||
| 54 | |||
| 55 | static void report_frame(const struct utouch_frame *frame) | ||
| 56 | { | ||
| 57 | int i; | ||
| 58 | |||
| 59 | for (i = 0; i < frame->num_active; i++) { | ||
| 60 | const struct utouch_contact *t = frame->active[i]; | ||
| 61 | |||
| 62 | fprintf(stderr, "touch %d\n", i); | ||
| 63 | fprintf(stderr, " slot: %d\n", t->slot); | ||
| 64 | fprintf(stderr, " id: %d\n", t->id); | ||
| 65 | fprintf(stderr, " tool_type: %d\n", t->tool_type); | ||
| 66 | fprintf(stderr, " x: %f\n", t->x); | ||
| 67 | fprintf(stderr, " y: %f\n", t->y); | ||
| 68 | fprintf(stderr, " touch_major: %f\n", t->touch_major); | ||
| 69 | fprintf(stderr, " touch_minor: %f\n", t->touch_minor); | ||
| 70 | fprintf(stderr, " width_major: %f\n", t->width_major); | ||
| 71 | fprintf(stderr, " width_minor: %f\n", t->width_minor); | ||
| 72 | fprintf(stderr, " angle: %f\n", t->orientation); | ||
| 73 | fprintf(stderr, " pressure: %f\n", t->pressure); | ||
| 74 | fprintf(stderr, " distance: %f\n", t->distance); | ||
| 75 | } | ||
| 76 | |||
| 77 | fprintf(stderr, "sync %d %ld %d %d %d\n", | ||
| 78 | frame->num_active, | ||
| 79 | frame->time, | ||
| 80 | frame->sequence_id, | ||
| 81 | frame->revision, | ||
| 82 | frame->slot_revision); | ||
| 83 | } | ||
diff --git a/tools/utouch-frame-test-mtdev.c b/tools/utouch-frame-test-mtdev.c index 86f5b64..4838f84 100644 --- a/tools/utouch-frame-test-mtdev.c +++ b/tools/utouch-frame-test-mtdev.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <stdio.h> | 30 | #include <stdio.h> |
| 31 | #include <unistd.h> | 31 | #include <unistd.h> |
| 32 | #include <fcntl.h> | 32 | #include <fcntl.h> |
| 33 | #include "common-defs.h" | ||
| 33 | 34 | ||
| 34 | struct frame_test { | 35 | struct frame_test { |
| 35 | struct evemu_device *evemu; | 36 | struct evemu_device *evemu; |
| @@ -69,36 +70,6 @@ static void destroy_all(struct frame_test *test) | |||
| 69 | memset(test, 0, sizeof(*test)); | 70 | memset(test, 0, sizeof(*test)); |
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | static void report_frame(const struct utouch_frame *frame) | ||
| 73 | { | ||
| 74 | int i; | ||
| 75 | |||
| 76 | for (i = 0; i < frame->num_active; i++) { | ||
| 77 | const struct utouch_contact *t = frame->active[i]; | ||
| 78 | |||
| 79 | fprintf(stderr, "touch %d\n", i); | ||
| 80 | fprintf(stderr, " slot: %d\n", t->slot); | ||
| 81 | fprintf(stderr, " id: %d\n", t->id); | ||
| 82 | fprintf(stderr, " tool_type: %d\n", t->tool_type); | ||
| 83 | fprintf(stderr, " x: %f\n", t->x); | ||
| 84 | fprintf(stderr, " y: %f\n", t->y); | ||
| 85 | fprintf(stderr, " touch_major: %f\n", t->touch_major); | ||
| 86 | fprintf(stderr, " touch_minor: %f\n", t->touch_minor); | ||
| 87 | fprintf(stderr, " width_major: %f\n", t->width_major); | ||
| 88 | fprintf(stderr, " width_minor: %f\n", t->width_minor); | ||
| 89 | fprintf(stderr, " angle: %f\n", t->orientation); | ||
| 90 | fprintf(stderr, " pressure: %f\n", t->pressure); | ||
| 91 | fprintf(stderr, " distance: %f\n", t->distance); | ||
| 92 | } | ||
| 93 | |||
| 94 | fprintf(stderr, "sync %d %ld %d %d %d\n", | ||
| 95 | frame->num_active, | ||
| 96 | frame->time, | ||
| 97 | frame->sequence_id, | ||
| 98 | frame->revision, | ||
| 99 | frame->slot_revision); | ||
| 100 | } | ||
| 101 | |||
| 102 | static void loop_device(struct frame_test *test, int fd) | 73 | static void loop_device(struct frame_test *test, int fd) |
| 103 | { | 74 | { |
| 104 | const struct utouch_frame *frame; | 75 | const struct utouch_frame *frame; |
| @@ -113,35 +84,6 @@ static void loop_device(struct frame_test *test, int fd) | |||
| 113 | } | 84 | } |
| 114 | } | 85 | } |
| 115 | 86 | ||
| 116 | static void report_device_caps(struct frame_test *test) | ||
| 117 | { | ||
| 118 | struct utouch_surface *s = utouch_frame_get_surface(test->fh); | ||
| 119 | fprintf(stderr, "device props:\n"); | ||
| 120 | if (s->needs_pointer) | ||
| 121 | fprintf(stderr, "\tpointer\n"); | ||
| 122 | if (s->is_direct) | ||
| 123 | fprintf(stderr, "\tdirect\n"); | ||
| 124 | if (s->is_buttonpad) | ||
| 125 | fprintf(stderr, "\tbuttonpad\n"); | ||
| 126 | if (s->is_semi_mt) | ||
| 127 | fprintf(stderr, "\tsemi_mt\n"); | ||
| 128 | fprintf(stderr, "device mt events:\n"); | ||
| 129 | if (s->use_touch_major) | ||
| 130 | fprintf(stderr, "\ttouch_major\n"); | ||
| 131 | if (s->use_touch_minor) | ||
| 132 | fprintf(stderr, "\ttouch_minor\n"); | ||
| 133 | if (s->use_width_major) | ||
| 134 | fprintf(stderr, "\twidth_major\n"); | ||
| 135 | if (s->use_width_minor) | ||
| 136 | fprintf(stderr, "\twidth_minor\n"); | ||
| 137 | if (s->use_orientation) | ||
| 138 | fprintf(stderr, "\torientation\n"); | ||
| 139 | if (s->use_pressure) | ||
| 140 | fprintf(stderr, "\tpressure\n"); | ||
| 141 | if (s->use_distance) | ||
| 142 | fprintf(stderr, "\tdistance\n"); | ||
| 143 | } | ||
| 144 | |||
| 145 | int main(int argc, char *argv[]) | 87 | int main(int argc, char *argv[]) |
| 146 | { | 88 | { |
| 147 | struct frame_test test; | 89 | struct frame_test test; |
| @@ -182,7 +124,7 @@ int main(int argc, char *argv[]) | |||
| 182 | return -1; | 124 | return -1; |
| 183 | } | 125 | } |
| 184 | 126 | ||
| 185 | report_device_caps(&test); | 127 | report_device_caps(test.fh); |
| 186 | 128 | ||
| 187 | loop_device(&test, fd); | 129 | loop_device(&test, fd); |
| 188 | 130 | ||
diff --git a/tools/utouch-frame-test-xi2.c b/tools/utouch-frame-test-xi2.c index df68c1a..015c119 100644 --- a/tools/utouch-frame-test-xi2.c +++ b/tools/utouch-frame-test-xi2.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <unistd.h> | 30 | #include <unistd.h> |
| 31 | #include <fcntl.h> | 31 | #include <fcntl.h> |
| 32 | #include <stdlib.h> | 32 | #include <stdlib.h> |
| 33 | #include "common-defs.h" | ||
| 33 | 34 | ||
| 34 | static int opcode; | 35 | static int opcode; |
| 35 | 36 | ||
| @@ -91,68 +92,6 @@ static void destroy_all(struct frame_test *test) | |||
| 91 | memset(test, 0, sizeof(*test)); | 92 | memset(test, 0, sizeof(*test)); |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 94 | static void report_device_caps(struct frame_test *test) | ||
| 95 | { | ||
| 96 | struct utouch_surface *s = utouch_frame_get_surface(test->fh); | ||
| 97 | fprintf(stderr, "device props:\n"); | ||
| 98 | if (s->needs_pointer) | ||
| 99 | fprintf(stderr, "\tpointer\n"); | ||
| 100 | if (s->is_direct) | ||
| 101 | fprintf(stderr, "\tdirect\n"); | ||
| 102 | if (s->is_buttonpad) | ||
| 103 | fprintf(stderr, "\tbuttonpad\n"); | ||
| 104 | if (s->is_semi_mt) | ||
| 105 | fprintf(stderr, "\tsemi_mt\n"); | ||
| 106 | fprintf(stderr, "device mt events:\n"); | ||
| 107 | if (s->use_touch_major) | ||
| 108 | fprintf(stderr, "\ttouch_major\n"); | ||
| 109 | if (s->use_touch_minor) | ||
| 110 | fprintf(stderr, "\ttouch_minor\n"); | ||
| 111 | if (s->use_width_major) | ||
| 112 | fprintf(stderr, "\twidth_major\n"); | ||
| 113 | if (s->use_width_minor) | ||
| 114 | fprintf(stderr, "\twidth_minor\n"); | ||
| 115 | if (s->use_orientation) | ||
| 116 | fprintf(stderr, "\torientation\n"); | ||
| 117 | if (s->use_pressure) | ||
| 118 | fprintf(stderr, "\tpressure\n"); | ||
| 119 | if (s->use_distance) | ||
| 120 | fprintf(stderr, "\tdistance\n"); | ||
| 121 | } | ||
| 122 | |||
| 123 | static void report_frame(const struct utouch_frame *frame, | ||
| 124 | const XIDeviceEvent *ev) | ||
| 125 | { | ||
| 126 | int i; | ||
| 127 | |||
| 128 | for (i = 0; i < frame->num_active; i++) { | ||
| 129 | const struct utouch_contact *t = frame->active[i]; | ||
| 130 | |||
| 131 | fprintf(stderr, "touch %d\n", i); | ||
| 132 | fprintf(stderr, " slot: %d\n", t->slot); | ||
| 133 | fprintf(stderr, " id: %d\n", t->id); | ||
| 134 | fprintf(stderr, " tool_type: %d\n", t->tool_type); | ||
| 135 | fprintf(stderr, " x: %f\n", t->x); | ||
| 136 | fprintf(stderr, " y: %f\n", t->y); | ||
| 137 | fprintf(stderr, " touch_major: %f\n", t->touch_major); | ||
| 138 | fprintf(stderr, " touch_minor: %f\n", t->touch_minor); | ||
| 139 | fprintf(stderr, " width_major: %f\n", t->width_major); | ||
| 140 | fprintf(stderr, " width_minor: %f\n", t->width_minor); | ||
| 141 | fprintf(stderr, " angle: %f\n", t->orientation); | ||
| 142 | fprintf(stderr, " pressure: %f\n", t->pressure); | ||
| 143 | fprintf(stderr, " distance: %f\n", t->distance); | ||
| 144 | } | ||
| 145 | |||
| 146 | fprintf(stderr, "sync %d %ld %d %d %d %f %f\n", | ||
| 147 | frame->num_active, | ||
| 148 | frame->time, | ||
| 149 | frame->sequence_id, | ||
| 150 | frame->revision, | ||
| 151 | frame->slot_revision, | ||
| 152 | ev->root_x, | ||
| 153 | ev->root_y); | ||
| 154 | } | ||
| 155 | |||
| 156 | static void handle_event(struct frame_test *test, XEvent *ev) | 95 | static void handle_event(struct frame_test *test, XEvent *ev) |
| 157 | { | 96 | { |
| 158 | XGenericEventCookie *gev = &ev->xcookie; | 97 | XGenericEventCookie *gev = &ev->xcookie; |
| @@ -175,7 +114,7 @@ static void handle_event(struct frame_test *test, XEvent *ev) | |||
| 175 | if (gev->type == GenericEvent && gev->extension == opcode) { | 114 | if (gev->type == GenericEvent && gev->extension == opcode) { |
| 176 | frame = utouch_frame_pump_xi2(test->fh, dev); | 115 | frame = utouch_frame_pump_xi2(test->fh, dev); |
| 177 | if (frame) | 116 | if (frame) |
| 178 | report_frame(frame, dev); | 117 | report_frame(frame); |
| 179 | } | 118 | } |
| 180 | XFreeEventData(test->display, gev); | 119 | XFreeEventData(test->display, gev); |
| 181 | break; | 120 | break; |
| @@ -229,7 +168,7 @@ int main(int argc, char *argv[]) | |||
| 229 | return -1; | 168 | return -1; |
| 230 | } | 169 | } |
| 231 | 170 | ||
| 232 | report_device_caps(&test); | 171 | report_device_caps(test.fh); |
| 233 | 172 | ||
| 234 | loop_device(&test); | 173 | loop_device(&test); |
| 235 | 174 | ||
