1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
/*
* tslib/tests/ts_print_raw.c
*
* Copyright (C) 2002 Douglas Lowder
* Just prints touchscreen events -- does not paint them on framebuffer
*
* This file is placed under the GPL. Please see the file
* COPYING for more details.
*
* SPDX-License-Identifier: GPL-2.0+
*
*
* Basic test program for touchscreen library.
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <errno.h>
#include "tslib.h"
static void usage(void)
{
ts_print_ascii_logo(16);
printf("%s", tslib_version());
printf("\n");
printf("-h --help\n");
printf(" print this help text\n");
printf("-v --version\n");
printf(" print version information only\n");
}
int main(int argc, char **argv)
{
struct tsdev *ts;
while (1) {
const struct option long_options[] = {
{ "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
};
int option_index = 0;
int c = getopt_long(argc, argv, "vh", long_options, &option_index);
errno = 0;
if (c == -1)
break;
switch (c) {
case 'v':
printf("%s", tslib_version());
return 0;
case 'h':
usage();
return 0;
default:
usage();
return 0;
}
}
ts = ts_setup(NULL, 0);
if (!ts) {
perror("ts_setup");
exit(1);
}
while (1) {
struct ts_sample samp;
int ret;
ret = ts_read_raw(ts, &samp, 1);
if (ret < 0) {
perror("ts_read_raw");
ts_close(ts);
exit(1);
}
if (ret != 1)
continue;
printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
}
ts_close(ts);
}
|