1
/*****************************************************************************
3
* grail - Gesture Recognition And Instantiation Library
5
* Copyright (C) 2010 Canonical Ltd.
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.
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.
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/>.
21
* Henrik Rydberg <rydberg@bitmath.org>
23
****************************************************************************/
25
#include <grail-touch.h>
31
static void tp_event(struct touch_dev *dev,
32
const struct input_event *ev)
34
fprintf(stderr, "event %d 0x%x %d\n", ev->type, ev->code, ev->value);
37
static void tp_sync(struct touch_dev *dev,
38
const struct input_event *syn)
40
struct touch_frame *frame = &dev->frame;
42
for (i = 0; i < frame->nactive; i++) {
43
struct touch *t = frame->active[i];
44
fprintf(stderr, "touch %d\n", i);
45
fprintf(stderr, " slot: %d\n", t->slot);
46
fprintf(stderr, " id: %d\n", t->id);
47
fprintf(stderr, " tool_type: %d\n", t->tool_type);
48
fprintf(stderr, " x: %d\n", t->x);
49
fprintf(stderr, " y: %d\n", t->y);
50
fprintf(stderr, " touch_major: %d\n", t->touch_major);
51
fprintf(stderr, " touch_minor: %d\n", t->touch_minor);
52
fprintf(stderr, " width_major: %d\n", t->width_major);
53
fprintf(stderr, " width_minor: %d\n", t->width_minor);
54
fprintf(stderr, " angle: %f\n",
55
touch_angle(dev, t->orientation));
56
fprintf(stderr, " pressure: %f\n",
57
touch_pressure(dev, t->pressure));
59
fprintf(stderr, "sync %d %lld %d %d\n",
60
frame->nactive, frame->time, frame->ncreate, frame->ndestroy);
63
static void loop_device(struct touch_dev *dev, int fd)
65
dev->event = tp_event;
67
while (!touch_dev_idle(dev, fd, 5000))
68
touch_dev_pull(dev, fd);
71
int main(int argc, char *argv[])
76
fprintf(stderr, "Usage: %s <device>\n", argv[0]);
79
fd = open(argv[1], O_RDONLY | O_NONBLOCK);
81
fprintf(stderr, "error: could not open device\n");
84
if (ioctl(fd, EVIOCGRAB, 1)) {
85
fprintf(stderr, "error: could not grab the device\n");
88
if (touch_dev_open(&dev, fd)) {
89
fprintf(stderr, "error: could not open touch device\n");
92
loop_device(&dev, fd);
93
touch_dev_close(&dev, fd);
94
ioctl(fd, EVIOCGRAB, 0);