1 /***************************************************************************
4 * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
5 * Copyright (C) 2011 Ryan Bourgeois <bluedragonx@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 **************************************************************************/
27 void xf86Msg(int type, const char *format, ...)
30 va_start(args, format);
31 vfprintf(stderr, format, args);
35 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) <= 13
36 typedef XF86OptionPtr pointer;
39 int xf86SetIntOption(XF86OptionPtr opts, const char *name, int deflt)
44 int xf86SetBoolOption(XF86OptionPtr opts, const char *name, int deflt)
49 double xf86SetRealOption(XF86OptionPtr opts, const char *name, double deflt)
54 static void print_gestures(const struct Gestures* gs)
57 static bitmask_t buttons_prev = 0U;
58 for (i = 0; i < 32; i++) {
59 if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i))
62 if (GETBIT(gs->buttons, i))
63 printf("button %d down\n", i+1);
65 printf("button %d up\n", i+1);
68 if (gs->move_dx != 0 || gs->move_dy != 0)
69 printf("moving (%+4d, %+4d)\n", gs->move_dx, gs->move_dy);
71 buttons_prev = gs->buttons;
74 static void loop_device(int fd)
77 if (mtouch_configure(&mt, fd)) {
78 fprintf(stderr, "error: could not configure device\n");
81 if (mtouch_open(&mt, fd)) {
82 fprintf(stderr, "error: could not open device\n");
86 mconfig_defaults(&mt.cfg);
87 printf("width: %d\n", mt.hs.max_x);
88 printf("height: %d\n", mt.hs.max_y);
90 //while (!mtdev_idle(&mt.dev, fd, 5000)) {
92 while (mtouch_read(&mt) > 0)
93 print_gestures(&mt.gs);
94 if (mtouch_delayed(&mt))
95 print_gestures(&mt.gs);
100 int main(int argc, char *argv[])
103 fprintf(stderr, "Usage: test <mtdev>\n");
106 int fd = open(argv[1], O_RDONLY | O_NONBLOCK);
108 fprintf(stderr, "error: could not open file\n");