OSDN Git Service

initial import
authorRussell King <rmk@arm.linux.org.uk>
Sun, 23 Dec 2001 04:12:06 +0000 (21:12 -0700)
committerRussell King <rmk@arm.linux.org.uk>
Sun, 23 Dec 2001 04:12:06 +0000 (21:12 -0700)
33 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
config.h.in [new file with mode: 0644]
configure.in [new file with mode: 0644]
etc/Makefile.am [new file with mode: 0644]
etc/ts.conf [new file with mode: 0644]
plugins/Makefile.am [new file with mode: 0644]
plugins/dejitter.c [new file with mode: 0644]
plugins/linear.c [new file with mode: 0644]
plugins/variance.c [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/ts_attach.c [new file with mode: 0644]
src/ts_close.c [new file with mode: 0644]
src/ts_config.c [new file with mode: 0644]
src/ts_error.c [new file with mode: 0644]
src/ts_load_module.c [new file with mode: 0644]
src/ts_open.c [new file with mode: 0644]
src/ts_parse_vars.c [new file with mode: 0644]
src/ts_read.c [new file with mode: 0644]
src/ts_read_raw.c [new file with mode: 0644]
src/tslib-filter.h [new file with mode: 0644]
src/tslib-private.h [new file with mode: 0644]
src/tslib.h [new file with mode: 0644]
tests/Makefile.am [new file with mode: 0644]
tests/ts_calibrate.c [new file with mode: 0644]
tests/ts_test.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..f4853f1
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+# $Id: AUTHORS,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+Russell King
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..161a3d1
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,482 @@
+                 GNU LIBRARY GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+\f
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+\f
+                 GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+     Appendix: How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+    MA 02111-1307, USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..0a0ea3f
--- /dev/null
@@ -0,0 +1,13 @@
+#
+#  tslib/Makefile.am
+#
+#  Copyright (C) 2001 Russell King.
+#
+# This file is placed under the LGPL.  Please see the file
+# COPYING for more details.
+#
+# $Id: Makefile.am,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+#
+
+SUBDIRS                = etc src plugins tests
+EXTRA_DIST     = autogen.sh
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..529a21c
--- /dev/null
+++ b/README
@@ -0,0 +1,49 @@
+$Id: README,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+
+module:        variance
+----------------
+
+Description:
+  Variance filter.  Calculates the variance on the last 4 X and Y axis values
+  independently, and averages the two samples with the smallest variance.
+
+Parameters:
+  xlimit
+       Sets the X axis variance limit on the last 4 touch screen samples,
+       in touch screen coordinates.  Variances outside this limit will
+       cause 4 extra samples to be collected.
+
+  ylimit
+       Sets the Y axis variance limit on the last 4 touch screen samples,
+       in touch screen coordinates.  Variances outside this limit will
+       cause 4 extra samples to be collected.
+
+  pthreshold
+       Sets the pressure threshold, above which we believe the pen
+       to be down.
+
+module: dejitter
+----------------
+
+Description:
+  Removes jitter on the X and Y co-ordinates.  Samples whos X and Y
+  differentials are within these limits will be treated as an identical
+  value, and gobbled up.
+
+Parameters:
+  xdelta
+  ydelta
+       Sets the minimum differential between the current and the previous
+       X or Y sample.
+
+  pthreshold
+
+module: linear
+--------------
+
+Description:
+  Linear scaling module, primerily used for conversion of touch screen
+  co-ordinates to screen co-ordinates.
+
+Parameters:
+  none
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..eafb103
--- /dev/null
@@ -0,0 +1,545 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+dnl PARTICULAR PURPOSE.
+
+# Do all the work for Automake.  This macro actually does too much --
+# some checks are only needed if your package does certain things.
+# But this isn't really a big deal.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+   if test "[$]*" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftestfile`
+   fi
+   if test "[$]*" != "X $srcdir/configure conftestfile" \
+      && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "[$]2" = conftestfile
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# Run test in a subshell; some versions of sh will print an error if
+# an executable is not found, even if stderr is redirected.
+# Redirect stdin to placate older versions of autoconf.  Sigh.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+   $1=$2
+   AC_MSG_RESULT(found)
+else
+   $1="$3/missing $2"
+   AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated.  We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+  case " <<$>>CONFIG_HEADERS " in
+  *" <<$>>am_file "*<<)>>
+    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+    ;;
+  esac
+  am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
+
+
+# serial 40 AC_PROG_LIBTOOL
+AC_DEFUN(AC_PROG_LIBTOOL,
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+
+# Save cache, so that ltconfig can load it
+AC_CACHE_SAVE
+
+# Actually configure libtool.  ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
+LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
+DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
+|| AC_MSG_ERROR([libtool configure failed])
+
+# Reload cache, that may have been modified by ltconfig
+AC_CACHE_LOAD
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+])
+
+AC_DEFUN(AC_LIBTOOL_SETUP,
+[AC_PREREQ(2.13)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_RANLIB])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+dnl
+
+case "$target" in
+NONE) lt_target="$host" ;;
+*) lt_target="$target" ;;
+esac
+
+# Check for any special flags to pass to ltconfig.
+#
+# the following will cause an existing older ltconfig to fail, so
+# we ignore this at the expense of the cache file... Checking this 
+# will just take longer ... bummer!
+#libtool_flags="--cache-file=$cache_file"
+#
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
+[libtool_flags="$libtool_flags --enable-dlopen"])
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[libtool_flags="$libtool_flags --enable-win32-dll"])
+AC_ARG_ENABLE(libtool-lock,
+  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
+test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
+test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$lt_target" in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case "`/usr/bin/file conftest.o`" in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+])
+esac
+])
+
+# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
+AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
+
+# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
+AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
+
+# AC_ENABLE_SHARED - implement the --enable-shared flag
+# Usage: AC_ENABLE_SHARED[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_SHARED, [dnl
+define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(shared,
+changequote(<<, >>)dnl
+<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
+])
+
+# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
+AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)])
+
+# AC_ENABLE_STATIC - implement the --enable-static flag
+# Usage: AC_ENABLE_STATIC[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_STATIC, [dnl
+define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(static,
+changequote(<<, >>)dnl
+<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
+])
+
+# AC_DISABLE_STATIC - set the default static flag to --disable-static
+AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)])
+
+
+# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
+# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
+define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(fast-install,
+changequote(<<, >>)dnl
+<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
+])
+
+# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
+AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)])
+
+# AC_PROG_LD - find the path to the GNU or non-GNU linker
+AC_DEFUN(AC_PROG_LD,
+[AC_ARG_WITH(gnu-ld,
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  ac_prog=`($CC -print-prog-name=ld) 2>&5`
+  case "$ac_prog" in
+    # Accept absolute paths.
+changequote(,)dnl
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+changequote([,])dnl
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(ac_cv_path_LD,
+[if test -z "$LD"; then
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      ac_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+       test "$with_gnu_ld" != no && break
+      else
+       test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])
+
+AC_DEFUN(AC_PROG_LD_GNU,
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  ac_cv_prog_gnu_ld=yes
+else
+  ac_cv_prog_gnu_ld=no
+fi])
+])
+
+# AC_PROG_NM - find the path to a BSD-compatible name lister
+AC_DEFUN(AC_PROG_NM,
+[AC_MSG_CHECKING([for BSD-compatible nm])
+AC_CACHE_VAL(ac_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  ac_cv_path_NM="$NM"
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -B"
+       break
+      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+       ac_cv_path_NM="$ac_dir/nm -p"
+       break
+      else
+       ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
+       continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi])
+NM="$ac_cv_path_NM"
+AC_MSG_RESULT([$NM])
+])
+
+# AC_CHECK_LIBM - check for math library
+AC_DEFUN(AC_CHECK_LIBM,
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case "$lt_target" in
+*-*-beos* | *-*-cygwin*)
+  # These system don't have libm
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, main, LIBM="-lm")
+  ;;
+esac
+])
+
+# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl convenience library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-convenience to the
+# configure arguments.  Note that LIBLTDL and INCLTDL are not
+# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
+# provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
+# with '${top_builddir}/' and INCLTDL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case "$enable_ltdl_convenience" in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+])
+
+# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl installable library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-install to the configure
+# arguments.  Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
+# AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
+# libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
+# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
+# with '${top_srcdir}/' (note the single quotes!).  If your package is
+# not flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, main,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    INCLTDL=
+  fi
+])
+
+dnl old names
+AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
+AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
+AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
+
+dnl This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])dnl
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..6c0992d
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+# $Id: autogen.sh,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+libtoolize --force --copy
+aclocal
+autoheader
+automake --add-missing --copy
+autoconf
+./configure $*
diff --git a/config.h.in b/config.h.in
new file mode 100644 (file)
index 0000000..7c6b9c6
--- /dev/null
@@ -0,0 +1,66 @@
+/* config.h.in.  Generated automatically from configure.in by autoheader.  */
+
+/* Define if using alloca.c.  */
+#undef C_ALLOCA
+
+/* Define to empty if the keyword does not work.  */
+#undef const
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+   This function is required for alloca.c support on those systems.  */
+#undef CRAY_STACKSEG_END
+
+/* Define if you have alloca, as a function or macro.  */
+#undef HAVE_ALLOCA
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix).  */
+#undef HAVE_ALLOCA_H
+
+/* Define if you don't have vprintf but do have _doprnt.  */
+#undef HAVE_DOPRNT
+
+/* Define if you have the vprintf function.  */
+#undef HAVE_VPRINTF
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+#undef STACK_DIRECTION
+
+/* Define if you have the ANSI C header files.  */
+#undef STDC_HEADERS
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+#undef TIME_WITH_SYS_TIME
+
+/* Define if you have the strdup function.  */
+#undef HAVE_STRDUP
+
+/* Define if you have the strsep function.  */
+#undef HAVE_STRSEP
+
+/* Define if you have the strtoul function.  */
+#undef HAVE_STRTOUL
+
+/* Define if you have the <limits.h> header file.  */
+#undef HAVE_LIMITS_H
+
+/* Define if you have the <sys/time.h> header file.  */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <unistd.h> header file.  */
+#undef HAVE_UNISTD_H
+
+/* Define if you have the dl library (-ldl).  */
+#undef HAVE_LIBDL
+
+/* Name of package */
+#undef PACKAGE
+
+/* Version number of package */
+#undef VERSION
+
diff --git a/configure.in b/configure.in
new file mode 100644 (file)
index 0000000..38e2630
--- /dev/null
@@ -0,0 +1,55 @@
+dnl $Id: configure.in,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(src/ts_close.c)
+AM_INIT_AUTOMAKE(libts,0.0.0)
+AM_CONFIG_HEADER(config.h)
+
+AC_ARG_ENABLE(linear,   [  --enable-linear         Enable building of linear scaling [default=yes]],
+  [ "x$enableval" = "xyes" ] && PLUGINS="$PLUGINS linear.la", PLUGINS="$PLUGINS linear.la")
+AC_ARG_ENABLE(dejitter, [  --enable-dejitter       Enable building of dejitter filter [default=yes]],
+  [ "x$enableval" = "xyes" ] && PLUGINS="$PLUGINS dejitter.la", PLUGINS="$PLUGINS dejitter.la")
+AC_ARG_ENABLE(variance, [  --enable-variance       Enable building of variance filter [default=yes]],
+  [ "x$enableval" = "xyes" ] && PLUGINS="$PLUGINS variance.la", PLUGINS="$PLUGINS variance.la")
+AC_SUBST(PLUGINS)
+
+AM_DISABLE_STATIC
+AM_ENABLE_SHARED
+
+PLUGIN_DIR='${datadir}/ts/plugins'
+AC_SUBST(PLUGIN_DIR)
+
+TS_CONF='${sysconfdir}/ts.conf'
+AC_SUBST(TS_CONF)
+
+dnl Library versioning
+LT_RELEASE=0.0
+LT_CURRENT=0
+LT_REVISION=0
+LT_AGE=0
+AC_SUBST(LT_RELEASE)
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+AC_SUBST(LT_AGE)
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_LIBTOOL_DLOPEN
+AM_PROG_LIBTOOL
+
+dnl Checks for libraries.
+AC_CHECK_LIB(dl, dlopen)
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(limits.h sys/time.h unistd.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_HEADER_TIME
+
+dnl Checks for library functions.
+AC_FUNC_ALLOCA
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS(strsep strdup strtoul)
+
+AC_OUTPUT(Makefile etc/Makefile src/Makefile plugins/Makefile tests/Makefile)
diff --git a/etc/Makefile.am b/etc/Makefile.am
new file mode 100644 (file)
index 0000000..ebe6895
--- /dev/null
@@ -0,0 +1,14 @@
+#
+#  etc/Makefile.am
+#
+#  Copyright (C) 2001 Russell King.
+#
+# This file is placed under the LGPL.  Please see the file
+# COPYING for more details.
+#
+# $Id: Makefile.am,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+#
+
+sysconf_DATA           = ts.conf
+
+EXTRA_DIST             = $(sysconf_DATA)
diff --git a/etc/ts.conf b/etc/ts.conf
new file mode 100644 (file)
index 0000000..7292394
--- /dev/null
@@ -0,0 +1,4 @@
+# $Id: ts.conf,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+module variance xlimit=50 ylimit=50 pthreshold=100
+module dejitter xdelta=3 ydelta=2 pthreshold=100
+module linear
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
new file mode 100644 (file)
index 0000000..4e2f33b
--- /dev/null
@@ -0,0 +1,32 @@
+#
+#  tslib/plugins/Makefile.am
+#
+#  Copyright (C) 2001 Russell King.
+#
+# This file is placed under the LGPL.  Please see the file
+# COPYING for more details.
+#
+# $Id: Makefile.am,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+#
+
+INCLUDES                = -I$(top_srcdir)/src
+LDFLAGS                        := $(LDFLAGS) -rpath $(PLUGIN_DIR)
+#LTVSN                 := -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+#                         -release $(LT_RELEASE)
+LTVSN                  := -avoid-version
+LIBS                    =
+
+plugindir               = $(PLUGIN_DIR)
+
+EXTRA_LTLIBRARIES       = variance.la dejitter.la linear.la
+plugin_LTLIBRARIES      = $(PLUGINS)
+
+variance_la_SOURCES     = variance.c
+variance_la_LDFLAGS     = -module $(LTVSN)
+
+dejitter_la_SOURCES     = dejitter.c
+dejitter_la_LDFLAGS     = -module $(LTVSN)
+
+linear_la_SOURCES       = linear.c
+linear_la_LDFLAGS       = -module $(LTVSN)
+
diff --git a/plugins/dejitter.c b/plugins/dejitter.c
new file mode 100644 (file)
index 0000000..fa952a0
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ *  tslib/plugins/threshold.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: dejitter.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Threshold filter for touchscreen values
+ */
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#include "tslib.h"
+#include "tslib-filter.h"
+
+#define NR_LAST        4
+
+struct tslib_threshold {
+       struct tslib_module_info        module;
+       unsigned int                    pthreshold;
+       unsigned int                    xdelta;
+       unsigned int                    ydelta;
+       unsigned int                    x;
+       unsigned int                    y;
+       unsigned int                    down;
+};
+
+static int threshold_read(struct tslib_module_info *info, struct ts_sample *samp, int nr)
+{
+       struct tslib_threshold *thr = (struct tslib_threshold *)info;
+       struct ts_sample *s;
+       int ret;
+
+       ret = info->next->ops->read(info->next, samp, nr);
+       if (ret >= 0) {
+               int nr = 0;
+
+               for (s = samp; s < samp + ret; s++) {
+                       int dx, dy;
+
+                       if (thr->down) {
+                               dx = thr->x - s->x;
+                               if (dx < 0)
+                                       dx = -dx;
+                               dy = thr->y - s->y;
+                               if (dy < 0)
+                                       dy = -dy;
+
+                               if (dx < thr->xdelta)
+                                       s->x = thr->x;
+                               if (dy < thr->ydelta)
+                                       s->y = thr->y;
+
+                               if (thr->x != s->x || thr->y != s->y)
+                                       samp[nr++] = *s;
+                       }
+
+                       thr->down = s->pressure >= thr->pthreshold;
+
+                       thr->x = s->x;
+                       thr->y = s->y;
+               }
+
+               ret = nr;
+       }
+       return ret;
+}
+
+static int threshold_fini(struct tslib_module_info *info)
+{
+       free(info);
+}
+
+static const struct tslib_ops threshold_ops =
+{
+       read:   threshold_read,
+       fini:   threshold_fini,
+};
+
+static int threshold_limit(struct tslib_module_info *inf, char *str, void *data)
+{
+       struct tslib_threshold *thr = (struct tslib_threshold *)inf;
+       unsigned long v;
+       int err = errno;
+
+       v = strtoul(str, NULL, 0);
+
+       if (v == ULONG_MAX && errno == ERANGE)
+               return -1;
+
+       errno = err;
+       switch ((int)data) {
+       case 1:
+               thr->xdelta = v;
+               break;
+
+       case 2:
+               thr->ydelta = v;
+               break;
+
+       case 3:
+               thr->pthreshold = v;
+               break;
+
+       default:
+               return -1;
+       }
+       return 0;
+}
+
+static const struct tslib_vars threshold_vars[] =
+{
+       { "xdelta",     (void *)1, threshold_limit },
+       { "ydelta",     (void *)2, threshold_limit },
+       { "pthreshold", (void *)3, threshold_limit }
+};
+
+#define NR_VARS (sizeof(threshold_vars) / sizeof(threshold_vars[0]))
+
+struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
+{
+       struct tslib_threshold *thr;
+
+       thr = malloc(sizeof(struct tslib_threshold));
+       if (thr == NULL)
+               return NULL;
+
+       thr->module.ops = &threshold_ops;
+
+       thr->xdelta = 3;
+       thr->ydelta = 3;
+       thr->pthreshold = 100;
+
+       if (tslib_parse_vars(&thr->module, threshold_vars, NR_VARS, params)) {
+               free(thr);
+               return NULL;
+       }
+
+       return &thr->module;
+}
diff --git a/plugins/linear.c b/plugins/linear.c
new file mode 100644 (file)
index 0000000..207b474
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ *  tslib/plugins/linear.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: linear.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Linearly scale touchscreen values
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "tslib.h"
+#include "tslib-filter.h"
+
+struct tslib_linear {
+       struct tslib_module_info module;
+       int     x_offset;
+       int     x_mult;
+       int     x_div;
+       int     y_offset;
+       int     y_mult;
+       int     y_div;
+       int     p_offset;
+       int     p_mult;
+       int     p_div;
+};
+
+static int
+linear_read(struct tslib_module_info *info, struct ts_sample *samp, int nr)
+{
+       struct tslib_linear *lin = (struct tslib_linear *)info;
+       int ret;
+
+       ret = info->next->ops->read(info->next, samp, nr);
+       if (ret >= 0) {
+               int nr;
+
+               for (nr = 0; nr < ret; nr++, samp++) {
+                       samp->x = ((samp->x + lin->x_offset) * lin->x_mult)
+                                       / lin->x_div;
+                       samp->y = ((samp->y + lin->y_offset) * lin->y_mult)
+                                       / lin->y_div;
+                       samp->pressure = ((samp->pressure + lin->p_offset)
+                                                * lin->p_mult) / lin->p_div;
+               }
+       }
+
+       return ret;
+}
+
+static int linear_fini(struct tslib_module_info *info)
+{
+       free(info);
+}
+
+static const struct tslib_ops linear_ops =
+{
+       read:           linear_read,
+       fini:           linear_fini,
+};
+
+struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
+{
+       struct tslib_linear *lin;
+       char *tok, *str, *p;
+
+       if (params) {
+               str = p = strdup(params);
+               if (!p)
+                       return NULL;
+       } else
+               str = p = NULL;
+
+       lin = malloc(sizeof(struct tslib_linear));
+       if (lin == NULL) {
+               if (str)
+                       free(str);
+               return NULL;
+       }
+
+       lin->module.ops = &linear_ops;
+
+       lin->x_offset = -908;
+       lin->x_mult   = 270;
+       lin->x_div    = -684;
+
+       lin->y_offset = -918;
+       lin->y_mult   = 190;
+       lin->y_div    = -664;
+
+       lin->p_offset = 0;
+       lin->p_mult   = 0x10000;
+       lin->p_div    = 0x10000;
+
+       /*
+        * Parse the parameters.
+        */
+       while ((tok = strsep(&p, " \t")) != NULL) {
+
+       }
+
+       if (str)
+               free(str);
+
+       return &lin->module;
+}
diff --git a/plugins/variance.c b/plugins/variance.c
new file mode 100644 (file)
index 0000000..fbeff4a
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ *  tslib/plugins/variance.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: variance.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Variance filter for touchscreen values
+ */
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#include "tslib.h"
+#include "tslib-filter.h"
+
+#define NR_LAST        4
+
+struct tslib_variance {
+       struct tslib_module_info        module;
+       int                             nr;
+       unsigned int                    pthreshold;
+       unsigned int                    xlimit;
+       unsigned int                    ylimit;
+       struct ts_sample                last[NR_LAST];
+};
+
+/*
+ * We have 4 complete samples.  Calculate the variance between each,
+ * treating X and Y values separately.  Then pick the two with the
+ * least variance, and average them.
+ */
+static int
+variance_calculate(struct tslib_variance *var, struct ts_sample *samp,
+                  struct ts_sample *s)
+{
+       int i, j;
+       int diff_x, min_x, i_x, j_x;
+       int diff_y, min_y, i_y, j_y;
+       int diff_p, min_p, i_p, j_p;
+
+       min_x = INT_MAX;
+       min_y = INT_MAX;
+       min_p = INT_MAX;
+
+       for (i = 0; i < var->nr - 1; i++) {
+               for (j = i + 1; j < var->nr; j++) {
+                       /*
+                        * Calculate the variance between sample 'i'
+                        * and sample 'j'.  X and Y values are treated
+                        * separately.
+                        */
+                       diff_x = var->last[i].x - var->last[j].x;
+                       if (diff_x < 0)
+                               diff_x = -diff_x;
+
+                       diff_y = var->last[i].y - var->last[j].y;
+                       if (diff_y < 0)
+                               diff_y = -diff_y;
+
+                       diff_p = var->last[i].pressure - var->last[j].pressure;
+                       if (diff_p < 0)
+                               diff_p = -diff_p;
+
+                       /*
+                        * Is the variance between any two samples too large?
+                        */
+                       if (diff_x > var->xlimit || diff_y > var->ylimit)
+                               return 0;
+
+                       /*
+                        * Find the minimum X variance.
+                        */
+                       if (min_x > diff_x) {
+                               min_x = diff_x;
+                               i_x = i;
+                               j_x = j;
+                       }
+
+                       /*
+                        * Find the minimum Y variance.
+                        */
+                       if (min_y > diff_y) {
+                               min_y = diff_y;
+                               i_y = i;
+                               j_y = j;
+                       }
+
+                       if (min_p > diff_p) {
+                               min_p = diff_p;
+                               i_p = i;
+                               j_p = j;
+                       }
+               }
+       }
+
+       samp->x          = (var->last[i_x].x + var->last[j_x].x) / 2;
+       samp->y          = (var->last[i_y].y + var->last[j_y].y) / 2;
+       samp->pressure   = (var->last[i_p].pressure + var->last[j_p].pressure) / 2;
+       samp->tv.tv_sec  = s->tv.tv_sec;
+       samp->tv.tv_usec = s->tv.tv_usec;
+
+       return 1;
+}
+
+static int variance_read(struct tslib_module_info *info, struct ts_sample *samp, int nr)
+{
+       struct tslib_variance *var = (struct tslib_variance *)info;
+       struct ts_sample *s;
+       int ret;
+
+       ret = info->next->ops->read(info->next, samp, nr);
+       if (ret >= 0) {
+               int nr = 0;
+
+               for (s = samp; s < samp + ret; s++) {
+                       if (s->pressure < var->pthreshold) {
+                               /*
+                                * Pen was released.  Reset our state and
+                                * pass up the release information.
+                                */
+                               samp[nr].x = 0;
+                               samp[nr].y = 0;
+                               samp[nr].pressure = s->pressure;
+                               samp[nr].tv.tv_sec = s->tv.tv_sec;
+                               samp[nr].tv.tv_usec = s->tv.tv_usec;
+
+                               nr++;
+
+                               var->nr = 0;
+                               continue;
+                       } else if (var->nr == -1) {
+                               /*
+                                * Pen was pressed.  Inform upper layers
+                                * immediately.
+                                */
+                               samp[nr] = *s;
+                               nr++;
+                       }
+
+                       if (var->nr >= 0) {
+                               var->last[var->nr].x = s->x;
+                               var->last[var->nr].y = s->y;
+                               var->last[var->nr].pressure = s->pressure;
+                       }
+
+                       var->nr++;
+
+                       if (var->nr == NR_LAST) {
+                               if (variance_calculate(var, samp + nr, s))
+                                       nr++;
+                               var->nr = 0;
+                       }
+               }
+
+               ret = nr;
+       }
+       return ret;
+}
+
+static int variance_fini(struct tslib_module_info *info)
+{
+       free(info);
+}
+
+static const struct tslib_ops variance_ops =
+{
+       read:   variance_read,
+       fini:   variance_fini,
+};
+
+static int variance_limit(struct tslib_module_info *inf, char *str, void *data)
+{
+       struct tslib_variance *var = (struct tslib_variance *)inf;
+       unsigned long v;
+       int err = errno;
+
+       v = strtoul(str, NULL, 0);
+
+       if (v == ULONG_MAX && errno == ERANGE)
+               return -1;
+
+       errno = err;
+       switch ((int)data) {
+       case 1:
+               var->xlimit = v;
+               break;
+
+       case 2:
+               var->ylimit = v;
+               break;
+
+       case 3:
+               var->pthreshold = v;
+               break;
+
+       default:
+               return -1;
+       }
+       return 0;
+}
+
+static const struct tslib_vars variance_vars[] =
+{
+       { "xlimit",     (void *)1, variance_limit },
+       { "ylimit",     (void *)2, variance_limit },
+       { "pthreshold", (void *)3, variance_limit }
+};
+
+#define NR_VARS (sizeof(variance_vars) / sizeof(variance_vars[0]))
+
+struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
+{
+       struct tslib_variance *var;
+
+       var = malloc(sizeof(struct tslib_variance));
+       if (var == NULL)
+               return NULL;
+
+       var->module.ops = &variance_ops;
+
+       var->nr = -1;
+       var->xlimit = 160;
+       var->ylimit = 160;
+       var->pthreshold = 100;
+
+       if (tslib_parse_vars(&var->module, variance_vars, NR_VARS, params)) {
+               free(var);
+               return NULL;
+       }
+
+       return &var->module;
+}
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..b2c98fa
--- /dev/null
@@ -0,0 +1,23 @@
+#
+#  tslib/src/Makefile.am
+#
+#  Copyright (C) 2001 Russell King.
+#
+# This file is placed under the LGPL.  Please see the file
+# COPYING for more details.
+#
+# $Id: Makefile.am,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+#
+
+CFLAGS         := $(CFLAGS) -DPLUGIN_DIR=\"@PLUGIN_DIR@\" -DTS_CONF=\"@TS_CONF@\"
+
+noinst_HEADERS   = tslib-private.h tslib-filter.h
+include_HEADERS  = tslib.h
+
+lib_LTLIBRARIES  = libts.la
+libts_la_SOURCES = ts_attach.c ts_close.c ts_config.c ts_error.c \
+                  ts_load_module.c ts_open.c ts_parse_vars.c    \
+                  ts_read.c ts_read_raw.c
+libts_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+                  -release $(LT_RELEASE) -export-dynamic
+libts_la_LIBADD  = -ldl
diff --git a/src/ts_attach.c b/src/ts_attach.c
new file mode 100644 (file)
index 0000000..060cdae
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ *  tslib/src/ts_attach.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_attach.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Attach a filter to a touchscreen device.
+ */
+#include "config.h"
+
+#include "tslib-private.h"
+
+int __ts_attach(struct tsdev *ts, struct tslib_module_info *info)
+{
+       info->dev = ts;
+       info->next = ts->list;
+       ts->list = info;
+
+       return 0;
+}
diff --git a/src/ts_close.c b/src/ts_close.c
new file mode 100644 (file)
index 0000000..4fd274d
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ *  tslib/src/ts_close.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_close.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Close a touchscreen device.
+ */
+#include "config.h"
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "tslib-private.h"
+
+int ts_close(struct tsdev *ts)
+{
+       int ret;
+
+       ret = close(ts->fd);
+       free(ts);
+
+       return ret;
+}
diff --git a/src/ts_config.c b/src/ts_config.c
new file mode 100644 (file)
index 0000000..5080cb4
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ *  tslib/src/ts_config.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_config.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Read the configuration and load the appropriate drivers.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+
+#include "tslib-private.h"
+
+struct opt {
+       const char *str;
+       int (*fn)(struct tsdev *ts, char *rest);
+};
+
+static int ts_opt_module(struct tsdev *ts, char *rest)
+{
+       char *tok = strsep(&rest, " \t");
+
+       return ts_load_module(ts, tok, rest);
+}
+
+static struct opt options[] = {
+       { "module", ts_opt_module },
+};
+
+#define NR_OPTS (sizeof(options) / sizeof(options[0]))
+
+int ts_config(struct tsdev *ts)
+{
+       char buf[80], *p;
+       FILE *f;
+       int line = 0, ret = 0;
+
+       f = fopen(TS_CONF, "r");
+       if (!f)
+               return -1;
+
+       while ((p = fgets(buf, sizeof(buf), f)) != NULL && ret == 0) {
+               struct opt *opt;
+               char *e, *tok;
+
+               line++;
+
+               /*
+                * Did we read a whole line?
+                */
+               e = strchr(p, '\n');
+               if (!e) {
+                       ts_error("%d: line too long", line);
+                       break;
+               }
+
+               /*
+                * Chomp.
+                */
+               *e = '\0';
+
+               tok = strsep(&p, " \t");
+
+               /*
+                * Ignore comments or blank lines.
+                */
+               if (!tok || *tok == '#')
+                       continue;
+
+               /*
+                * Search for the option.
+                */
+               for (opt = options; opt < options + NR_OPTS; opt++)
+                       if (strcasecmp(tok, opt->str) == 0) {
+                               ret = opt->fn(ts, p);
+                               break;
+                       }
+
+               if (opt == options + NR_OPTS) {
+                       ts_error("%d: option `%s' not recognised", line, tok);
+                       ret = -1;
+               }
+       }
+
+       fclose(f);
+
+       return ret;
+}
diff --git a/src/ts_error.c b/src/ts_error.c
new file mode 100644 (file)
index 0000000..e70cc4f
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  tslib/src/ts_error.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_error.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Error handling for tslib.
+ */
+#include "config.h"
+#include <stdarg.h>
+#include <stdio.h>
+
+static int stderrfn(const char *fmt, va_list ap)
+{
+       return vfprintf(stderr, fmt, ap);
+}
+
+/*
+ * Change this hook to point to your custom error handling function.
+ */
+int (*ts_error_fn)(const char *fmt, va_list ap) = stderrfn;
+
+int ts_error(const char *fmt, ...)
+{
+       va_list ap;
+       int ret;
+
+       va_start(ap, fmt);
+       ret = ts_error_fn(fmt, ap);
+       va_end(ap);
+
+       return ret;
+}
diff --git a/src/ts_load_module.c b/src/ts_load_module.c
new file mode 100644 (file)
index 0000000..edd1947
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *  tslib/src/ts_load_module.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_load_module.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Close a touchscreen device.
+ */
+#include "config.h"
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "tslib-private.h"
+
+int ts_load_module(struct tsdev *ts, const char *module, const char *params)
+{
+       struct tslib_module_info * (*init)(struct tsdev *, const char *);
+       struct tslib_module_info *info;
+       char *fn;
+       void *handle;
+       int ret;
+
+       fn = alloca(sizeof(PLUGIN_DIR) + strlen(module) + 4);
+
+       strcpy(fn, PLUGIN_DIR);
+       strcat(fn, "/");
+       strcat(fn, module);
+       strcat(fn, ".so");
+
+       handle = dlopen(fn, RTLD_NOW);
+       if (!handle)
+               return -1;
+
+       init = dlsym(handle, "mod_init");
+       if (!init) {
+               dlclose(handle);
+               return -1;
+       }
+
+       info = init(ts, params);
+       if (!info) {
+               dlclose(handle);
+               return -1;
+       }
+
+       info->handle = handle;
+
+       ret = __ts_attach(ts, info);
+       if (ret) {
+               info->ops->fini(info);
+               dlclose(handle);
+       }
+
+       return ret;
+}
diff --git a/src/ts_open.c b/src/ts_open.c
new file mode 100644 (file)
index 0000000..ec76617
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  tslib/src/ts_open.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_open.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Open a touchscreen device.
+ */
+#include "config.h"
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <sys/fcntl.h>
+
+#include "tslib-private.h"
+
+extern struct tslib_module_info __ts_raw;
+
+struct tsdev *ts_open(const char *name, int nonblock)
+{
+       struct tsdev *ts;
+       int flags = O_RDONLY;
+
+       if (nonblock)
+               flags |= O_NONBLOCK;
+
+       ts = malloc(sizeof(struct tsdev));
+       if (ts) {
+               memset(ts, 0, sizeof(struct tsdev));
+
+               __ts_attach(ts, &__ts_raw);
+
+               ts->fd = open(name, flags);
+               if (ts->fd == -1)
+                       goto free;
+       }
+       return ts;
+
+free:
+       free(ts);
+       return NULL;
+}
diff --git a/src/ts_parse_vars.c b/src/ts_parse_vars.c
new file mode 100644 (file)
index 0000000..5d960d1
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  tslib/src/ts_read.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_parse_vars.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Read raw pressure, x, y, and timestamp from a touchscreen device.
+ */
+#include "config.h"
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#include <string.h>
+
+#include "tslib-private.h"
+
+int tslib_parse_vars(struct tslib_module_info *mod,
+                    const struct tslib_vars *vars, int nr,
+                    const char *str)
+{
+       char *s, *p;
+       int ret = 0;
+
+       if (!str)
+               return 0;
+
+       s = alloca(strlen(str));
+
+       while ((p = strsep(&s, " \t")) != NULL && ret == 0) {
+               const struct tslib_vars *v;
+               char *eq;
+
+               eq = strchr(p, '=');
+               if (eq)
+                       *eq++ = '\0';
+
+               for (v = vars; v < vars + nr; v++)
+                       if (strcasecmp(v->name, p) == 0) {
+                               ret = v->fn(mod, eq, v->data);
+                               break;
+                       }
+       }
+
+       return ret;
+}
diff --git a/src/ts_read.c b/src/ts_read.c
new file mode 100644 (file)
index 0000000..08e7045
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ *  tslib/src/ts_read.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_read.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Read raw pressure, x, y, and timestamp from a touchscreen device.
+ */
+#include "config.h"
+
+#include "tslib-private.h"
+
+int ts_read(struct tsdev *ts, struct ts_sample *samp, int nr)
+{
+       return ts->list->ops->read(ts->list, samp, nr);
+}
diff --git a/src/ts_read_raw.c b/src/ts_read_raw.c
new file mode 100644 (file)
index 0000000..895b28a
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ *  tslib/src/ts_read_raw.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_read_raw.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Read raw pressure, x, y, and timestamp from a touchscreen device.
+ */
+#include "config.h"
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <sys/time.h>
+
+#include "tslib-private.h"
+
+struct ts_event {
+       unsigned short  pressure;
+       unsigned short  x;
+       unsigned short  y;
+       unsigned short  pad;
+       struct timeval  stamp;
+};
+
+int ts_read_raw(struct tsdev *ts, struct ts_sample *samp, int nr)
+{
+       struct ts_event *evt;
+       int ret;
+
+       evt = alloca(sizeof(*evt) * nr);
+
+       ret = read(ts->fd, evt, sizeof(*evt) * nr);
+
+       if (ret >= 0) {
+               int nr = ret / sizeof(*evt);
+               while (ret >= sizeof(*evt)) {
+                       samp->x = evt->x;
+                       samp->y = evt->y;
+                       samp->pressure = evt->pressure;
+                       samp->tv.tv_usec = evt->stamp.tv_usec;
+                       samp->tv.tv_sec = evt->stamp.tv_sec;
+                       samp++;
+                       evt++;
+                       ret -= sizeof(*evt);
+               }
+               ret = nr;
+       }
+
+       return ret;
+}
+
+static int __ts_read_raw(struct tslib_module_info *inf, struct ts_sample *samp, int nr)
+{
+       return ts_read_raw(inf->dev, samp, nr);
+}
+
+static const struct tslib_ops __ts_raw_ops =
+{
+       read:   __ts_read_raw,
+};
+
+struct tslib_module_info __ts_raw =
+{
+       next:   NULL,
+       ops:    &__ts_raw_ops,
+};
diff --git a/src/tslib-filter.h b/src/tslib-filter.h
new file mode 100644 (file)
index 0000000..f739c1f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  tslib/src/tslib-filter.h
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.
+ *
+ * $Id: tslib-filter.h,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Internal touch screen library definitions.
+ */
+struct tslib_module_info;
+struct tsdev;
+
+struct tslib_vars {
+       const char *name;
+       void *data;
+       int (*fn)(struct tslib_module_info *inf, char *str, void *data);
+};
+
+struct tslib_ops {
+       int (*read)(struct tslib_module_info *inf, struct ts_sample *samp, int nr);
+       int (*fini)(struct tslib_module_info *inf);
+};
+
+struct tslib_module_info {
+       struct tsdev *dev;
+       struct tslib_module_info *next; /* next module in chain */
+       void *handle;                   /* dl handle            */
+       const struct tslib_ops *ops;
+};
+
+extern int tslib_parse_vars(struct tslib_module_info *,
+                           const struct tslib_vars *, int,
+                           const char *);
diff --git a/src/tslib-private.h b/src/tslib-private.h
new file mode 100644 (file)
index 0000000..3acab48
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ *  tslib/src/tslib-private.h
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.
+ *
+ * $Id: tslib-private.h,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Internal touch screen library definitions.
+ */
+#include "tslib.h"
+#include "tslib-filter.h"
+
+struct tsdev {
+       int fd;
+       struct tslib_module_info *list;
+};
+
+int __ts_attach(struct tsdev *ts, struct tslib_module_info *info);
+int ts_load_module(struct tsdev *dev, const char *module, const char *params);
+int ts_error(const char *fmt, ...);
diff --git a/src/tslib.h b/src/tslib.h
new file mode 100644 (file)
index 0000000..0652c53
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ *  tslib/src/tslib.h
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the LGPL.
+ *
+ * $Id: tslib.h,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Touch screen library interface definitions.
+ */
+#include <stdarg.h>
+#include <sys/time.h>
+
+struct tsdev;
+
+struct ts_sample {
+       int             x;
+       int             y;
+       unsigned int    pressure;
+       struct timeval  tv;
+};
+
+/*
+ * Close the touchscreen device, free all resources.
+ */
+int ts_close(struct tsdev *);
+
+/*
+ * Configure the touchscreen device.
+ */
+int ts_config(struct tsdev *);
+
+/*
+ * Change this hook to point to your custom error handling function.
+ */
+extern int (*ts_error_fn)(const char *fmt, va_list ap);
+
+/*
+ * Returns the file descriptor in use for the touchscreen device.
+ * (not currently implemented)
+ */
+int ts_fd(struct tsdev *);
+
+/*
+ * Load a filter/scaling module
+ */
+int ts_load_module(struct tsdev *, const char *mod, const char *params);
+
+/*
+ * Open the touchscreen device.
+ */
+struct tsdev *ts_open(const char *dev_name, int nonblock);
+
+/*
+ * Return a scaled touchscreen sample.
+ */
+int ts_read(struct tsdev *, struct ts_sample *, int);
+
+/*
+ * Returns a raw, unscaled sample from the touchscreen.
+ */
+int ts_read_raw(struct tsdev *, struct ts_sample *, int);
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..b8283ea
--- /dev/null
@@ -0,0 +1,20 @@
+#
+#  tslib/tests/Makefile.am
+#
+#  Copyright (C) 2001 Russell King.
+#
+# This file is placed under the LGPL.  Please see the file
+# COPYING for more details.
+#
+# $Id: Makefile.am,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+#
+
+INCLUDES               = -I$(top_srcdir)/src
+
+bin_PROGRAMS           = ts_test ts_calibrate
+
+ts_test_SOURCES                = ts_test.c
+ts_test_LDADD          = $(top_builddir)/src/libts.la
+
+ts_calibrate_SOURCES   = ts_calibrate.c
+ts_calibrate_LDADD     = $(top_builddir)/src/libts.la
diff --git a/tests/ts_calibrate.c b/tests/ts_calibrate.c
new file mode 100644 (file)
index 0000000..bbe1329
--- /dev/null
@@ -0,0 +1,246 @@
+/*
+ *  tslib/tests/ts_calibrate.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the GPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_calibrate.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Basic test program for touchscreen library.
+ */
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <linux/fb.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+
+#include "tslib.h"
+
+static int con_fd, fb_fd, last_vt = -1;
+static struct fb_fix_screeninfo fix;
+static struct fb_var_screeninfo var;
+static struct fb_cmap cmap;
+static char *fbuffer;
+
+static int open_framebuffer(void)
+{
+       struct vt_stat vts;
+       char vtname[16];
+       int fd, nr;
+       unsigned short col[2];
+
+       fd = open("/dev/tty1", O_WRONLY);
+       if (fd < 0) {
+               perror("open /dev/tty1");
+               return -1;
+       }
+
+       if (ioctl(fd, VT_OPENQRY, &nr) < 0) {
+               perror("ioctl VT_OPENQRY");
+               return -1;
+       }
+       close(fd);
+
+       sprintf(vtname, "/dev/tty%d", nr);
+
+       con_fd = open(vtname, O_RDWR | O_NDELAY);
+       if (con_fd < 0) {
+               perror("open tty");
+               return -1;
+       }
+
+       if (ioctl(con_fd, VT_GETSTATE, &vts) == 0)
+               last_vt = vts.v_active;
+
+       if (ioctl(con_fd, VT_ACTIVATE, nr) < 0) {
+               perror("VT_ACTIVATE");
+               close(con_fd);
+               return -1;
+       }
+
+       if (ioctl(con_fd, VT_WAITACTIVE, nr) < 0) {
+               perror("VT_WAITACTIVE");
+               close(con_fd);
+               return -1;
+       }
+
+       if (ioctl(con_fd, KDSETMODE, KD_GRAPHICS) < 0) {
+               perror("KDSETMODE");
+               close(con_fd);
+               return -1;
+       }
+
+       fb_fd = open("/dev/fb0", O_RDWR);
+       if (fb_fd == -1) {
+               perror("open /dev/fb");
+               return -1;
+       }
+
+       if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fix) < 0) {
+               perror("ioctl FBIOGET_FSCREENINFO");
+               close(fb_fd);
+               return -1;
+       }
+
+       if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &var) < 0) {
+               perror("ioctl FBIOGET_VSCREENINFO");
+               close(fb_fd);
+               return -1;
+       }
+
+       cmap.start = 0;
+       cmap.len = 2;
+       cmap.red = col;
+       cmap.green = col;
+       cmap.blue = col;
+       cmap.transp = NULL;
+
+       col[0] = 0;
+       col[1] = 0xffff;
+
+       if (ioctl(fb_fd, FBIOGETCMAP, &cmap) < 0) {
+               perror("ioctl FBIOGETCMAP");
+               close(fb_fd);
+               return -1;
+       }
+
+       fbuffer = mmap(NULL, fix.smem_len, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fb_fd, 0);
+       if (fbuffer == (char *)-1) {
+               perror("mmap framebuffer");
+               close(fb_fd);
+               return -1;
+       }
+       return 0;
+}
+
+static void close_framebuffer(void)
+{
+       munmap(fbuffer, fix.smem_len);
+       close(fb_fd);
+
+       if (ioctl(con_fd, KDSETMODE, KD_TEXT) < 0)
+               perror("KDSETMODE");
+
+       if (last_vt >= 0)
+               if (ioctl(con_fd, VT_ACTIVATE, last_vt))
+                       perror("VT_ACTIVATE");
+
+       close(con_fd);
+}
+
+static void sig(int sig)
+{
+       close_framebuffer();
+       fflush(stderr);
+       printf("signal %d caught\n", sig);
+       fflush(stdout);
+       exit(1);
+}
+
+static void put_cross(int x, int y, int c)
+{
+       int off = y * fix.line_length + x * var.bits_per_pixel / 8;
+       int i;
+
+       for (i = 0; i < 50; i++) {
+               fbuffer[off + i * fix.line_length + 50] = c;
+               fbuffer[off + i * fix.line_length + 51] = c;
+       }
+
+       for (i = 0; i < 100; i++)
+               fbuffer[off + 25 * fix.line_length + i] = c;
+}
+
+static int getxy(struct tsdev *ts, int *x, int *y)
+{
+       struct ts_sample samp, sa;
+
+       do {
+               sa = samp;
+               if (ts_read_raw(ts, &samp, 1) < 0) {
+                       perror("ts_read");
+                       close_framebuffer();
+                       exit(1);
+               }
+       } while (samp.pressure > 100);
+
+       if (x && y) {
+               *x = sa.x;
+               *y = sa.y;
+       }
+}
+
+int main()
+{
+       struct tsdev *ts;
+       int fd, x[4], y[4];
+
+       signal(SIGSEGV, sig);
+       signal(SIGINT, sig);
+       signal(SIGTERM, sig);
+
+       ts = ts_open("/dev/touchscreen/ucb1x00", 0);
+       if (!ts) {
+               perror("ts_open");
+               exit(1);
+       }
+
+       if (open_framebuffer()) {
+               close_framebuffer();
+               exit(1);
+       }
+
+       memset(fbuffer, 0, fix.smem_len);
+
+       getxy(ts, 0, 0);
+       put_cross(0,0,0xff);
+       getxy(ts, &x[0], &y[0]);
+       put_cross(0,0,0);
+
+       printf("Top left : X = %4d Y = %4d\n", x[0], y[0]);
+
+       put_cross(var.xres - 50, 0, 0xff);
+       getxy(ts, &x[1], &y[1]);
+       put_cross(var.xres - 50, 0, 0);
+
+       printf("Top right: X = %4d Y = %4d\n", x[1], y[1]);
+
+       put_cross(var.xres - 50, var.yres - 50, 0xff);
+       getxy(ts, &x[2], &y[2]);
+       put_cross(var.xres - 50, var.yres - 50, 0);
+
+       printf("Bot right: X = %4d Y = %4d\n", x[2], y[2]);
+
+       put_cross(0, var.yres - 50, 0xff);
+       getxy(ts, &x[3], &y[3]);
+       put_cross(0, var.yres - 50, 0);
+
+       printf("Bot left : X = %4d Y = %4d\n", x[3], y[3]);
+
+       printf("X mult = %d div = %d\n",
+               var.xres - 50, (x[2] + x[1] - x[0] - x[3]) / 2);
+
+       printf("Y mult = %d div = %d\n",
+               var.yres - 50, (y[2] + y[3] - y[0] - y[1]) / 2);
+
+       while (1) {
+               struct ts_sample samp;
+
+               if (ts_read_raw(ts, &samp, 1) < 0) {
+                       perror("ts_read");
+                       exit(1);
+               }
+
+               printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec,
+                       samp.x, samp.y, samp.pressure);
+       }
+}
diff --git a/tests/ts_test.c b/tests/ts_test.c
new file mode 100644 (file)
index 0000000..01fc0b0
--- /dev/null
@@ -0,0 +1,250 @@
+/*
+ *  tslib/src/ts_test.c
+ *
+ *  Copyright (C) 2001 Russell King.
+ *
+ * This file is placed under the GPL.  Please see the file
+ * COPYING for more details.
+ *
+ * $Id: ts_test.c,v 1.1.1.1 2001/12/22 21:12:06 rmk Exp $
+ *
+ * Basic test program for touchscreen library.
+ */
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <linux/fb.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+
+#include "tslib.h"
+
+static int con_fd, fb_fd, last_vt = -1;
+static struct fb_fix_screeninfo fix;
+static struct fb_var_screeninfo var;
+static struct fb_cmap cmap;
+static char *fbuffer;
+
+static int open_framebuffer(void)
+{
+       struct vt_stat vts;
+       char vtname[16];
+       int fd, nr;
+       unsigned short col[2];
+
+       fd = open("/dev/tty1", O_WRONLY);
+       if (fd < 0) {
+               perror("open /dev/tty1");
+               return -1;
+       }
+
+       if (ioctl(fd, VT_OPENQRY, &nr) < 0) {
+               perror("ioctl VT_OPENQRY");
+               return -1;
+       }
+       close(fd);
+
+       sprintf(vtname, "/dev/tty%d", nr);
+
+       con_fd = open(vtname, O_RDWR | O_NDELAY);
+       if (con_fd < 0) {
+               perror("open tty");
+               return -1;
+       }
+
+       if (ioctl(con_fd, VT_GETSTATE, &vts) == 0)
+               last_vt = vts.v_active;
+
+       if (ioctl(con_fd, VT_ACTIVATE, nr) < 0) {
+               perror("VT_ACTIVATE");
+               close(con_fd);
+               return -1;
+       }
+
+       if (ioctl(con_fd, VT_WAITACTIVE, nr) < 0) {
+               perror("VT_WAITACTIVE");
+               close(con_fd);
+               return -1;
+       }
+
+       if (ioctl(con_fd, KDSETMODE, KD_GRAPHICS) < 0) {
+               perror("KDSETMODE");
+               close(con_fd);
+               return -1;
+       }
+
+       fb_fd = open("/dev/fb0", O_RDWR);
+       if (fb_fd == -1) {
+               perror("open /dev/fb");
+               return -1;
+       }
+
+       if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fix) < 0) {
+               perror("ioctl FBIOGET_FSCREENINFO");
+               close(fb_fd);
+               return -1;
+       }
+
+       if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &var) < 0) {
+               perror("ioctl FBIOGET_VSCREENINFO");
+               close(fb_fd);
+               return -1;
+       }
+
+       cmap.start = 0;
+       cmap.len = 2;
+       cmap.red = col;
+       cmap.green = col;
+       cmap.blue = col;
+       cmap.transp = NULL;
+
+       col[0] = 0;
+       col[1] = 0xffff;
+
+       if (ioctl(fb_fd, FBIOGETCMAP, &cmap) < 0) {
+               perror("ioctl FBIOGETCMAP");
+               close(fb_fd);
+               return -1;
+       }
+
+       fbuffer = mmap(NULL, fix.smem_len, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fb_fd, 0);
+       if (fbuffer == (char *)-1) {
+               perror("mmap framebuffer");
+               close(fb_fd);
+               return -1;
+       }
+       return 0;
+}
+
+static void close_framebuffer(void)
+{
+       munmap(fbuffer, fix.smem_len);
+       close(fb_fd);
+
+       if (ioctl(con_fd, KDSETMODE, KD_TEXT) < 0)
+               perror("KDSETMODE");
+
+       if (last_vt >= 0)
+               if (ioctl(con_fd, VT_ACTIVATE, last_vt))
+                       perror("VT_ACTIVATE");
+
+       close(con_fd);
+}
+
+static void sig(int sig)
+{
+       close_framebuffer();
+       fflush(stderr);
+       printf("signal %d caught\n", sig);
+       fflush(stdout);
+       exit(1);
+}
+
+static void put_cross(int x, int y, int c)
+{
+       int off, i, s, e;
+
+       if (x < 0) x = 0;
+       if (y < 0) y = 0;
+       if (x >= var.xres) x = var.xres - 1;
+       if (y >= var.yres) y = var.yres - 1;
+
+       off = y * fix.line_length + x * var.bits_per_pixel / 8;
+
+       switch (var.bits_per_pixel) {
+       case 16:
+               s = y;
+               if (s > 25)
+                       s = 25;
+
+               e = var.yres - y;
+               if (e > 25)
+                       e = 25;
+
+               for (i = -s; i < e; i++) {
+                       fbuffer[off + i * fix.line_length + 0] = c;
+                       fbuffer[off + i * fix.line_length + 1] = c;
+               }
+
+               s = x;
+               if (s > 25)
+                       s = 25;
+               e = var.xres - x;
+               if (e > 25)
+                       e = 25;
+
+               for (i = -s; i < e; i++) {
+                       fbuffer[off + i * 2] = c;
+                       fbuffer[off + i * 2 + 1] = c;
+               }
+               break;
+
+       case 8:
+               break;
+       }
+}
+
+int main()
+{
+       struct tsdev *ts;
+       int x, y;
+
+       signal(SIGSEGV, sig);
+       signal(SIGINT, sig);
+       signal(SIGTERM, sig);
+
+       ts = ts_open("/dev/touchscreen/ucb1x00", 0);
+       if (!ts) {
+               perror("ts_open");
+               exit(1);
+       }
+
+       if (ts_config(ts)) {
+               perror("ts_config");
+               exit(1);
+       }
+
+       if (open_framebuffer()) {
+               close_framebuffer();
+               exit(1);
+       }
+
+       memset(fbuffer, 0, fix.smem_len);
+
+       x = var.xres / 2;
+       y = var.yres / 2;
+
+       put_cross(x, y, 0xff);
+
+       while (1) {
+               struct ts_sample samp;
+               int ret;
+
+               ret = ts_read(ts, &samp, 1);
+
+               if (ret < 0) {
+                       perror("ts_read");
+                       close_framebuffer();
+                       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);
+
+               if (samp.pressure > 100) {
+                       put_cross(x, y, 0);
+                       x = samp.x;
+                       y = samp.y;
+                       put_cross(x, y, 0xff);
+               }
+       }
+}