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
****************************************************************************/
31
static void tp_sync(struct touch_engine *engine, touch_time_t time)
33
struct touch_frame *frame = &engine->frame;
35
fprintf(stderr, "sync %d %lld\n", frame->ntouch, time);
36
for (slot = frame->slot; slot >= 0; slot = next_slot(frame, slot)) {
37
struct touch *touch = &frame->touch[slot];
38
fprintf(stderr, "touch %d\n", slot);
39
for (i = 0; i < DIM_TOUCH_PROP; i++)
40
fprintf(stderr, " %d\n", touch->prop[i]);
44
static void loop_device(struct touch_dev *dev, int fd)
46
struct touch_engine engine;
47
touch_engine_init(&engine, tp_sync, 0);
48
touch_engine_attach(&engine, dev);
49
while (!touch_dev_idle(dev, fd, 5000))
50
touch_dev_pull(dev, fd);
51
touch_engine_detach(&engine, dev);
54
int main(int argc, char *argv[])
59
fprintf(stderr, "Usage: mtdev <device>\n");
62
fd = open(argv[1], O_RDONLY | O_NONBLOCK);
64
fprintf(stderr, "error: could not open device\n");
67
if (ioctl(fd, EVIOCGRAB, 1)) {
68
fprintf(stderr, "error: could not grab the device\n");
71
if (touch_dev_open(&dev, fd)) {
72
fprintf(stderr, "error: could not open touch device\n");
75
loop_device(&dev, fd);
76
touch_dev_close(&dev, fd);
77
ioctl(fd, EVIOCGRAB, 0);