diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 15 | ||||
-rw-r--r-- | test/Makefile.in | 601 | ||||
-rw-r--r-- | test/mtdev-kernel.c | 158 | ||||
-rw-r--r-- | test/mtdev-mapgen.c | 80 | ||||
-rw-r--r-- | test/mtdev-matching.c | 174 | ||||
-rw-r--r-- | test/mtdev-test.c | 120 |
6 files changed, 1148 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..0cdd859 --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,15 @@ +noinst_PROGRAMS = mtdev-mapgen mtdev-matching mtdev-kernel +bin_PROGRAMS = mtdev-test + +INCLUDES=-I$(top_srcdir)/include/ + +mtdev_mapgen_SOURCES = mtdev-mapgen.c + +mtdev_matching_SOURCES = mtdev-matching.c +mtdev_matching_LDFLAGS = -L$(top_builddir)/src/.libs/ -lmtdev + +mtdev_test_SOURCES = mtdev-test.c +mtdev_test_LDFLAGS = -lmtdev -L$(top_builddir)/src/.libs/ + +mtdev_kernel_SOURCES = mtdev-kernel.c +mtdev_kernel_LDFLAGS = -L$(top_builddir)/src/.libs/ -lmtdev diff --git a/test/Makefile.in b/test/Makefile.in new file mode 100644 index 0000000..b64f869 --- /dev/null +++ b/test/Makefile.in @@ -0,0 +1,601 @@ +# Makefile.in generated by automake 1.12.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2012 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = mtdev-mapgen$(EXEEXT) mtdev-matching$(EXEEXT) \ + mtdev-kernel$(EXEEXT) +bin_PROGRAMS = mtdev-test$(EXEEXT) +subdir = test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/config-aux/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) +am_mtdev_kernel_OBJECTS = mtdev-kernel.$(OBJEXT) +mtdev_kernel_OBJECTS = $(am_mtdev_kernel_OBJECTS) +mtdev_kernel_LDADD = $(LDADD) +mtdev_kernel_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(mtdev_kernel_LDFLAGS) $(LDFLAGS) -o $@ +am_mtdev_mapgen_OBJECTS = mtdev-mapgen.$(OBJEXT) +mtdev_mapgen_OBJECTS = $(am_mtdev_mapgen_OBJECTS) +mtdev_mapgen_LDADD = $(LDADD) +am_mtdev_matching_OBJECTS = mtdev-matching.$(OBJEXT) +mtdev_matching_OBJECTS = $(am_mtdev_matching_OBJECTS) +mtdev_matching_LDADD = $(LDADD) +mtdev_matching_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(mtdev_matching_LDFLAGS) $(LDFLAGS) -o $@ +am_mtdev_test_OBJECTS = mtdev-test.$(OBJEXT) +mtdev_test_OBJECTS = $(am_mtdev_test_OBJECTS) +mtdev_test_LDADD = $(LDADD) +mtdev_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(mtdev_test_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/config-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(mtdev_kernel_SOURCES) $(mtdev_mapgen_SOURCES) \ + $(mtdev_matching_SOURCES) $(mtdev_test_SOURCES) +DIST_SOURCES = $(mtdev_kernel_SOURCES) $(mtdev_mapgen_SOURCES) \ + $(mtdev_matching_SOURCES) $(mtdev_test_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_VERSION = @LIB_VERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = -I$(top_srcdir)/include/ +mtdev_mapgen_SOURCES = mtdev-mapgen.c +mtdev_matching_SOURCES = mtdev-matching.c +mtdev_matching_LDFLAGS = -L$(top_builddir)/src/.libs/ -lmtdev +mtdev_test_SOURCES = mtdev-test.c +mtdev_test_LDFLAGS = -lmtdev -L$(top_builddir)/src/.libs/ +mtdev_kernel_SOURCES = mtdev-kernel.c +mtdev_kernel_LDFLAGS = -L$(top_builddir)/src/.libs/ -lmtdev +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign test/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +mtdev-kernel$(EXEEXT): $(mtdev_kernel_OBJECTS) $(mtdev_kernel_DEPENDENCIES) $(EXTRA_mtdev_kernel_DEPENDENCIES) + @rm -f mtdev-kernel$(EXEEXT) + $(mtdev_kernel_LINK) $(mtdev_kernel_OBJECTS) $(mtdev_kernel_LDADD) $(LIBS) +mtdev-mapgen$(EXEEXT): $(mtdev_mapgen_OBJECTS) $(mtdev_mapgen_DEPENDENCIES) $(EXTRA_mtdev_mapgen_DEPENDENCIES) + @rm -f mtdev-mapgen$(EXEEXT) + $(LINK) $(mtdev_mapgen_OBJECTS) $(mtdev_mapgen_LDADD) $(LIBS) +mtdev-matching$(EXEEXT): $(mtdev_matching_OBJECTS) $(mtdev_matching_DEPENDENCIES) $(EXTRA_mtdev_matching_DEPENDENCIES) + @rm -f mtdev-matching$(EXEEXT) + $(mtdev_matching_LINK) $(mtdev_matching_OBJECTS) $(mtdev_matching_LDADD) $(LIBS) +mtdev-test$(EXEEXT): $(mtdev_test_OBJECTS) $(mtdev_test_DEPENDENCIES) $(EXTRA_mtdev_test_DEPENDENCIES) + @rm -f mtdev-test$(EXEEXT) + $(mtdev_test_LINK) $(mtdev_test_OBJECTS) $(mtdev_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtdev-kernel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtdev-mapgen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtdev-matching.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtdev-test.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +cscopelist: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool clean-noinstPROGRAMS cscopelist \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/mtdev-kernel.c b/test/mtdev-kernel.c new file mode 100644 index 0000000..1f33c3e --- /dev/null +++ b/test/mtdev-kernel.c @@ -0,0 +1,158 @@ +/***************************************************************************** + * + * mtdev - Multitouch Protocol Translation Library (MIT license) + * + * Copyright (C) 2010 Henrik Rydberg <rydberg@euromail.se> + * Copyright (C) 2010 Canonical Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + ****************************************************************************/ + +#include <../src/common.h> +#include <stdio.h> +#include <time.h> + +/* + * Combinatorial formulation + * + * x_ij = 1 if slot i and contact j are connected, zero otherwise + * + * sum_i x_ij <= 1 for all j; each contact picks at most one slot + * + * sum_j x_ij <= 1 for all i; each slot is picked by at most one contact + * + * sum_ij x_ij == min(nslot, npos); assign every contact possible + * + * Arrange x_ij as a bitmask; x_00 x_01 x_02.. x_10 x_11 x_12... + * + * Up to five slots, this is readily enumerable. + */ + +#define SLOT_MAX 5 +#define SLOT_CNT (SLOT_MAX + 1) + +static int illegal(int nslot, int npos, unsigned x) +{ + int i, j, sum; + + for (j = 0; j < npos; j++) { + sum = 0; + for (i = 0; i < nslot; i++) + sum += GETBIT(x, i * npos + j); + if (sum > 1) + return 1; + } + for (i = 0; i < nslot; i++) { + sum = 0; + for (j = 0; j < npos; j++) + sum += GETBIT(x, i * npos + j); + if (sum > 1) + return 1; + } + + sum = bitcount(x); + return sum != minval(nslot, npos); +} + +static void get_slots(int *slots, int nslot, int npos, unsigned x) +{ + int i; + + memset(slots, -1, sizeof(slots[0]) * npos); + for (i = 0; i < nslot * npos; i++) + if (GETBIT(x, i)) + slots[i % npos] = i / npos; + for (i = 0; i < npos; i++) + if (slots[i] < 0) + slots[i] = nslot++; +} + +static int generate_assignments(int nslot, int npos) +{ + static int ncol; + unsigned x, nx = BITMASK(nslot * npos); + int slots[SLOT_MAX]; + int i, n = 0; + + for (x = 0; x < nx; x++) { + if (illegal(nslot, npos, x)) + continue; + for (i = 0; i < nslot * npos; i++) { + if (GETBIT(x, i)) { + if (ncol++ % 16 == 0) + printf("\n\t%d,", i); + else + printf(" %d,", i); + n++; + } + } + get_slots(slots, nslot, npos, x); + for (i = 0; i < npos; i++) { + if (ncol++ % 16 == 0) + printf("\n\t%d,", slots[i]); + else + printf(" %d,", slots[i]); + n++; + } + } + + return n; +} + +int main(int argc, char *argv[]) +{ + int ix[SLOT_CNT][SLOT_CNT], nix = 0; + int eslot, i, j; + + if (argc < 2) { + fprintf(stderr, "usage: %s <num_slots>\n", argv[0]); + return 1; + } + + eslot = atoi(argv[1]) + 1; + if (eslot > SLOT_CNT) { + fprintf(stderr, "allowed slot range: 2 - %d\n", SLOT_MAX); + return 1; + } + + printf("\n/* generated by mtdev-kernel - do not edit */\n"); + printf("static const u8 match_data[] = {"); + for (i = 0; i < eslot; i++) { + for (j = 0; j < eslot; j++) { + ix[i][j] = nix; + nix += generate_assignments(i, j); + } + } + printf("\n};\n"); + + printf("\n/* generated by mtdev-kernel - do not edit */\n"); + printf("static const int match_index[][%d] = {\n", eslot); + for (i = 0; i < eslot; i++) { + printf("\t{"); + for (j = 0; j < eslot; j++) + printf(" %d%s", ix[i][j], j < eslot - 1 ? "," : ""); + printf(" },\n"); + } + printf("\t{ %d }\n", nix); + printf("};\n"); + + return 0; +} diff --git a/test/mtdev-mapgen.c b/test/mtdev-mapgen.c new file mode 100644 index 0000000..c34cb7e --- /dev/null +++ b/test/mtdev-mapgen.c @@ -0,0 +1,80 @@ +/***************************************************************************** + * + * mtdev - Multitouch Protocol Translation Library (MIT license) + * + * Copyright (C) 2010 Henrik Rydberg <rydberg@euromail.se> + * Copyright (C) 2010 Canonical Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + ****************************************************************************/ + +#define MTDEV_NO_LEGACY_API +#include <mtdev.h> +#include <stdio.h> + +#define MT_ABS_SIZE 12 +#define MT_SLOT_ABS_EVENTS { \ + ABS_MT_TOUCH_MAJOR, \ + ABS_MT_TOUCH_MINOR, \ + ABS_MT_WIDTH_MAJOR, \ + ABS_MT_WIDTH_MINOR, \ + ABS_MT_ORIENTATION, \ + ABS_MT_POSITION_X, \ + ABS_MT_POSITION_Y, \ + ABS_MT_TOOL_TYPE, \ + ABS_MT_BLOB_ID, \ + ABS_MT_TRACKING_ID, \ + ABS_MT_PRESSURE, \ + ABS_MT_DISTANCE, \ +} + +static unsigned int cabs2mt[ABS_CNT]; +static unsigned int cmt2abs[MT_ABS_SIZE]; + +void init_caps() +{ + static const int init_abs_map[MT_ABS_SIZE] = MT_SLOT_ABS_EVENTS; + int i; + for (i = 0; i < MT_ABS_SIZE; i++) { + cabs2mt[init_abs_map[i]] = i + 1; + cmt2abs[i] = init_abs_map[i]; + } +} + +static inline const char *newln(int i, int n) +{ + return i == n - 1 || i % 8 == 7 ? "\n" : ""; +} + +int main(int argc, char *argv[]) +{ + int i; + init_caps(); + printf("static const unsigned int mtdev_map_abs2mt[ABS_CNT] = {\n"); + for (i = 0; i < ABS_CNT; i++) + printf(" 0x%04x,%s", cabs2mt[i], newln(i, ABS_CNT)); + printf("};\n\n"); + printf("static const unsigned int mtdev_map_mt2abs[MT_ABS_SIZE] = {\n"); + for (i = 0; i < MT_ABS_SIZE; i++) + printf(" 0x%04x,%s", cmt2abs[i], newln(i, MT_ABS_SIZE)); + printf("};\n\n"); + return 0; +} diff --git a/test/mtdev-matching.c b/test/mtdev-matching.c new file mode 100644 index 0000000..799429f --- /dev/null +++ b/test/mtdev-matching.c @@ -0,0 +1,174 @@ +/***************************************************************************** + * + * mtdev - Multitouch Protocol Translation Library (MIT license) + * + * Copyright (C) 2010 Henrik Rydberg <rydberg@euromail.se> + * Copyright (C) 2010 Canonical Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + ****************************************************************************/ + +#include <src/match.h> +#include <stdio.h> +#include <time.h> + +#define ITS 4000000 +const int n1 = 4; +const int n2 = 4; + +static void test1() +{ + int A[] = { + 1013, + 3030660, + 3559354, + 12505925, + 19008450, + 6946421, + 6118613, + 698020, + 3021800, + 1017, + 37573, + 3242018, + 8152794, + 1266053, + 942941, + 462820, + }; + int index[DIM_FINGER], i; + mtdev_match(index, A, 4, 4); + for (i = 0; i < 4; i++) + printf("match[%d] = %d\n", i, index[i]); +} + +static void test2() +{ + int A[] = { + 0, + 4534330, + 22653552, + 12252500, + 685352, + 4534330, + 0, + 9619317, + 28409530, + 6710170, + 22653552, + 9619317, + 0, + 47015292, + 29788572, + 2809040, + 10428866, + 38615920, + 17732500, + 719528, + 12113945, + 28196220, + 46778656, + 405, + 14175493, + }; + int index[DIM_FINGER], i; + mtdev_match(index, A, 5, 5); + for (i = 0; i < 5; i++) + printf("match[%d] = %d\n", i, index[i]); +} + +static void speed1() +{ + /* column-by-column matrix */ + int A[DIM2_FINGER]; + int x1[DIM_FINGER] = { 1, 5, 2, 3, 4, 5, 6, 7, 8 }; + int y1[DIM_FINGER] = { 1, 5, 2, 3, 4, 6, 6, 7, 8 }; + int x2[DIM_FINGER] = { 1, 3, 2, 4, 5, 6, 7, 8 }; + int y2[DIM_FINGER] = { 1, 3, 2, 4, 5, 6, 7, 8 }; + int index[DIM_FINGER]; + int i, j, k; + + clock_t t1 = clock(); + for (k = 0; k < ITS; k++) { + for (i = 0; i < n1; i++) { + for (j = 0; j < n2; j++) { + A[i + n1 * j] = + (x1[i] - x2[j]) * (x1[i] - x2[j]) + + (y1[i] - y2[j]) * (y1[i] - y2[j]); + } + } + mtdev_match(index, A, n1, n2); + } + clock_t t2 = clock(); + + printf("%lf matches per second\n", + ITS * ((float)CLOCKS_PER_SEC / (t2 - t1))); + + for (i = 0; i < n1; i++) + printf("match[%d] = %d\n", i, index[i]); + +} + +static void speed2() +{ + struct trk_coord p1[] = { + { 1, 1 }, + { 5, 5 }, + { 2, 2 }, + { 3, 3 }, + { 4, 4 }, + }; + struct trk_coord p2[] = { + { 1, 1 }, + { 3, 3 }, + { 2, 2 }, + { 4, 4 }, + { 5, 5 }, + }; + const unsigned char *p; + int i; + + clock_t t1 = clock(); + for (i = 0; i < ITS; i++) + p = mtdev_match_four(p1, n1, p2, n2); + clock_t t2 = clock(); + + printf("%lf matches per second\n", + ITS * ((float)CLOCKS_PER_SEC / (t2 - t1))); + + for (i = 0; i < n2; i++) + printf("match[%d] = %d\n", i, p[i]); + +} + +int main(int argc, char *argv[]) +{ + printf("test1\n"); + test1(); + printf("test2\n"); + test2(); + printf("speed1\n"); + speed1(); + printf("speed2\n"); + speed2(); + printf("done\n"); + return 0; +} diff --git a/test/mtdev-test.c b/test/mtdev-test.c new file mode 100644 index 0000000..1b3e4f2 --- /dev/null +++ b/test/mtdev-test.c @@ -0,0 +1,120 @@ +/***************************************************************************** + * + * mtdev - Multitouch Protocol Translation Library (MIT license) + * + * Copyright (C) 2010 Henrik Rydberg <rydberg@euromail.se> + * Copyright (C) 2010 Canonical Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + ****************************************************************************/ + +#include <mtdev.h> +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> + +/* year-proof millisecond event time */ +typedef __u64 mstime_t; + +static int use_event(const struct input_event *ev) +{ +#if 0 + return ev->type == EV_ABS && mtdev_is_absmt(ev->code); +#else + return 1; +#endif +} + +static void print_event(const struct input_event *ev) +{ + static const mstime_t ms = 1000; + static int slot; + mstime_t evtime = ev->time.tv_usec / ms + ev->time.tv_sec * ms; + if (ev->type == EV_ABS && ev->code == ABS_MT_SLOT) + slot = ev->value; + fprintf(stderr, "%012llx %02d %01d %04x %d\n", + evtime, slot, ev->type, ev->code, ev->value); +} + +#define CHECK(dev, name) \ + if (mtdev_has_mt_event(dev, name)) \ + fprintf(stderr, " %s\n", #name) + +static void show_props(const struct mtdev *dev) +{ + fprintf(stderr, "supported mt events:\n"); + CHECK(dev, ABS_MT_SLOT); + CHECK(dev, ABS_MT_TOUCH_MAJOR); + CHECK(dev, ABS_MT_TOUCH_MINOR); + CHECK(dev, ABS_MT_WIDTH_MAJOR); + CHECK(dev, ABS_MT_WIDTH_MINOR); + CHECK(dev, ABS_MT_ORIENTATION); + CHECK(dev, ABS_MT_POSITION_X); + CHECK(dev, ABS_MT_POSITION_Y); + CHECK(dev, ABS_MT_TOOL_TYPE); + CHECK(dev, ABS_MT_BLOB_ID); + CHECK(dev, ABS_MT_TRACKING_ID); + CHECK(dev, ABS_MT_PRESSURE); + CHECK(dev, ABS_MT_DISTANCE); +} + +static void loop_device(int fd) +{ + struct mtdev dev; + struct input_event ev; + int ret = mtdev_open(&dev, fd); + if (ret) { + fprintf(stderr, "error: could not open device: %d\n", ret); + return; + } + show_props(&dev); + /* while the device has not been inactive for five seconds */ + while (!mtdev_idle(&dev, fd, 5000)) { + /* extract all available processed events */ + while (mtdev_get(&dev, fd, &ev, 1) > 0) { + if (use_event(&ev)) + print_event(&ev); + } + } + mtdev_close(&dev); +} + +int main(int argc, char *argv[]) +{ + int fd; + if (argc < 2) { + fprintf(stderr, "Usage: mtdev <device>\n"); + return -1; + } + fd = open(argv[1], O_RDONLY | O_NONBLOCK); + if (fd < 0) { + fprintf(stderr, "error: could not open device\n"); + return -1; + } + if (ioctl(fd, EVIOCGRAB, 1)) { + fprintf(stderr, "error: could not grab the device\n"); + return -1; + } + loop_device(fd); + ioctl(fd, EVIOCGRAB, 0); + close(fd); + return 0; +} |