diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile.am | 5 | ||||
| -rw-r--r-- | test/evlink.c | 96 | ||||
| -rw-r--r-- | test/grail.c | 7 | ||||
| -rw-r--r-- | test/touch.c | 7 |
4 files changed, 108 insertions, 7 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index c8404f8..a24f615 100644 --- a/test/Makefile.am +++ b/test/Makefile.am | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | noinst_PROGRAMS = touch grail | 1 | noinst_PROGRAMS = touch grail evlink |
| 2 | 2 | ||
| 3 | INCLUDES=-I$(top_srcdir)/include/ | 3 | INCLUDES=-I$(top_srcdir)/include/ |
| 4 | 4 | ||
| @@ -7,3 +7,6 @@ touch_LDFLAGS = -L$(top_builddir)/src/.libs/ -lgrail -lmtdev | |||
| 7 | 7 | ||
| 8 | grail_SOURCES = grail.c | 8 | grail_SOURCES = grail.c |
| 9 | grail_LDFLAGS = -L$(top_builddir)/src/.libs/ -lgrail -lmtdev | 9 | grail_LDFLAGS = -L$(top_builddir)/src/.libs/ -lgrail -lmtdev |
| 10 | |||
| 11 | evlink_SOURCES = evlink.c | ||
| 12 | evlink_LDFLAGS = -L$(top_builddir)/src/.libs/ -lgrail -lmtdev | ||
diff --git a/test/evlink.c b/test/evlink.c new file mode 100644 index 0000000..bef5e22 --- /dev/null +++ b/test/evlink.c | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * | ||
| 3 | * grail - Gesture Recognition And Instantiation Library | ||
| 4 | * | ||
| 5 | * Copyright (C) 2010 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 | #include <grail.h> | ||
| 26 | #include <string.h> | ||
| 27 | #include <stdio.h> | ||
| 28 | #include <unistd.h> | ||
| 29 | #include <fcntl.h> | ||
| 30 | |||
| 31 | static int tp_get_clients(int x, int y, int screen, | ||
| 32 | grail_clientid_t *clients, int nclients) | ||
| 33 | { | ||
| 34 | return 0; | ||
| 35 | } | ||
| 36 | |||
| 37 | static void tp_event(struct grail *ge, const struct input_event *ev) | ||
| 38 | { | ||
| 39 | fprintf(stderr, "event %d %d %d\n", ev->type, ev->code, ev->value); | ||
| 40 | } | ||
| 41 | |||
| 42 | static void tp_gesture(struct grail *ge, const struct grail_event *ev) | ||
| 43 | { | ||
| 44 | fprintf(stderr, "gesture %d %d\n", ev->type, ev->id); | ||
| 45 | } | ||
| 46 | |||
| 47 | static void loop_device(struct grail *ge, int fd) | ||
| 48 | { | ||
| 49 | while (!grail_idle(ge, fd, 5000)) | ||
| 50 | grail_pull(ge, fd); | ||
| 51 | } | ||
| 52 | |||
| 53 | #if 0 | ||
| 54 | void grail_add_client(struct grail *ge, grail_clientid_t id, | ||
| 55 | const int *types, const int *priority, int ntypes); | ||
| 56 | void grail_remove_client(struct grail *ge, grail_clientid_t id); | ||
| 57 | |||
| 58 | #endif | ||
| 59 | |||
| 60 | |||
| 61 | int main(int argc, char *argv[]) | ||
| 62 | { | ||
| 63 | struct grail ge; | ||
| 64 | int fd; | ||
| 65 | |||
| 66 | if (argc < 2) { | ||
| 67 | fprintf(stderr, "Usage: %s <device>\n", argv[0]); | ||
| 68 | return -1; | ||
| 69 | } | ||
| 70 | |||
| 71 | memset(&ge, 0, sizeof(ge)); | ||
| 72 | ge.get_clients = tp_get_clients; | ||
| 73 | ge.event = tp_event; | ||
| 74 | ge.gesture = tp_gesture; | ||
| 75 | |||
| 76 | fd = open(argv[1], O_RDONLY | O_NONBLOCK); | ||
| 77 | if (fd < 0) { | ||
| 78 | fprintf(stderr, "error: could not open device\n"); | ||
| 79 | return -1; | ||
| 80 | } | ||
| 81 | if (ioctl(fd, EVIOCGRAB, 1)) { | ||
| 82 | fprintf(stderr, "error: could not grab the device\n"); | ||
| 83 | return -1; | ||
| 84 | } | ||
| 85 | |||
| 86 | if (grail_open(&ge, fd)) { | ||
| 87 | fprintf(stderr, "error: could not open touch device\n"); | ||
| 88 | return -1; | ||
| 89 | } | ||
| 90 | loop_device(&ge, fd); | ||
| 91 | grail_close(&ge, fd); | ||
| 92 | |||
| 93 | ioctl(fd, EVIOCGRAB, 0); | ||
| 94 | close(fd); | ||
| 95 | return 0; | ||
| 96 | } | ||
diff --git a/test/grail.c b/test/grail.c index 82de65f..e22ffd8 100644 --- a/test/grail.c +++ b/test/grail.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | * | 22 | * |
| 23 | ****************************************************************************/ | 23 | ****************************************************************************/ |
| 24 | 24 | ||
| 25 | #include <grail.h> | 25 | #include <grail-gesture.h> |
| 26 | #include <string.h> | 26 | #include <string.h> |
| 27 | #include <stdio.h> | 27 | #include <stdio.h> |
| 28 | #include <unistd.h> | 28 | #include <unistd.h> |
| @@ -133,7 +133,8 @@ static void tp_event(struct touch_engine *engine, | |||
| 133 | { | 133 | { |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | static void tp_sync(struct touch_engine *engine) | 136 | static void tp_sync(struct touch_engine *engine, |
| 137 | const struct input_event *syn) | ||
| 137 | { | 138 | { |
| 138 | struct gesture_handler *gh = engine->priv; | 139 | struct gesture_handler *gh = engine->priv; |
| 139 | struct touch_frame *frame = &engine->frame; | 140 | struct touch_frame *frame = &engine->frame; |
| @@ -158,7 +159,7 @@ int main(int argc, char *argv[]) | |||
| 158 | struct touch_dev dev; | 159 | struct touch_dev dev; |
| 159 | int fd; | 160 | int fd; |
| 160 | if (argc < 2) { | 161 | if (argc < 2) { |
| 161 | fprintf(stderr, "Usage: mtdev <device>\n"); | 162 | fprintf(stderr, "Usage: %s <device>\n", argv[0]); |
| 162 | return -1; | 163 | return -1; |
| 163 | } | 164 | } |
| 164 | fd = open(argv[1], O_RDONLY | O_NONBLOCK); | 165 | fd = open(argv[1], O_RDONLY | O_NONBLOCK); |
diff --git a/test/touch.c b/test/touch.c index 1f9213d..bc10b54 100644 --- a/test/touch.c +++ b/test/touch.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | * | 22 | * |
| 23 | ****************************************************************************/ | 23 | ****************************************************************************/ |
| 24 | 24 | ||
| 25 | #include <grail.h> | 25 | #include <grail-touch.h> |
| 26 | #include <string.h> | 26 | #include <string.h> |
| 27 | #include <stdio.h> | 27 | #include <stdio.h> |
| 28 | #include <unistd.h> | 28 | #include <unistd.h> |
| @@ -34,7 +34,8 @@ static void tp_event(struct touch_engine *engine, | |||
| 34 | fprintf(stderr, "event %d %d %d\n", ev->type, ev->code, ev->value); | 34 | fprintf(stderr, "event %d %d %d\n", ev->type, ev->code, ev->value); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | static void tp_sync(struct touch_engine *engine) | 37 | static void tp_sync(struct touch_engine *engine, |
| 38 | const struct input_event *syn) | ||
| 38 | { | 39 | { |
| 39 | struct touch_frame *frame = &engine->frame; | 40 | struct touch_frame *frame = &engine->frame; |
| 40 | int slot, i; | 41 | int slot, i; |
| @@ -62,7 +63,7 @@ int main(int argc, char *argv[]) | |||
| 62 | struct touch_dev dev; | 63 | struct touch_dev dev; |
| 63 | int fd; | 64 | int fd; |
| 64 | if (argc < 2) { | 65 | if (argc < 2) { |
| 65 | fprintf(stderr, "Usage: mtdev <device>\n"); | 66 | fprintf(stderr, "Usage: %s <device>\n", argv[0]); |
| 66 | return -1; | 67 | return -1; |
| 67 | } | 68 | } |
| 68 | fd = open(argv[1], O_RDONLY | O_NONBLOCK); | 69 | fd = open(argv[1], O_RDONLY | O_NONBLOCK); |
