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 **************************************************************************/
28 void xf86Msg(int type, const char *format, ...)
31 va_start(args, format);
32 vfprintf(stderr, format, args);
36 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) <= 13
37 typedef XF86OptionPtr pointer;
40 int xf86SetIntOption(XF86OptionPtr opts, const char *name, int deflt)
45 int xf86SetBoolOption(XF86OptionPtr opts, const char *name, int deflt)
50 double xf86SetRealOption(XF86OptionPtr opts, const char *name, double deflt)
55 static void print_gestures(const struct Gestures* gs)
58 static bitmask_t buttons_prev = 0U;
59 for (i = 0; i < 32; i++) {
60 if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i))
63 if (GETBIT(gs->buttons, i))
64 printf("button %d down\n", i+1);
66 printf("button %d up\n", i+1);
69 if (gs->move_dx != 0 || gs->move_dy != 0)
70 printf("moving (%+4d, %+4d)\n", gs->move_dx, gs->move_dy);
72 buttons_prev = gs->buttons;
75 static void loop_device(int fd)
78 if (mtouch_configure(&mt, fd)) {
79 fprintf(stderr, "error: could not configure device\n");
82 if (mtouch_open(&mt, fd)) {
83 fprintf(stderr, "error: could not open device\n");
87 mconfig_defaults(&mt.cfg);
88 printf("width: %d\n", mt.hs.max_x);
89 printf("height: %d\n", mt.hs.max_y);
91 //while (!mtdev_idle(&mt.dev, fd, 5000)) {
93 while (mtouch_read(&mt) > 0)
94 print_gestures(&mt.gs);
95 if (mtouch_delayed(&mt))
96 print_gestures(&mt.gs);
101 int main(int argc, char *argv[])
104 fprintf(stderr, "Usage: test <mtdev>\n");
107 int fd = open(argv[1], O_RDONLY | O_NONBLOCK);
109 fprintf(stderr, "error: could not open file\n");