summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore81
-rw-r--r--COPYING672
-rw-r--r--INSTALL25
-rw-r--r--Makefile.am14
-rw-r--r--README7
-rwxr-xr-xautogen.sh11
-rw-r--r--configure.ac33
-rw-r--r--docs/event-semantics.txt31
-rw-r--r--include/utouch/frame-mtdev.h39
-rw-r--r--include/utouch/frame.h250
-rw-r--r--src/Makefile.am21
-rw-r--r--src/frame-impl.h18
-rw-r--r--src/frame-mtdev.c189
-rw-r--r--src/frame.c303
-rw-r--r--test/Makefile.am0
-rw-r--r--tools/Makefile.am7
-rw-r--r--tools/utouch-frame-test-mtdev.c202
-rw-r--r--utouch-frame.pc.in9
18 files changed, 1912 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cf601fa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,81 @@
1#
2# X.Org module default exclusion patterns
3# The next section if for module specific patterns
4#
5# Do not edit the following section
6# GNU Build System (Autotools)
7aclocal.m4
8autom4te.cache/
9autoscan.log
10ChangeLog
11compile
12config.guess
13config.h
14config.h.in
15config.log
16config-ml.in
17config.py
18config.status
19config.status.lineno
20config.sub
21configure
22configure.scan
23depcomp
24.deps/
25install-sh
26.libs/
27libtool
28libtool.m4
29ltmain.sh
30lt~obsolete.m4
31ltoptions.m4
32ltsugar.m4
33ltversion.m4
34Makefile
35Makefile.in
36mdate-sh
37missing
38mkinstalldirs
39*.pc
40py-compile
41stamp-h?
42symlink-tree
43texinfo.tex
44ylwrap
45
46# Do not edit the following section
47# Edit Compile Debug Document Distribute
48*~
49*.[0-9]
50*.[0-9]x
51*.bak
52*.bin
53core
54*.dll
55*.exe
56*-ISO*.bdf
57*-JIS*.bdf
58*-KOI8*.bdf
59*.kld
60*.ko
61*.ko.cmd
62*.lai
63*.l[oa]
64*.[oa]
65*.obj
66*.patch
67*.so
68*.pcf.gz
69*.pdb
70*.tar.bz2
71*.tar.gz
72#
73# Add & Override patterns for mtdev
74#
75# Edit the following section as needed
76# For example, !report.pc overrides *.pc. See 'man gitignore'
77#
78.bzrignore
79.bzr
80patches
81tools/utouch-frame-test-mtdev
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..cf2bee5
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,672 @@
1utouch-frame - Touch Frame Library (GPLv3 license)
2
3 Copyright (C) 2010 Canonical Ltd.
4 Copyright (C) 2010 Henrik Rydberg <rydberg@bitmath.org>
5
6 Preamble
7
8 The GNU General Public License is a free, copyleft license for
9software and other kinds of works.
10
11 The licenses for most software and other practical works are designed
12to take away your freedom to share and change the works. By contrast,
13the GNU General Public License is intended to guarantee your freedom to
14share and change all versions of a program--to make sure it remains free
15software for all its users. We, the Free Software Foundation, use the
16GNU General Public License for most of our software; it applies also to
17any other work released this way by its authors. You can apply it to
18your programs, too.
19
20 When we speak of free software, we are referring to freedom, not
21price. Our General Public Licenses are designed to make sure that you
22have the freedom to distribute copies of free software (and charge for
23them if you wish), that you receive source code or can get it if you
24want it, that you can change the software or use pieces of it in new
25free programs, and that you know you can do these things.
26
27 To protect your rights, we need to prevent others from denying you
28these rights or asking you to surrender the rights. Therefore, you have
29certain responsibilities if you distribute copies of the software, or if
30you modify it: responsibilities to respect the freedom of others.
31
32 For example, if you distribute copies of such a program, whether
33gratis or for a fee, you must pass on to the recipients the same
34freedoms that you received. You must make sure that they, too, receive
35or can get the source code. And you must show them these terms so they
36know their rights.
37
38 Developers that use the GNU GPL protect your rights with two steps:
39(1) assert copyright on the software, and (2) offer you this License
40giving you legal permission to copy, distribute and/or modify it.
41
42 For the developers' and authors' protection, the GPL clearly explains
43that there is no warranty for this free software. For both users' and
44authors' sake, the GPL requires that modified versions be marked as
45changed, so that their problems will not be attributed erroneously to
46authors of previous versions.
47
48 Some devices are designed to deny users access to install or run
49modified versions of the software inside them, although the manufacturer
50can do so. This is fundamentally incompatible with the aim of
51protecting users' freedom to change the software. The systematic
52pattern of such abuse occurs in the area of products for individuals to
53use, which is precisely where it is most unacceptable. Therefore, we
54have designed this version of the GPL to prohibit the practice for those
55products. If such problems arise substantially in other domains, we
56stand ready to extend this provision to those domains in future versions
57of the GPL, as needed to protect the freedom of users.
58
59 Finally, every program is threatened constantly by software patents.
60States should not allow patents to restrict development and use of
61software on general-purpose computers, but in those that do, we wish to
62avoid the special danger that patents applied to a free program could
63make it effectively proprietary. To prevent this, the GPL assures that
64patents cannot be used to render the program non-free.
65
66 The precise terms and conditions for copying, distribution and
67modification follow.
68
69 TERMS AND CONDITIONS
70
71 0. Definitions.
72
73 "This License" refers to version 3 of the GNU General Public License.
74
75 "Copyright" also means copyright-like laws that apply to other kinds of
76works, such as semiconductor masks.
77
78 "The Program" refers to any copyrightable work licensed under this
79License. Each licensee is addressed as "you". "Licensees" and
80"recipients" may be individuals or organizations.
81
82 To "modify" a work means to copy from or adapt all or part of the work
83in a fashion requiring copyright permission, other than the making of an
84exact copy. The resulting work is called a "modified version" of the
85earlier work or a work "based on" the earlier work.
86
87 A "covered work" means either the unmodified Program or a work based
88on the Program.
89
90 To "propagate" a work means to do anything with it that, without
91permission, would make you directly or secondarily liable for
92infringement under applicable copyright law, except executing it on a
93computer or modifying a private copy. Propagation includes copying,
94distribution (with or without modification), making available to the
95public, and in some countries other activities as well.
96
97 To "convey" a work means any kind of propagation that enables other
98parties to make or receive copies. Mere interaction with a user through
99a computer network, with no transfer of a copy, is not conveying.
100
101 An interactive user interface displays "Appropriate Legal Notices"
102to the extent that it includes a convenient and prominently visible
103feature that (1) displays an appropriate copyright notice, and (2)
104tells the user that there is no warranty for the work (except to the
105extent that warranties are provided), that licensees may convey the
106work under this License, and how to view a copy of this License. If
107the interface presents a list of user commands or options, such as a
108menu, a prominent item in the list meets this criterion.
109
110 1. Source Code.
111
112 The "source code" for a work means the preferred form of the work
113for making modifications to it. "Object code" means any non-source
114form of a work.
115
116 A "Standard Interface" means an interface that either is an official
117standard defined by a recognized standards body, or, in the case of
118interfaces specified for a particular programming language, one that
119is widely used among developers working in that language.
120
121 The "System Libraries" of an executable work include anything, other
122than the work as a whole, that (a) is included in the normal form of
123packaging a Major Component, but which is not part of that Major
124Component, and (b) serves only to enable use of the work with that
125Major Component, or to implement a Standard Interface for which an
126implementation is available to the public in source code form. A
127"Major Component", in this context, means a major essential component
128(kernel, window system, and so on) of the specific operating system
129(if any) on which the executable work runs, or a compiler used to
130produce the work, or an object code interpreter used to run it.
131
132 The "Corresponding Source" for a work in object code form means all
133the source code needed to generate, install, and (for an executable
134work) run the object code and to modify the work, including scripts to
135control those activities. However, it does not include the work's
136System Libraries, or general-purpose tools or generally available free
137programs which are used unmodified in performing those activities but
138which are not part of the work. For example, Corresponding Source
139includes interface definition files associated with source files for
140the work, and the source code for shared libraries and dynamically
141linked subprograms that the work is specifically designed to require,
142such as by intimate data communication or control flow between those
143subprograms and other parts of the work.
144
145 The Corresponding Source need not include anything that users
146can regenerate automatically from other parts of the Corresponding
147Source.
148
149 The Corresponding Source for a work in source code form is that
150same work.
151
152 2. Basic Permissions.
153
154 All rights granted under this License are granted for the term of
155copyright on the Program, and are irrevocable provided the stated
156conditions are met. This License explicitly affirms your unlimited
157permission to run the unmodified Program. The output from running a
158covered work is covered by this License only if the output, given its
159content, constitutes a covered work. This License acknowledges your
160rights of fair use or other equivalent, as provided by copyright law.
161
162 You may make, run and propagate covered works that you do not
163convey, without conditions so long as your license otherwise remains
164in force. You may convey covered works to others for the sole purpose
165of having them make modifications exclusively for you, or provide you
166with facilities for running those works, provided that you comply with
167the terms of this License in conveying all material for which you do
168not control copyright. Those thus making or running the covered works
169for you must do so exclusively on your behalf, under your direction
170and control, on terms that prohibit them from making any copies of
171your copyrighted material outside their relationship with you.
172
173 Conveying under any other circumstances is permitted solely under
174the conditions stated below. Sublicensing is not allowed; section 10
175makes it unnecessary.
176
177 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
178
179 No covered work shall be deemed part of an effective technological
180measure under any applicable law fulfilling obligations under article
18111 of the WIPO copyright treaty adopted on 20 December 1996, or
182similar laws prohibiting or restricting circumvention of such
183measures.
184
185 When you convey a covered work, you waive any legal power to forbid
186circumvention of technological measures to the extent such circumvention
187is effected by exercising rights under this License with respect to
188the covered work, and you disclaim any intention to limit operation or
189modification of the work as a means of enforcing, against the work's
190users, your or third parties' legal rights to forbid circumvention of
191technological measures.
192
193 4. Conveying Verbatim Copies.
194
195 You may convey verbatim copies of the Program's source code as you
196receive it, in any medium, provided that you conspicuously and
197appropriately publish on each copy an appropriate copyright notice;
198keep intact all notices stating that this License and any
199non-permissive terms added in accord with section 7 apply to the code;
200keep intact all notices of the absence of any warranty; and give all
201recipients a copy of this License along with the Program.
202
203 You may charge any price or no price for each copy that you convey,
204and you may offer support or warranty protection for a fee.
205
206 5. Conveying Modified Source Versions.
207
208 You may convey a work based on the Program, or the modifications to
209produce it from the Program, in the form of source code under the
210terms of section 4, provided that you also meet all of these conditions:
211
212 a) The work must carry prominent notices stating that you modified
213 it, and giving a relevant date.
214
215 b) The work must carry prominent notices stating that it is
216 released under this License and any conditions added under section
217 7. This requirement modifies the requirement in section 4 to
218 "keep intact all notices".
219
220 c) You must license the entire work, as a whole, under this
221 License to anyone who comes into possession of a copy. This
222 License will therefore apply, along with any applicable section 7
223 additional terms, to the whole of the work, and all its parts,
224 regardless of how they are packaged. This License gives no
225 permission to license the work in any other way, but it does not
226 invalidate such permission if you have separately received it.
227
228 d) If the work has interactive user interfaces, each must display
229 Appropriate Legal Notices; however, if the Program has interactive
230 interfaces that do not display Appropriate Legal Notices, your
231 work need not make them do so.
232
233 A compilation of a covered work with other separate and independent
234works, which are not by their nature extensions of the covered work,
235and which are not combined with it such as to form a larger program,
236in or on a volume of a storage or distribution medium, is called an
237"aggregate" if the compilation and its resulting copyright are not
238used to limit the access or legal rights of the compilation's users
239beyond what the individual works permit. Inclusion of a covered work
240in an aggregate does not cause this License to apply to the other
241parts of the aggregate.
242
243 6. Conveying Non-Source Forms.
244
245 You may convey a covered work in object code form under the terms
246of sections 4 and 5, provided that you also convey the
247machine-readable Corresponding Source under the terms of this License,
248in one of these ways:
249
250 a) Convey the object code in, or embodied in, a physical product
251 (including a physical distribution medium), accompanied by the
252 Corresponding Source fixed on a durable physical medium
253 customarily used for software interchange.
254
255 b) Convey the object code in, or embodied in, a physical product
256 (including a physical distribution medium), accompanied by a
257 written offer, valid for at least three years and valid for as
258 long as you offer spare parts or customer support for that product
259 model, to give anyone who possesses the object code either (1) a
260 copy of the Corresponding Source for all the software in the
261 product that is covered by this License, on a durable physical
262 medium customarily used for software interchange, for a price no
263 more than your reasonable cost of physically performing this
264 conveying of source, or (2) access to copy the
265 Corresponding Source from a network server at no charge.
266
267 c) Convey individual copies of the object code with a copy of the
268 written offer to provide the Corresponding Source. This
269 alternative is allowed only occasionally and noncommercially, and
270 only if you received the object code with such an offer, in accord
271 with subsection 6b.
272
273 d) Convey the object code by offering access from a designated
274 place (gratis or for a charge), and offer equivalent access to the
275 Corresponding Source in the same way through the same place at no
276 further charge. You need not require recipients to copy the
277 Corresponding Source along with the object code. If the place to
278 copy the object code is a network server, the Corresponding Source
279 may be on a different server (operated by you or a third party)
280 that supports equivalent copying facilities, provided you maintain
281 clear directions next to the object code saying where to find the
282 Corresponding Source. Regardless of what server hosts the
283 Corresponding Source, you remain obligated to ensure that it is
284 available for as long as needed to satisfy these requirements.
285
286 e) Convey the object code using peer-to-peer transmission, provided
287 you inform other peers where the object code and Corresponding
288 Source of the work are being offered to the general public at no
289 charge under subsection 6d.
290
291 A separable portion of the object code, whose source code is excluded
292from the Corresponding Source as a System Library, need not be
293included in conveying the object code work.
294
295 A "User Product" is either (1) a "consumer product", which means any
296tangible personal property which is normally used for personal, family,
297or household purposes, or (2) anything designed or sold for incorporation
298into a dwelling. In determining whether a product is a consumer product,
299doubtful cases shall be resolved in favor of coverage. For a particular
300product received by a particular user, "normally used" refers to a
301typical or common use of that class of product, regardless of the status
302of the particular user or of the way in which the particular user
303actually uses, or expects or is expected to use, the product. A product
304is a consumer product regardless of whether the product has substantial
305commercial, industrial or non-consumer uses, unless such uses represent
306the only significant mode of use of the product.
307
308 "Installation Information" for a User Product means any methods,
309procedures, authorization keys, or other information required to install
310and execute modified versions of a covered work in that User Product from
311a modified version of its Corresponding Source. The information must
312suffice to ensure that the continued functioning of the modified object
313code is in no case prevented or interfered with solely because
314modification has been made.
315
316 If you convey an object code work under this section in, or with, or
317specifically for use in, a User Product, and the conveying occurs as
318part of a transaction in which the right of possession and use of the
319User Product is transferred to the recipient in perpetuity or for a
320fixed term (regardless of how the transaction is characterized), the
321Corresponding Source conveyed under this section must be accompanied
322by the Installation Information. But this requirement does not apply
323if neither you nor any third party retains the ability to install
324modified object code on the User Product (for example, the work has
325been installed in ROM).
326
327 The requirement to provide Installation Information does not include a
328requirement to continue to provide support service, warranty, or updates
329for a work that has been modified or installed by the recipient, or for
330the User Product in which it has been modified or installed. Access to a
331network may be denied when the modification itself materially and
332adversely affects the operation of the network or violates the rules and
333protocols for communication across the network.
334
335 Corresponding Source conveyed, and Installation Information provided,
336in accord with this section must be in a format that is publicly
337documented (and with an implementation available to the public in
338source code form), and must require no special password or key for
339unpacking, reading or copying.
340
341 7. Additional Terms.
342
343 "Additional permissions" are terms that supplement the terms of this
344License by making exceptions from one or more of its conditions.
345Additional permissions that are applicable to the entire Program shall
346be treated as though they were included in this License, to the extent
347that they are valid under applicable law. If additional permissions
348apply only to part of the Program, that part may be used separately
349under those permissions, but the entire Program remains governed by
350this License without regard to the additional permissions.
351
352 When you convey a copy of a covered work, you may at your option
353remove any additional permissions from that copy, or from any part of
354it. (Additional permissions may be written to require their own
355removal in certain cases when you modify the work.) You may place
356additional permissions on material, added by you to a covered work,
357for which you have or can give appropriate copyright permission.
358
359 Notwithstanding any other provision of this License, for material you
360add to a covered work, you may (if authorized by the copyright holders of
361that material) supplement the terms of this License with terms:
362
363 a) Disclaiming warranty or limiting liability differently from the
364 terms of sections 15 and 16 of this License; or
365
366 b) Requiring preservation of specified reasonable legal notices or
367 author attributions in that material or in the Appropriate Legal
368 Notices displayed by works containing it; or
369
370 c) Prohibiting misrepresentation of the origin of that material, or
371 requiring that modified versions of such material be marked in
372 reasonable ways as different from the original version; or
373
374 d) Limiting the use for publicity purposes of names of licensors or
375 authors of the material; or
376
377 e) Declining to grant rights under trademark law for use of some
378 trade names, trademarks, or service marks; or
379
380 f) Requiring indemnification of licensors and authors of that
381 material by anyone who conveys the material (or modified versions of
382 it) with contractual assumptions of liability to the recipient, for
383 any liability that these contractual assumptions directly impose on
384 those licensors and authors.
385
386 All other non-permissive additional terms are considered "further
387restrictions" within the meaning of section 10. If the Program as you
388received it, or any part of it, contains a notice stating that it is
389governed by this License along with a term that is a further
390restriction, you may remove that term. If a license document contains
391a further restriction but permits relicensing or conveying under this
392License, you may add to a covered work material governed by the terms
393of that license document, provided that the further restriction does
394not survive such relicensing or conveying.
395
396 If you add terms to a covered work in accord with this section, you
397must place, in the relevant source files, a statement of the
398additional terms that apply to those files, or a notice indicating
399where to find the applicable terms.
400
401 Additional terms, permissive or non-permissive, may be stated in the
402form of a separately written license, or stated as exceptions;
403the above requirements apply either way.
404
405 8. Termination.
406
407 You may not propagate or modify a covered work except as expressly
408provided under this License. Any attempt otherwise to propagate or
409modify it is void, and will automatically terminate your rights under
410this License (including any patent licenses granted under the third
411paragraph of section 11).
412
413 However, if you cease all violation of this License, then your
414license from a particular copyright holder is reinstated (a)
415provisionally, unless and until the copyright holder explicitly and
416finally terminates your license, and (b) permanently, if the copyright
417holder fails to notify you of the violation by some reasonable means
418prior to 60 days after the cessation.
419
420 Moreover, your license from a particular copyright holder is
421reinstated permanently if the copyright holder notifies you of the
422violation by some reasonable means, this is the first time you have
423received notice of violation of this License (for any work) from that
424copyright holder, and you cure the violation prior to 30 days after
425your receipt of the notice.
426
427 Termination of your rights under this section does not terminate the
428licenses of parties who have received copies or rights from you under
429this License. If your rights have been terminated and not permanently
430reinstated, you do not qualify to receive new licenses for the same
431material under section 10.
432
433 9. Acceptance Not Required for Having Copies.
434
435 You are not required to accept this License in order to receive or
436run a copy of the Program. Ancillary propagation of a covered work
437occurring solely as a consequence of using peer-to-peer transmission
438to receive a copy likewise does not require acceptance. However,
439nothing other than this License grants you permission to propagate or
440modify any covered work. These actions infringe copyright if you do
441not accept this License. Therefore, by modifying or propagating a
442covered work, you indicate your acceptance of this License to do so.
443
444 10. Automatic Licensing of Downstream Recipients.
445
446 Each time you convey a covered work, the recipient automatically
447receives a license from the original licensors, to run, modify and
448propagate that work, subject to this License. You are not responsible
449for enforcing compliance by third parties with this License.
450
451 An "entity transaction" is a transaction transferring control of an
452organization, or substantially all assets of one, or subdividing an
453organization, or merging organizations. If propagation of a covered
454work results from an entity transaction, each party to that
455transaction who receives a copy of the work also receives whatever
456licenses to the work the party's predecessor in interest had or could
457give under the previous paragraph, plus a right to possession of the
458Corresponding Source of the work from the predecessor in interest, if
459the predecessor has it or can get it with reasonable efforts.
460
461 You may not impose any further restrictions on the exercise of the
462rights granted or affirmed under this License. For example, you may
463not impose a license fee, royalty, or other charge for exercise of
464rights granted under this License, and you may not initiate litigation
465(including a cross-claim or counterclaim in a lawsuit) alleging that
466any patent claim is infringed by making, using, selling, offering for
467sale, or importing the Program or any portion of it.
468
469 11. Patents.
470
471 A "contributor" is a copyright holder who authorizes use under this
472License of the Program or a work on which the Program is based. The
473work thus licensed is called the contributor's "contributor version".
474
475 A contributor's "essential patent claims" are all patent claims
476owned or controlled by the contributor, whether already acquired or
477hereafter acquired, that would be infringed by some manner, permitted
478by this License, of making, using, or selling its contributor version,
479but do not include claims that would be infringed only as a
480consequence of further modification of the contributor version. For
481purposes of this definition, "control" includes the right to grant
482patent sublicenses in a manner consistent with the requirements of
483this License.
484
485 Each contributor grants you a non-exclusive, worldwide, royalty-free
486patent license under the contributor's essential patent claims, to
487make, use, sell, offer for sale, import and otherwise run, modify and
488propagate the contents of its contributor version.
489
490 In the following three paragraphs, a "patent license" is any express
491agreement or commitment, however denominated, not to enforce a patent
492(such as an express permission to practice a patent or covenant not to
493sue for patent infringement). To "grant" such a patent license to a
494party means to make such an agreement or commitment not to enforce a
495patent against the party.
496
497 If you convey a covered work, knowingly relying on a patent license,
498and the Corresponding Source of the work is not available for anyone
499to copy, free of charge and under the terms of this License, through a
500publicly available network server or other readily accessible means,
501then you must either (1) cause the Corresponding Source to be so
502available, or (2) arrange to deprive yourself of the benefit of the
503patent license for this particular work, or (3) arrange, in a manner
504consistent with the requirements of this License, to extend the patent
505license to downstream recipients. "Knowingly relying" means you have
506actual knowledge that, but for the patent license, your conveying the
507covered work in a country, or your recipient's use of the covered work
508in a country, would infringe one or more identifiable patents in that
509country that you have reason to believe are valid.
510
511 If, pursuant to or in connection with a single transaction or
512arrangement, you convey, or propagate by procuring conveyance of, a
513covered work, and grant a patent license to some of the parties
514receiving the covered work authorizing them to use, propagate, modify
515or convey a specific copy of the covered work, then the patent license
516you grant is automatically extended to all recipients of the covered
517work and works based on it.
518
519 A patent license is "discriminatory" if it does not include within
520the scope of its coverage, prohibits the exercise of, or is
521conditioned on the non-exercise of one or more of the rights that are
522specifically granted under this License. You may not convey a covered
523work if you are a party to an arrangement with a third party that is
524in the business of distributing software, under which you make payment
525to the third party based on the extent of your activity of conveying
526the work, and under which the third party grants, to any of the
527parties who would receive the covered work from you, a discriminatory
528patent license (a) in connection with copies of the covered work
529conveyed by you (or copies made from those copies), or (b) primarily
530for and in connection with specific products or compilations that
531contain the covered work, unless you entered into that arrangement,
532or that patent license was granted, prior to 28 March 2007.
533
534 Nothing in this License shall be construed as excluding or limiting
535any implied license or other defenses to infringement that may
536otherwise be available to you under applicable patent law.
537
538 12. No Surrender of Others' Freedom.
539
540 If conditions are imposed on you (whether by court order, agreement or
541otherwise) that contradict the conditions of this License, they do not
542excuse you from the conditions of this License. If you cannot convey a
543covered work so as to satisfy simultaneously your obligations under this
544License and any other pertinent obligations, then as a consequence you may
545not convey it at all. For example, if you agree to terms that obligate you
546to collect a royalty for further conveying from those to whom you convey
547the Program, the only way you could satisfy both those terms and this
548License would be to refrain entirely from conveying the Program.
549
550 13. Use with the GNU Affero General Public License.
551
552 Notwithstanding any other provision of this License, you have
553permission to link or combine any covered work with a work licensed
554under version 3 of the GNU Affero General Public License into a single
555combined work, and to convey the resulting work. The terms of this
556License will continue to apply to the part which is the covered work,
557but the special requirements of the GNU Affero General Public License,
558section 13, concerning interaction through a network will apply to the
559combination as such.
560
561 14. Revised Versions of this License.
562
563 The Free Software Foundation may publish revised and/or new versions of
564the GNU General Public License from time to time. Such new versions will
565be similar in spirit to the present version, but may differ in detail to
566address new problems or concerns.
567
568 Each version is given a distinguishing version number. If the
569Program specifies that a certain numbered version of the GNU General
570Public License "or any later version" applies to it, you have the
571option of following the terms and conditions either of that numbered
572version or of any later version published by the Free Software
573Foundation. If the Program does not specify a version number of the
574GNU General Public License, you may choose any version ever published
575by the Free Software Foundation.
576
577 If the Program specifies that a proxy can decide which future
578versions of the GNU General Public License can be used, that proxy's
579public statement of acceptance of a version permanently authorizes you
580to choose that version for the Program.
581
582 Later license versions may give you additional or different
583permissions. However, no additional obligations are imposed on any
584author or copyright holder as a result of your choosing to follow a
585later version.
586
587 15. Disclaimer of Warranty.
588
589 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
598 16. Limitation of Liability.
599
600 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608SUCH DAMAGES.
609
610 17. Interpretation of Sections 15 and 16.
611
612 If the disclaimer of warranty and limitation of liability provided
613above cannot be given local legal effect according to their terms,
614reviewing courts shall apply local law that most closely approximates
615an absolute waiver of all civil liability in connection with the
616Program, unless a warranty or assumption of liability accompanies a
617copy of the Program in return for a fee.
618
619 END OF TERMS AND CONDITIONS
620
621 How to Apply These Terms to Your New Programs
622
623 If you develop a new program, and you want it to be of the greatest
624possible use to the public, the best way to achieve this is to make it
625free software which everyone can redistribute and change under these terms.
626
627 To do so, attach the following notices to the program. It is safest
628to attach them to the start of each source file to most effectively
629state the exclusion of warranty; and each file should have at least
630the "copyright" line and a pointer to where the full notice is found.
631
632 <one line to give the program's name and a brief idea of what it does.>
633 Copyright (C) <year> <name of author>
634
635 This program is free software: you can redistribute it and/or modify
636 it under the terms of the GNU General Public License as published by
637 the Free Software Foundation, either version 3 of the License, or
638 (at your option) any later version.
639
640 This program is distributed in the hope that it will be useful,
641 but WITHOUT ANY WARRANTY; without even the implied warranty of
642 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 GNU General Public License for more details.
644
645 You should have received a copy of the GNU General Public License
646 along with this program. If not, see <http://www.gnu.org/licenses/>.
647
648Also add information on how to contact you by electronic and paper mail.
649
650 If the program does terminal interaction, make it output a short
651notice like this when it starts in an interactive mode:
652
653 <program> Copyright (C) <year> <name of author>
654 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
655 This is free software, and you are welcome to redistribute it
656 under certain conditions; type `show c' for details.
657
658The hypothetical commands `show w' and `show c' should show the appropriate
659parts of the General Public License. Of course, your program's commands
660might be different; for a GUI interface, you would use an "about box".
661
662 You should also get your employer (if you work as a programmer) or school,
663if any, to sign a "copyright disclaimer" for the program, if necessary.
664For more information on this, and how to apply and follow the GNU GPL, see
665<http://www.gnu.org/licenses/>.
666
667 The GNU General Public License does not permit incorporating your program
668into proprietary programs. If your program is a subroutine library, you
669may consider it more useful to permit linking proprietary applications with
670the library. If this is what you want to do, use the GNU Lesser General
671Public License instead of this License. But first, please read
672<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..187d071
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,25 @@
1utouch-frame - Touch Frame Library
2
3To build, you need to have the autoconf, libtool, libutouch-evemu-dev
4and mtdev-dev packages installed. Then, do
5
6 ./autogen.sh
7 ./configure
8 make
9
10To test the touch properties of an MT device at /dev/input/eventX, do
11
12 sudo ./test/utouch-frame-test /dev/input/eventX
13
14You should be able to see touch events in the terminal. After five
15seconds of inactivity, the program exits.
16
17To install utouch-frame, do
18
19 sudo make install
20
21By default, utouch-frame installs to /usr/local. To change, use the --prefix
22configure option.
23
24Enjoy,
25Henrik
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..6a94173
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,14 @@
1SUBDIRS = src tools test
2
3pkgconfigdir = $(libdir)/pkgconfig
4pkgconfig_DATA = utouch-frame.pc
5
6INCLUDES = $(top_srcdir)/include/
7
8.PHONY: ChangeLog INSTALL
9INSTALL:
10 $(INSTALL_CMD)
11ChangeLog:
12 bzr log > ChangeLog
13
14dist-hook: ChangeLog INSTALL
diff --git a/README b/README
new file mode 100644
index 0000000..340f839
--- /dev/null
+++ b/README
@@ -0,0 +1,7 @@
1utouch-frame - Touch Frame Library
2
3This tree handles the buildup and synchronization of a set of
4simultaneous touches. The library is input agnostic.
5
6Enjoy,
7Henrik
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..a08311b
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,11 @@
1#! /bin/sh
2
3srcdir=`dirname $0`
4test -z "$srcdir" && srcdir=.
5
6ORIGDIR=`pwd`
7cd $srcdir
8
9autoreconf -v --install || exit 1
10cd $ORIGDIR || exit $?
11
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..0ff758f
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,33 @@
1# Initialize Autoconf
2AC_PREREQ([2.60])
3AC_INIT([Touch Frame Library],
4 [1.0.0],
5 [],
6 [utouch-frame])
7AC_CONFIG_SRCDIR([Makefile.am])
8AC_CONFIG_HEADERS([config.h])
9AC_CONFIG_AUX_DIR([config-aux])
10
11# Initialize Automake
12AM_INIT_AUTOMAKE([foreign dist-bzip2])
13AM_MAINTAINER_MODE
14
15LIB_VERSION=1:0:0
16AC_SUBST([LIB_VERSION])
17
18# Initialize libtool
19AC_PROG_LIBTOOL
20
21# Checks for programs.
22AC_PROG_CC
23AC_PROG_INSTALL
24
25PKG_CHECK_MODULES([MTDEV], [mtdev >= 1.1])
26PKG_CHECK_MODULES([EVEMU], [utouch-evemu >= 1.0])
27
28AC_CONFIG_FILES([Makefile
29 src/Makefile
30 test/Makefile
31 tools/Makefile
32 utouch-frame.pc])
33AC_OUTPUT
diff --git a/docs/event-semantics.txt b/docs/event-semantics.txt
new file mode 100644
index 0000000..87afe4e
--- /dev/null
+++ b/docs/event-semantics.txt
@@ -0,0 +1,31 @@
1FRAME
2
3The touch frame, consisting of a set of simultaneous contacts.
4
5CONTACT
6
7The current MT contact configuration. Changes whenever an id changes.
8
9TOUCH
10
11The current touch configuration. Changes whenever the number of contacts
12changes. A touch frame is well-defined a time T after the last
13configuration change. This allows for simultaneous touches being
14handled. It also allows for a very quick change of one finger to
15another. Such an action changes the CONTACT state, but it does not change
16the TOUCH state.
17
18DRAG/PINCH/ROTATE
19
20A transformation based on the touch frame.
21
22GESTURES
23
24Two creation points may be grouped if they are close in space-time, and
25they are always close within the same controlling entity. There can be only
26one controlling entity per point, and that decision is made upon
27creation. The window manager is a controlling entity. Ambiguities can occur
28between close points, and are resolved either by state rule or by
29priority. Relaxing the time closeness criteria has no effect within a
30controlling entity, but creates a larger set of ambiguous and undesired
31groupings, which is considered inferior.
diff --git a/include/utouch/frame-mtdev.h b/include/utouch/frame-mtdev.h
new file mode 100644
index 0000000..f3957b9
--- /dev/null
+++ b/include/utouch/frame-mtdev.h
@@ -0,0 +1,39 @@
1/*****************************************************************************
2 *
3 * utouch-frame - Touch Frame Library
4 *
5 * Copyright (C) 2010-2011 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ****************************************************************************/
21
22#ifndef _UTOUCH_FRAME_MTDEV_H
23#define _UTOUCH_FRAME_MTDEV_H
24
25#define MTDEV_NO_LEGACY_API
26
27#include <utouch/frame.h>
28#include <evemu.h>
29#include <mtdev.h>
30
31int utouch_frame_is_supported_mtdev(const struct evemu_device *dev);
32
33int utouch_frame_init_mtdev(utouch_frame_handle fh,
34 const struct evemu_device *dev);
35
36const struct utouch_frame *
37utouch_frame_pump_mtdev(utouch_frame_handle fh, const struct input_event *ev);
38
39#endif
diff --git a/include/utouch/frame.h b/include/utouch/frame.h
new file mode 100644
index 0000000..08e4e26
--- /dev/null
+++ b/include/utouch/frame.h
@@ -0,0 +1,250 @@
1/*****************************************************************************
2 *
3 * utouch-frame - Touch Frame Library
4 *
5 * Copyright (C) 2010-2011 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ****************************************************************************/
21
22#ifndef _UTOUCH_FRAME_H
23#define _UTOUCH_FRAME_H
24
25#include <stdint.h>
26
27#define UTOUCH_FRAME_VERSION 0x00001000
28
29/**
30 * struct utouch_surface - device surface details
31 * @needs_pointer: device needs a screen pointer to function
32 * @is_direct: surface is a direct device (e.g. touchscreen)
33 * @is_buttonpad: surface has button(s) under it
34 * @is_semi_mt: surface detects bounding rectangle only
35 * @use_touch_major: device uses major axis for contact modulation
36 * @use_touch_minor: device uses minor axis for contact modulation
37 * @use_width_major: device uses approaching major axis for contact modulation
38 * @use_width_minor: device uses approaching minor axis for contact modulation
39 * @use_orientation: device uses ellipse orientation for contact modulation
40 * @use_pressure: device uses pressure for contact modulation
41 * @use_distance: device uses hover distance
42 * @phys_width: physical width in millimeters (mm)
43 * @phys_height: physical height in millimeters (mm)
44 * @phys_pressure: maximal physical pressure (N/cm^2)
45 * @min_x: minimum horizontal coordinate value
46 * @min_y: minimum vertical coordinate value
47 * @max_x: maximum horizontal coordinate value
48 * @max_y: maximum vertical coordinate value
49 * @max_pressure: maximum pressure coordinate value
50 *
51 * Device properties and touch surface details. Later versions of this
52 * struct may grow in size, but will remain binary compatible with
53 * older versions.
54 */
55struct utouch_surface {
56 int needs_pointer;
57 int is_direct;
58 int is_buttonpad;
59 int is_semi_mt;
60 int use_touch_major;
61 int use_touch_minor;
62 int use_width_major;
63 int use_width_minor;
64 int use_orientation;
65 int use_pressure;
66 int use_distance;
67 float phys_width;
68 float phys_height;
69 float phys_pressure;
70 float min_x;
71 float min_y;
72 float max_x;
73 float max_y;
74 float max_pressure;
75};
76
77#define UTOUCH_TOOL_FINGER 0
78#define UTOUCH_TOOL_PEN 1
79
80/**
81 * struct utouch_contact - surface contact details
82 * @prev: pointer to same slot of previous frame
83 * @active: currently in use
84 * @slot: slot occupied by this contact
85 * @id: unique id of this contact
86 * @tool_type: the tool type of this contact
87 * @x: horizontal center position coordinate (surface units)
88 * @y: vertical center position coordinate (surface units)
89 * @touch_major: major axis of contact (surface units)
90 * @touch_minor: minor axis of contact (surface units)
91 * @width_major: major axis of approaching contact (surface units)
92 * @width_minor: minor axis of approaching contact (surface units)
93 * @orientation: direction of ellipse (left: -Pi/2, up: 0, right: Pi/2)
94 * @pressure: pressure of contact (pressure units)
95 * @distance: distance of contact (surface units)
96 *
97 * Surface contact details. Later versions of this struct may grow in
98 * size, but will remain binary compatible with older versions.
99 *
100 * Contact structures are connected into one ring per slot. The
101 * previous contact pointers are ABI agnostic, owned by the engine,
102 * and have engine scope.
103 */
104struct utouch_contact {
105 const struct utouch_contact *prev;
106 int active;
107 int slot;
108 int id;
109 int tool_type;
110 float x;
111 float y;
112 float touch_major;
113 float touch_minor;
114 float width_major;
115 float width_minor;
116 float orientation;
117 float pressure;
118 float distance;
119};
120
121/* time in milliseconds */
122typedef uint64_t utouch_frame_time_t;
123
124/* the frame engine handle */
125typedef struct utouch_frame_engine *utouch_frame_handle;
126
127/**
128 * struct utouch_frame - emitted frame details
129 * @prev: pointer to previous frame
130 * @sequence_id: frame sequence number
131 * @revision: changes whenever the contact count changes
132 * @slot_revision: changes whenever the slot id array change
133 * @num_active: the number of contacts in the active array
134 * @time: time of frame completion (ms)
135 * @mod_time: time of last contact count change (ms)
136 * @slot_mod_time: time of last slot id array change (ms)
137 * @active: the array of active contacts
138 *
139 * Contact frame details. Later versions of this struct may grow in
140 * size, but will remain binary compatible with older versions.
141 *
142 * Frames are connected into a ring. The previous frame pointer is ABI
143 * agnostic, owned by the engine, and has engine scope.
144 */
145struct utouch_frame {
146 const struct utouch_frame *prev;
147 unsigned int sequence_id;
148 unsigned int revision;
149 unsigned int slot_revision;
150 unsigned int num_active;
151 utouch_frame_time_t time;
152 utouch_frame_time_t mod_time;
153 utouch_frame_time_t slot_mod_time;
154 struct utouch_contact **active;
155 struct utouch_contact **slots;
156};
157
158/**
159 * utouch_frame_get_version - get library abi version
160 *
161 * Returns the version of the library, which may be different
162 * from the api version of the compiled user program.
163 */
164unsigned int utouch_frame_get_version(void);
165
166utouch_frame_handle utouch_frame_new_engine_raw(unsigned int num_frames,
167 unsigned int num_slots,
168 unsigned int frame_rate,
169 unsigned int version,
170 unsigned int surface_size,
171 unsigned int frame_size,
172 unsigned int slot_size);
173
174/**
175 * utouch_frame_new_engine - allocate a new frame engine
176 * @num_frames: number of frames in cyclic buffer
177 * @num_slots: maximum number of slots per frame
178 * @frame_rate: maximum frame rate (frames/s)
179 *
180 * Allocates memory, initializes the internal engine and returns a
181 * handle to it. A rate of 100 frames per second is normal.
182 */
183#define utouch_frame_new_engine(num_frames, num_slots, frame_rate) \
184 utouch_frame_new_engine_raw(num_frames, \
185 num_slots, \
186 frame_rate, \
187 UTOUCH_FRAME_VERSION, \
188 sizeof(struct utouch_surface), \
189 sizeof(struct utouch_frame), \
190 sizeof(struct utouch_contact))
191
192/**
193 * utouch_frame_delete_engine - deallocate a frame engine
194 * @fh: frame engine in use
195 *
196 * Deallocates all memory associated with the engine.
197 */
198void utouch_frame_delete_engine(utouch_frame_handle fh);
199
200/**
201 * utouch_frame_get_surface - get the mutable device surface information
202 * @fh: the frame engine in use
203 *
204 * Returns a pointer to the mutable device surface information. It is
205 * preferrably set up by one of the input handlers. The pointer is ABI
206 * agnostic, has frame engine scope, and is owned by the engine.
207 */
208struct utouch_surface *utouch_frame_get_surface(utouch_frame_handle fh);
209
210/**
211 * utouch_frame_get_current_slot - get the current mutable slot contact
212 * @fh: the frame engine in use
213 *
214 * Returns a pointer to the contact current being modified. The
215 * pointer is ABI agnostic, has frame engine scope, and is owned by
216 * the engine.
217 */
218struct utouch_contact *utouch_frame_get_current_slot(utouch_frame_handle fh);
219
220/**
221 * utouch_frame_set_current_slot - set the current slot number
222 * @fh: the frame engine in use
223 * @slot: the slot number
224 *
225 * Sets the slot currently being modified. Returns zero if successful,
226 * negative error otherwise.
227 */
228int utouch_frame_set_current_slot(utouch_frame_handle fh, int slot);
229
230/**
231 * utouch_frame_sync - synchronize and return new frame
232 * @fh: the frame engine in use
233 * @time: the frame synchronization time (ms)
234 *
235 * Scans through the updates, and in case the changes make up a new
236 * frame, returns the updated frame.
237 *
238 * If time is zero, a time-of-receipt will be used instead.
239 *
240 * The frame returned is always the next in the cyclic list, and
241 * always points back at the previous frame returned by this function.
242 *
243 * The returned pointer is ABI agnostic and owned by the frame
244 * engine. It may very well be zero if there is nothing to report or
245 * if the frame rate is limited.
246 */
247const struct utouch_frame *utouch_frame_sync(utouch_frame_handle fh,
248 utouch_frame_time_t time);
249
250#endif
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..aa11733
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,21 @@
1lib_LTLIBRARIES = libutouch-frame.la
2
3libutouch_frame_la_LDFLAGS = \
4 -version-info @LIB_VERSION@ \
5 -lm \
6 $(EVEMU_LIBS)
7 $(MTDEV_LIBS)
8
9libutouch_frame_la_SOURCES = \
10 frame-impl.h \
11 frame.c \
12 frame-mtdev.c
13
14AM_CFLAGS = $(CWARNFLAGS)
15
16INCLUDES = -I$(top_srcdir)/include/
17
18libutouch_frameincludedir = $(includedir)/utouch
19libutouch_frameinclude_HEADERS = \
20 $(top_srcdir)/include/utouch/frame.h \
21 $(top_srcdir)/include/utouch/frame-mtdev.h
diff --git a/src/frame-impl.h b/src/frame-impl.h
new file mode 100644
index 0000000..c31f7da
--- /dev/null
+++ b/src/frame-impl.h
@@ -0,0 +1,18 @@
1#ifndef _FRAME_IMPL_H
2#define _FRAME_IMPL_H
3
4#include <utouch/frame.h>
5
6struct utouch_frame_engine {
7 int num_frames;
8 int num_slots;
9 int hold_ms;
10 int frame;
11 int slot;
12 float max_orient;
13 struct utouch_surface *surface;
14 struct utouch_frame **frames;
15 struct utouch_frame *next;
16};
17
18#endif
diff --git a/src/frame-mtdev.c b/src/frame-mtdev.c
new file mode 100644
index 0000000..ed5dc9e
--- /dev/null
+++ b/src/frame-mtdev.c
@@ -0,0 +1,189 @@
1/*****************************************************************************
2 *
3 * utouch-frame - Touch Frame Library
4 *
5 * Copyright (C) 2010 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ****************************************************************************/
21
22#include <utouch/frame-mtdev.h>
23#include "frame-impl.h"
24#include <linux/input.h>
25#include <errno.h>
26#include <math.h>
27
28int utouch_frame_is_supported_mtdev(const struct evemu_device *dev)
29{
30
31 /* only support pure absolute devices at this time */
32 if (evemu_has_event(dev, EV_REL, REL_X) ||
33 evemu_has_event(dev, EV_REL, REL_Y))
34 return 0;
35
36 if (evemu_has_event(dev, EV_ABS, ABS_MT_POSITION_X) &&
37 evemu_has_event(dev, EV_ABS, ABS_MT_POSITION_Y))
38 return 1;
39
40 return evemu_has_event(dev, EV_ABS, ABS_X) &&
41 evemu_has_event(dev, EV_ABS, ABS_Y) &&
42 evemu_has_event(dev, EV_KEY, BTN_TOUCH) &&
43 evemu_has_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP);
44}
45
46int utouch_frame_init_mtdev(utouch_frame_handle fh,
47 const struct evemu_device *dev)
48{
49 struct utouch_surface *s = fh->surface;
50 float tmp;
51
52 if (!utouch_frame_is_supported_mtdev(dev))
53 return -ENODEV;
54
55#ifdef INPUT_PROP_POINTER
56 s->needs_pointer = evemu_has_prop(dev, INPUT_PROP_POINTER);
57 s->is_direct = evemu_has_prop(dev, INPUT_PROP_DIRECT);
58 s->is_buttonpad = evemu_has_prop(dev, INPUT_PROP_BUTTONPAD);
59 s->is_semi_mt = evemu_has_prop(dev, INPUT_PROP_SEMI_MT);
60#endif
61 s->use_touch_major = evemu_has_event(dev, EV_ABS, ABS_MT_TOUCH_MAJOR);
62 s->use_touch_minor = evemu_has_event(dev, EV_ABS, ABS_MT_TOUCH_MINOR);
63 s->use_width_major = evemu_has_event(dev, EV_ABS, ABS_MT_WIDTH_MAJOR);
64 s->use_width_minor = evemu_has_event(dev, EV_ABS, ABS_MT_WIDTH_MINOR);
65 s->use_orientation = evemu_has_event(dev, EV_ABS, ABS_MT_ORIENTATION);
66 s->use_pressure = evemu_has_event(dev, EV_ABS, ABS_MT_PRESSURE);
67#ifdef ABS_MT_DISTANCE
68 s->use_distance = evemu_has_event(dev, EV_ABS, ABS_MT_DISTANCE);
69#endif
70
71
72 s->min_x = evemu_get_abs_minimum(dev, ABS_MT_POSITION_X);
73 s->min_y = evemu_get_abs_minimum(dev, ABS_MT_POSITION_Y);
74 s->max_x = evemu_get_abs_maximum(dev, ABS_MT_POSITION_X);
75 s->max_y = evemu_get_abs_maximum(dev, ABS_MT_POSITION_Y);
76 if (s->min_x == s->max_x) {
77 s->min_x = 0;
78 s->max_x = 1024;
79 }
80 if (s->min_y == s->max_y) {
81 s->min_y = 0;
82 s->max_y = 768;
83 }
84
85 s->max_pressure = evemu_get_abs_maximum(dev, ABS_MT_PRESSURE);
86 if (s->use_pressure && s->max_pressure == 0)
87 s->max_pressure = 256;
88
89 fh->max_orient = evemu_get_abs_maximum(dev, ABS_MT_ORIENTATION);
90 if (s->use_orientation && fh->max_orient == 0)
91 fh->max_orient = 1;
92
93 tmp = evemu_get_abs_resolution(dev, ABS_MT_POSITION_X);
94 if (tmp > 0)
95 s->phys_width = (s->max_x - s->min_x) / tmp;
96 else if (s->needs_pointer)
97 s->phys_width = 100;
98 else
99 s->phys_width = 250;
100
101 tmp = evemu_get_abs_resolution(dev, ABS_MT_POSITION_Y);
102 if (tmp > 0)
103 s->phys_height = (s->max_y - s->min_y) / tmp;
104 else if (s->needs_pointer)
105 s->phys_height = 65;
106 else
107 s->phys_height = 160;
108
109 tmp = evemu_get_abs_resolution(dev, ABS_MT_PRESSURE);
110 if (tmp > 0)
111 s->phys_pressure = s->max_pressure / tmp;
112 else
113 s->phys_pressure = 10;
114
115 return 0;
116}
117
118static float touch_angle(utouch_frame_handle fh, int orient)
119{
120 return orient / fh->max_orient * M_PI_2;
121}
122
123static int handle_abs_event(utouch_frame_handle fh,
124 const struct input_event *ev)
125{
126 struct utouch_contact *t = utouch_frame_get_current_slot(fh);
127
128 switch (ev->code) {
129 case ABS_MT_SLOT:
130 utouch_frame_set_current_slot(fh, ev->value);
131 return 1;
132 case ABS_MT_POSITION_X:
133 t->x = ev->value;
134 return 1;
135 case ABS_MT_POSITION_Y:
136 t->y = ev->value;
137 return 1;
138 case ABS_MT_TOUCH_MAJOR:
139 t->touch_major = ev->value;
140 return 1;
141 case ABS_MT_TOUCH_MINOR:
142 t->touch_minor = ev->value;
143 return 1;
144 case ABS_MT_WIDTH_MAJOR:
145 t->width_major = ev->value;
146 return 1;
147 case ABS_MT_WIDTH_MINOR:
148 t->width_minor = ev->value;
149 return 1;
150 case ABS_MT_ORIENTATION:
151 t->orientation = touch_angle(fh, ev->value);
152 return 1;
153 case ABS_MT_PRESSURE:
154 t->pressure = ev->value;
155 return 1;
156#ifdef ABS_MT_DISTANCE
157 case ABS_MT_DISTANCE:
158 t->distance = ev->value;
159 return 1;
160#endif
161 case ABS_MT_TOOL_TYPE:
162 t->tool_type = ev->value;
163 return 1;
164 case ABS_MT_TRACKING_ID:
165 t->id = ev->value;
166 return 1;
167 default:
168 return 0;
169 }
170}
171
172static utouch_frame_time_t get_evtime_ms(const struct input_event *syn)
173{
174 static const utouch_frame_time_t ms = 1000;
175 return syn->time.tv_usec / ms + syn->time.tv_sec * ms;
176}
177
178const struct utouch_frame *
179utouch_frame_pump_mtdev(utouch_frame_handle fh, const struct input_event *ev)
180{
181 const struct utouch_frame *f = 0;
182
183 if (ev->type == EV_SYN && ev->code == SYN_REPORT)
184 f = utouch_frame_sync(fh, get_evtime_ms(ev));
185 else if (ev->type == EV_ABS)
186 handle_abs_event(fh, ev);
187
188 return f;
189}
diff --git a/src/frame.c b/src/frame.c
new file mode 100644
index 0000000..9c4be97
--- /dev/null
+++ b/src/frame.c
@@ -0,0 +1,303 @@
1/*****************************************************************************
2 *
3 * utouch-frame - Touch Frame Library
4 *
5 * Copyright (C) 2010 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ****************************************************************************/
21
22#include "frame-impl.h"
23#include <errno.h>
24#include <math.h>
25#include <memory.h>
26#include <stdlib.h>
27#include <sys/time.h>
28
29#define MAX(a, b) ((a) > (b) ? (a) : (b))
30
31unsigned int utouch_frame_get_version(void)
32{
33 return UTOUCH_FRAME_VERSION;
34}
35
36static void destroy_slots(struct utouch_contact **slots, int nslot)
37{
38 int i;
39
40 if (slots) {
41 for (i = nslot - 1; i >= 0; i--)
42 free(slots[i]);
43 free(slots);
44 }
45}
46
47static void destroy_frame(struct utouch_frame *frame, int nslot)
48{
49 if (frame) {
50 destroy_slots(frame->slots, nslot);
51 free(frame->active);
52 free(frame);
53 }
54}
55
56static void destroy_frames(struct utouch_frame **frames, int nframe, int nslot)
57{
58 int i;
59
60 if (frames) {
61 for (i = nframe - 1; i >= 0; i--)
62 destroy_frame(frames[i], nslot);
63 free(frames);
64 }
65}
66
67static struct utouch_contact **create_slots(int nslot, int size)
68{
69 struct utouch_contact **slots;
70 struct utouch_contact *s;
71 int i;
72
73 slots = calloc(nslot, sizeof(slots[0]));
74 if (!slots)
75 return 0;
76
77 for (i = 0; i < nslot; i++) {
78 s = calloc(1, size);
79 if (!s)
80 goto out;
81 slots[i] = s;
82 s->slot = i;
83 s->id = -1;
84 }
85
86 return slots;
87out:
88 destroy_slots(slots, nslot);
89 return 0;
90}
91
92static struct utouch_frame *create_frame(int nslot,
93 int frame_size, int slot_size)
94{
95 struct utouch_frame *frame;
96 int i;
97
98 frame = calloc(1, frame_size);
99 if (!frame)
100 return 0;
101
102 frame->active = calloc(nslot, sizeof(frame->active[0]));
103 frame->slots = create_slots(nslot, slot_size);
104 if (!frame->active || !frame->slots)
105 goto out;
106
107 return frame;
108out:
109 destroy_frame(frame, nslot);
110 return 0;
111}
112
113static struct utouch_frame **create_frames(int nframe, int nslot,
114 int frame_size, int slot_size)
115{
116 struct utouch_frame **frames;
117 struct utouch_frame *f;
118 int i;
119
120 frames = calloc(nframe, sizeof(frames[0]));
121 if (!frames)
122 return 0;
123
124 for (i = 0; i < nframe; i++) {
125 f = create_frame(nslot, frame_size, slot_size);
126 if (!f)
127 goto out;
128 frames[i] = f;
129 }
130
131 return frames;
132out:
133 destroy_frames(frames, nframe, nslot);
134 return 0;
135}
136
137utouch_frame_handle utouch_frame_new_engine_raw(unsigned int nframe,
138 unsigned int nslot,
139 unsigned int rate,
140 unsigned int version,
141 unsigned int surface_size,
142 unsigned int frame_size,
143 unsigned int slot_size)
144{
145 struct utouch_frame *f, *pf;
146 utouch_frame_handle fh;
147 int i, j;
148
149 fh = calloc(1, sizeof(struct utouch_frame_engine));
150 if (!fh)
151 return 0;
152
153 fh->num_frames = nframe;
154 fh->num_slots = nslot;
155 fh->hold_ms = 1000 / rate;
156
157 surface_size = MAX(surface_size, sizeof(struct utouch_surface));
158 frame_size = MAX(frame_size, sizeof(struct utouch_frame));
159 slot_size = MAX(slot_size, sizeof(struct utouch_contact));
160
161 fh->surface = calloc(1, surface_size);
162 fh->frames = create_frames(nframe, nslot, frame_size, slot_size);
163 fh->next = create_frame(nslot, frame_size, slot_size);
164 if (!fh->surface || !fh->frames || !fh->next)
165 goto out;
166
167 pf = fh->frames[nframe - 1];
168 for (i = 0; i < nframe; i++) {
169 f = fh->frames[i];
170 for (j = 0; j < nslot; j++)
171 f->slots[j]->prev = pf->slots[j];
172 f->prev = pf;
173 pf = f;
174 }
175
176 return fh;
177out:
178 utouch_frame_delete_engine(fh);
179 return 0;
180}
181
182void utouch_frame_delete_engine(utouch_frame_handle fh)
183{
184 destroy_frame(fh->next, fh->num_slots);
185 destroy_frames(fh->frames, fh->num_frames, fh->num_slots);
186 free(fh->surface);
187 free(fh);
188}
189
190struct utouch_surface *utouch_frame_get_surface(utouch_frame_handle fh)
191{
192 return fh->surface;
193}
194
195struct utouch_contact *utouch_frame_get_current_slot(utouch_frame_handle fh)
196{
197 return fh->next->slots[fh->slot];
198}
199
200int utouch_frame_set_current_slot(utouch_frame_handle fh, int slot)
201{
202 if (slot < 0 || slot >= fh->num_slots)
203 return -EINVAL;
204 fh->slot = slot;
205 return 0;
206}
207
208static void copy_contact(utouch_frame_handle fh,
209 struct utouch_contact *a,
210 const struct utouch_contact *b)
211{
212 struct utouch_surface *s = fh->surface;
213
214 a->active = b->id != -1;
215 a->id = b->id;
216 a->tool_type = b->tool_type;
217 a->x = b->x;
218 a->y = b->y;
219 a->touch_major = b->touch_major;
220 a->touch_minor = s->use_touch_minor && b->touch_minor > 0 ?
221 b->touch_minor : b->touch_major;
222 a->width_major = b->width_major;
223 a->width_minor = s->use_width_minor && b->width_minor > 0 ?
224 b->width_minor : b->width_major;
225 a->orientation = b->orientation;
226 a->pressure = b->pressure;
227 a->distance = b->distance;
228}
229
230static int detect_addrem(const struct utouch_contact *a,
231 const struct utouch_contact *b)
232{
233 return a->id != b->id || a->tool_type != b->tool_type;
234}
235
236static int detect_mod(const struct utouch_contact *a,
237 const struct utouch_contact *b)
238{
239 return a->x != b->x || a->y != b->y ||
240 a->touch_major != b->touch_major ||
241 a->touch_minor != b->touch_minor ||
242 a->width_major != b->width_major ||
243 a->width_minor != b->width_minor ||
244 a->orientation != b->orientation ||
245 a->pressure != b->pressure ||
246 a->distance != b->distance;
247}
248
249static utouch_frame_time_t get_time_ms()
250{
251 static const utouch_frame_time_t ms = 1000;
252 struct timeval tv;
253 gettimeofday(&tv, 0);
254 return tv.tv_usec / ms + tv.tv_sec * ms;
255}
256
257const struct utouch_frame *utouch_frame_sync(utouch_frame_handle fh,
258 utouch_frame_time_t time)
259{
260 struct utouch_frame *frame = fh->frames[fh->frame];
261 const struct utouch_frame *prev = frame->prev;
262 struct utouch_frame *next = fh->next;
263 int naddrem = 0, nmod = 0;
264 int i;
265
266 frame->num_active = 0;
267 for (i = 0; i < fh->num_slots; i++) {
268 struct utouch_contact *p = frame->slots[i];
269 const struct utouch_contact *q = next->slots[i];
270
271 copy_contact(fh, p, q);
272 if (p->active)
273 frame->active[frame->num_active++] = p;
274
275 naddrem += detect_addrem(p->prev, p);
276 nmod += detect_mod(p->prev, p);
277 }
278 if (naddrem + nmod == 0)
279 return 0;
280
281 frame->time = time ? time : get_time_ms();
282 if (naddrem == 0 && frame->time < prev->time + fh->hold_ms)
283 return 0;
284
285 if (frame->num_active != prev->num_active) {
286 next->mod_time = frame->time;
287 next->revision++;
288 }
289 if (naddrem) {
290 next->slot_mod_time = frame->time;
291 next->slot_revision++;
292 }
293
294 frame->revision = next->revision;
295 frame->slot_revision = next->slot_revision;
296 frame->mod_time = next->mod_time;
297 frame->slot_mod_time = next->slot_mod_time;
298 frame->sequence_id = next->sequence_id++;
299
300 fh->frame = (fh->frame + 1) % fh->num_frames;
301
302 return frame;
303}
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Makefile.am
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 0000000..6b50897
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,7 @@
1bin_PROGRAMS = utouch-frame-test-mtdev
2
3INCLUDES=-I$(top_srcdir)/include/
4
5utouch_frame_test_mtdev_SOURCES = utouch-frame-test-mtdev.c
6utouch_frame_test_mtdev_LDFLAGS = -L$(top_builddir)/src/.libs/ \
7 -lutouch-frame -lutouch-evemu -lmtdev -lm
diff --git a/tools/utouch-frame-test-mtdev.c b/tools/utouch-frame-test-mtdev.c
new file mode 100644
index 0000000..13f5a68
--- /dev/null
+++ b/tools/utouch-frame-test-mtdev.c
@@ -0,0 +1,202 @@
1/*****************************************************************************
2 *
3 * utouch-frame - Touch Frame Library
4 *
5 * Copyright (C) 2010-2011 Canonical Ltd.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Henrik Rydberg <rydberg@bitmath.org>
22 *
23 ****************************************************************************/
24
25#define MTDEV_NO_LEGACY_API
26
27#include <utouch/frame-mtdev.h>
28#include <mtdev.h>
29#include <string.h>
30#include <stdio.h>
31#include <unistd.h>
32#include <fcntl.h>
33
34struct frame_test {
35 struct evemu_device *evemu;
36 struct mtdev *mtdev;
37 utouch_frame_handle fh;
38};
39
40static int init_evemu(struct frame_test *test, int fd)
41{
42 test->evemu = evemu_new(NULL);
43 if (!test->evemu)
44 return -1;
45 return evemu_extract(test->evemu, fd);
46}
47
48static int init_mtdev(struct frame_test *test, int fd)
49{
50 test->mtdev = mtdev_new_open(fd);
51 if (!test->mtdev)
52 return -1;
53 return 0;
54}
55
56static int init_frame(struct frame_test *test, int fd)
57{
58 test->fh = utouch_frame_new_engine(100, 32, 100);
59 if (!test->fh)
60 return -1;
61 return utouch_frame_init_mtdev(test->fh, test->evemu);
62}
63
64static void destroy_all(struct frame_test *test)
65{
66 utouch_frame_delete_engine(test->fh);
67 mtdev_close_delete(test->mtdev);
68 evemu_delete(test->evemu);
69 memset(test, 0, sizeof(*test));
70}
71
72static void report_frame(const struct utouch_frame *frame)
73{
74 int i;
75
76 for (i = 0; i < frame->num_active; i++) {
77 const struct utouch_contact *t = frame->active[i];
78
79 fprintf(stderr, "touch %d\n", i);
80 fprintf(stderr, " slot: %d\n", t->slot);
81 fprintf(stderr, " id: %d\n", t->id);
82 fprintf(stderr, " tool_type: %d\n", t->tool_type);
83 fprintf(stderr, " x: %f\n", t->x);
84 fprintf(stderr, " y: %f\n", t->y);
85 fprintf(stderr, " touch_major: %f\n", t->touch_major);
86 fprintf(stderr, " touch_minor: %f\n", t->touch_minor);
87 fprintf(stderr, " width_major: %f\n", t->width_major);
88 fprintf(stderr, " width_minor: %f\n", t->width_minor);
89 fprintf(stderr, " angle: %f\n", t->orientation);
90 fprintf(stderr, " pressure: %f\n", t->pressure);
91 fprintf(stderr, " distance: %f\n", t->distance);
92 }
93
94 fprintf(stderr, "sync %d %ld %d %d %d\n",
95 frame->num_active,
96 frame->time,
97 frame->sequence_id,
98 frame->revision,
99 frame->slot_revision);
100}
101
102static void loop_device(struct frame_test *test, int fd)
103{
104 const struct utouch_frame *frame;
105 struct input_event ev;
106
107 while (!mtdev_idle(test->mtdev, fd, 5000)) {
108 while (mtdev_get(test->mtdev, fd, &ev, 1) > 0) {
109 frame = utouch_frame_pump_mtdev(test->fh, &ev);
110 if (frame)
111 report_frame(frame);
112 }
113 }
114}
115
116static void report_device_caps(struct frame_test *test)
117{
118#ifdef INPUT_PROP_POINTER
119 fprintf(stderr, "device props:\n");
120 if (evemu_has_prop(test->evemu, INPUT_PROP_POINTER))
121 fprintf(stderr, "\tpointer\n");
122 if (evemu_has_prop(test->evemu, INPUT_PROP_DIRECT))
123 fprintf(stderr, "\tdirect\n");
124 if (evemu_has_prop(test->evemu, INPUT_PROP_BUTTONPAD))
125 fprintf(stderr, "\tbuttonpad\n");
126 if (evemu_has_prop(test->evemu, INPUT_PROP_SEMI_MT))
127 fprintf(stderr, "\tsemi_mt\n");
128#endif
129 fprintf(stderr, "device mt events:\n");
130 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_SLOT))
131 fprintf(stderr, "\tslot\n");
132 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_TOUCH_MAJOR))
133 fprintf(stderr, "\ttouch_major\n");
134 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_TOUCH_MINOR))
135 fprintf(stderr, "\ttouch_minor\n");
136 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_WIDTH_MAJOR))
137 fprintf(stderr, "\twidth_major\n");
138 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_WIDTH_MINOR))
139 fprintf(stderr, "\twidth_minor\n");
140 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_ORIENTATION))
141 fprintf(stderr, "\torientation\n");
142 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_POSITION_X))
143 fprintf(stderr, "\tposition_x\n");
144 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_POSITION_Y))
145 fprintf(stderr, "\tposition_y\n");
146 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_TOOL_TYPE))
147 fprintf(stderr, "\tposition_y\n");
148 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_TRACKING_ID))
149 fprintf(stderr, "\ttracking_id\n");
150 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_PRESSURE))
151 fprintf(stderr, "\tpressure\n");
152 if (evemu_has_event(test->evemu, EV_ABS, ABS_MT_DISTANCE))
153 fprintf(stderr, "\tdistance\n");
154}
155
156int main(int argc, char *argv[])
157{
158 struct frame_test test;
159 int fd;
160
161 if (argc < 2) {
162 fprintf(stderr, "Usage: %s <device>\n", argv[0]);
163 return -1;
164 }
165
166 fd = open(argv[1], O_RDONLY | O_NONBLOCK);
167 if (fd < 0) {
168 fprintf(stderr, "error: could not open device\n");
169 return -1;
170 }
171 if (ioctl(fd, EVIOCGRAB, 1)) {
172 fprintf(stderr, "error: could not grab the device\n");
173 return -1;
174 }
175
176 if (init_evemu(&test, fd)) {
177 fprintf(stderr, "error: could not describe device\n");
178 return -1;
179 }
180 if (!utouch_frame_is_supported_mtdev(test.evemu)) {
181 fprintf(stderr, "error: unsupported device\n");
182 return -1;
183 }
184
185 fprintf(stderr, "device: %s\n", evemu_get_name(test.evemu));
186
187 if (init_mtdev(&test, fd)) {
188 fprintf(stderr, "error: could not init mtdev\n");
189 return -1;
190 }
191 if (init_frame(&test, fd)) {
192 fprintf(stderr, "error: could not init frame\n");
193 return -1;
194 }
195
196 report_device_caps(&test);
197
198 loop_device(&test, fd);
199
200 destroy_all(&test);
201 return 0;
202}
diff --git a/utouch-frame.pc.in b/utouch-frame.pc.in
new file mode 100644
index 0000000..cbb305a
--- /dev/null
+++ b/utouch-frame.pc.in
@@ -0,0 +1,9 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: utouch-frame
7Description: Touch Frame Library
8Version: @PACKAGE_VERSION@
9Libs: -L${libdir} -lutouch-frame