pax_global_header00006660000000000000000000000064115612373360014521gustar00rootroot0000000000000052 comment=ddc01e7aa8648698c92c6522ad212ccf27663a37 xf86-input-multitouch-1.0~rc2+git20110312/000077500000000000000000000000001156123733600177025ustar00rootroot00000000000000xf86-input-multitouch-1.0~rc2+git20110312/.gitignore000066400000000000000000000000731156123733600216720ustar00rootroot00000000000000debian/files debian/xf86-input-multitouch* bin obj patches xf86-input-multitouch-1.0~rc2+git20110312/COPYING000066400000000000000000000431051156123733600207400ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, 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 software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's 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 give any other recipients of the Program a copy of this License along with the Program. 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. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, 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 Program, 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 Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) 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; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, 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 executable. 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. If distribution of executable or 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 counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program 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. 5. 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 Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program 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. 7. 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 Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program 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 Program. 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. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program 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. 9. The Free Software Foundation may publish revised and/or new versions of the 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 Program 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 Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, 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 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. 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. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. xf86-input-multitouch-1.0~rc2+git20110312/CREDITS000066400000000000000000000050231156123733600207220ustar00rootroot00000000000000Multitouch X driver (GPL license) Copyright (C) 2008 Henrik Rydberg This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --- The Multitouch X driver extracts a lot of X knowledge from the synaptics X driver (MIT license) Copyright (C) 1997 C. Scott Ananian Copyright (C) 1998-2000 Bruce Kalk Copyright (C) 1999 Henry Davies Copyright (C) 2001 Stefan Gmeiner Copyright (C) 2002 Linuxcare Inc. David Kennedy Copyright (C) 2003 Fred Hucht Copyright (C) 2003 Neil Brown Copyright (C) 2003 Jörg Bösner Copyright (C) 2003 Hartwig Felger Copyright (C) 2002-2007 Peter Osterlund Copyright (C) 2004 Arne Schwabe Copyright (C) 2004 Matthias Ihmig Copyright (C) 2004 Alexei Gilchrist Copyright (C) 2006-2007 Christian Thaeter Copyright (C) 2006 Stefan Bethge Copyright (C) 2007 Joseph P. Skudlarek Copyright (C) 2007 Florian Loitsch Copyright (C) 2008 Fedor P. Goncharov Copyright (C) 2008-2009 Red Hat, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- xf86-input-multitouch-1.0~rc2+git20110312/Makefile000066400000000000000000000025001156123733600213370ustar00rootroot00000000000000VERSION = 1 PATCHLEVEL = 0 EXTRAVERSION = rc2 LIBRARY = multitouch.so MODULES = src XMODULES = driver o_src = capabilities hwstate mtstate memory mtouch gestures o_driver= multitouch TARGETS += src/test OBJECTS = $(addsuffix .o,\ $(foreach mod,$(MODULES),\ $(addprefix $(mod)/,$(o_$(mod))))) XOBJECTS= $(addsuffix .o,\ $(foreach mod,$(XMODULES),\ $(addprefix $(mod)/,$(o_$(mod))))) TBIN = $(addprefix bin/,$(TARGETS)) TLIB = $(addprefix obj/,$(LIBRARY)) TOBJ = $(addprefix obj/,$(addsuffix .o,$(TARGETS))) OBJS = $(addprefix obj/,$(OBJECTS)) XOBJS = $(addprefix obj/,$(XOBJECTS)) LIBS = -lmtdev -lm LIBDIR = usr/lib DLIB = $(LIBDIR)/xorg/modules/input INCLUDE = -Iinclude -I/usr/include/xorg -I/usr/include/pixman-1 OPTS = -O3 -fPIC .PHONY: all clean .PRECIOUS: obj/%.o all: $(OBJS) $(TLIB) $(TOBJ) $(TBIN) bin/%: obj/%.o $(OBJS) @mkdir -p $(@D) gcc $< -o $@ $(OBJS) $(LIBS) $(TLIB): $(OBJS) $(XOBJS) @rm -f $(TLIB) gcc -shared $(OBJS) $(XOBJS) $(LIBS) -Wl,-soname -Wl,$(LIBRARY) -o $@ obj/%.o: %.c @mkdir -p $(@D) gcc $(INCLUDE) $(OPTS) -c $< -o $@ obj/%.o: %.cc @mkdir -p $(@D) gcc $(INCLUDE) $(OPTS) -c $< -o $@ clean: rm -rf bin obj distclean: clean rm -rf debian/*.log debian/files debian/xf86-input-multitouch* install: $(TLIB) install -d "$(DESTDIR)/$(DLIB)" install -m 755 $(TLIB) "$(DESTDIR)/$(DLIB)" xf86-input-multitouch-1.0~rc2+git20110312/README000066400000000000000000000003151156123733600205610ustar00rootroot00000000000000xf86-input-multitouch The Multitouch X Driver provides gestures support for multitouch touchpads, in particular those with integrated button. --- Copyright (C) 2008 Henrik Rydberg xf86-input-multitouch-1.0~rc2+git20110312/driver/000077500000000000000000000000001156123733600211755ustar00rootroot00000000000000xf86-input-multitouch-1.0~rc2+git20110312/driver/multitouch.c000066400000000000000000000253701156123733600235450ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include "gestures.h" #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 #include #include #endif #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 typedef InputInfoPtr LocalDevicePtr; #endif /* these should be user-configurable at some point */ static const float vscroll_fraction = 0.025; static const float hscroll_fraction = 0.05; static const float vswipe_fraction = 0.25; static const float hswipe_fraction = 0.25; static const float scale_fraction = 0.05; static const float rot_fraction = 0.05; /* button mapping simplified */ #define PROPMAP(m, x, y) m[x] = XIGetKnownProperty(y) static void pointer_control(DeviceIntPtr dev, PtrCtrl *ctrl) { xf86Msg(X_INFO, "pointer_control\n"); } static int pointer_property(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, BOOL checkonly) { xf86Msg(X_INFO, "pointer_property\n"); return Success; } #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 static void initAxesLabels(Atom map[2]) { memset(map, 0, 2 * sizeof(Atom)); PROPMAP(map, 0, AXIS_LABEL_PROP_REL_X); PROPMAP(map, 1, AXIS_LABEL_PROP_REL_Y); } static void initButtonLabels(Atom map[DIM_BUTTON]) { memset(map, 0, DIM_BUTTON * sizeof(Atom)); PROPMAP(map, MT_BUTTON_LEFT, BTN_LABEL_PROP_BTN_LEFT); PROPMAP(map, MT_BUTTON_MIDDLE, BTN_LABEL_PROP_BTN_MIDDLE); PROPMAP(map, MT_BUTTON_RIGHT, BTN_LABEL_PROP_BTN_RIGHT); PROPMAP(map, MT_BUTTON_WHEEL_UP, BTN_LABEL_PROP_BTN_WHEEL_UP); PROPMAP(map, MT_BUTTON_WHEEL_DOWN, BTN_LABEL_PROP_BTN_WHEEL_DOWN); PROPMAP(map, MT_BUTTON_HWHEEL_LEFT, BTN_LABEL_PROP_BTN_HWHEEL_LEFT); PROPMAP(map, MT_BUTTON_HWHEEL_RIGHT, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); /* how to map swipe buttons? */ PROPMAP(map, MT_BUTTON_SWIPE_UP, BTN_LABEL_PROP_BTN_0); PROPMAP(map, MT_BUTTON_SWIPE_DOWN, BTN_LABEL_PROP_BTN_1); PROPMAP(map, MT_BUTTON_SWIPE_LEFT, BTN_LABEL_PROP_BTN_2); PROPMAP(map, MT_BUTTON_SWIPE_RIGHT, BTN_LABEL_PROP_BTN_3); /* how to map scale and rotate? */ PROPMAP(map, MT_BUTTON_SCALE_DOWN, BTN_LABEL_PROP_BTN_4); PROPMAP(map, MT_BUTTON_SCALE_UP, BTN_LABEL_PROP_BTN_5); PROPMAP(map, MT_BUTTON_ROTATE_LEFT, BTN_LABEL_PROP_BTN_6); PROPMAP(map, MT_BUTTON_ROTATE_RIGHT, BTN_LABEL_PROP_BTN_7); } #endif static int device_init(DeviceIntPtr dev, LocalDevicePtr local) { struct MTouch *mt = local->private; unsigned char btmap[DIM_BUTTON + 1] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 Atom axes_labels[2], btn_labels[DIM_BUTTON]; initAxesLabels(axes_labels); initButtonLabels(btn_labels); #endif local->fd = xf86OpenSerial(local->options); if (local->fd < 0) { xf86Msg(X_ERROR, "multitouch: cannot open device\n"); return !Success; } if (configure_mtouch(mt, local->fd)) { xf86Msg(X_ERROR, "multitouch: cannot configure device\n"); return !Success; } xf86CloseSerial(local->fd); #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 InitPointerDeviceStruct((DevicePtr)dev, btmap, DIM_BUTTON, GetMotionHistory, pointer_control, GetMotionHistorySize(), 2); #elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 7 InitPointerDeviceStruct((DevicePtr)dev, btmap, DIM_BUTTON, pointer_control, GetMotionHistorySize(), 2); #elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 InitPointerDeviceStruct((DevicePtr)dev, btmap, DIM_BUTTON, btn_labels, pointer_control, GetMotionHistorySize(), 2, axes_labels); #else #error "Unsupported ABI_XINPUT_VERSION" #endif xf86InitValuatorAxisStruct(dev, 0, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 axes_labels[0], #endif mt->caps.abs[MTDEV_POSITION_X].minimum, mt->caps.abs[MTDEV_POSITION_X].maximum, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 1, 0, 1, Absolute); #else 1, 0, 1); #endif xf86InitValuatorDefaults(dev, 0); xf86InitValuatorAxisStruct(dev, 1, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 axes_labels[1], #endif mt->caps.abs[MTDEV_POSITION_Y].minimum, mt->caps.abs[MTDEV_POSITION_Y].maximum, #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 1, 0, 1, Absolute); #else 1, 0, 1); #endif xf86InitValuatorDefaults(dev, 1); XIRegisterPropertyHandler(dev, pointer_property, NULL, NULL); return Success; } static int device_on(LocalDevicePtr local) { struct MTouch *mt = local->private; local->fd = xf86OpenSerial(local->options); if (local->fd < 0) { xf86Msg(X_ERROR, "multitouch: cannot open device\n"); return !Success; } if (open_mtouch(mt, local->fd)) { xf86Msg(X_ERROR, "multitouch: cannot grab device\n"); return !Success; } xf86AddEnabledDevice(local); return Success; } static int device_off(LocalDevicePtr local) { struct MTouch *mt = local->private; xf86RemoveEnabledDevice(local); if (close_mtouch(mt, local->fd)) xf86Msg(X_WARNING, "multitouch: cannot ungrab device\n"); xf86CloseSerial(local->fd); return Success; } static int device_close(LocalDevicePtr local) { return Success; } static void tickle_button(LocalDevicePtr local, int id) { xf86PostButtonEvent(local->dev, FALSE, id, 1, 0, 0); xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0); } static void button_scroll(LocalDevicePtr local, int btdec, int btinc, int *scroll, int step, int delta) { *scroll += delta; while (*scroll > step) { tickle_button(local, btinc); *scroll -= step; } while (*scroll < -step) { tickle_button(local, btdec); *scroll += step; } } static void handle_gestures(LocalDevicePtr local, const struct Gestures *gs, const struct Capabilities *caps) { static int vscroll, hscroll, vswipe, hswipe, scale, rot; int i; if (!gs->same_fingers) { vscroll = 0; hscroll = 0; vswipe = 0; hswipe = 0; } foreach_bit(i, gs->btmask) xf86PostButtonEvent(local->dev, FALSE, i + 1, GETBIT(gs->btdata, i), 0, 0); if (GETBIT(gs->type, GS_MOVE)) xf86PostMotionEvent(local->dev, 0, 0, 2, gs->dx, gs->dy); if (GETBIT(gs->type, GS_VSCROLL)) { int step = 1 + vscroll_fraction * get_cap_ysize(caps); button_scroll(local, 4, 5, &vscroll, step, gs->dy); } if (GETBIT(gs->type, GS_HSCROLL)) { int step = 1 + hscroll_fraction * get_cap_xsize(caps); button_scroll(local, 6, 7, &hscroll, step, gs->dx); } if (GETBIT(gs->type, GS_VSWIPE)) { int step = 1 + vswipe_fraction * get_cap_ysize(caps); button_scroll(local, 8, 9, &vswipe, step, gs->dy); } if (GETBIT(gs->type, GS_HSWIPE)) { int step = 1 + hswipe_fraction * get_cap_xsize(caps); button_scroll(local, 10, 11, &hswipe, step, gs->dx); } if (GETBIT(gs->type, GS_SCALE)) { int step = 1 + scale_fraction * get_cap_xsize(caps); button_scroll(local, 12, 13, &scale, step, gs->scale); } if (GETBIT(gs->type, GS_ROTATE)) { int step = 1 + rot_fraction * get_cap_xsize(caps); button_scroll(local, 14, 15, &rot, step, gs->rot); } if (GETBIT(gs->type, GS_TAP) && gs->ntap == 1) { foreach_bit(i, gs->tapmask) tickle_button(local, i + 1); } if (GETBIT(gs->type, GS_VSWIPE4)) { int step = 1 + vswipe_fraction * get_cap_ysize(caps); button_scroll(local, 16, 17, &vswipe, step, gs->dy); } if (GETBIT(gs->type, GS_HSWIPE4)) { int step = 1 + hswipe_fraction * get_cap_xsize(caps); button_scroll(local, 18, 19, &hswipe, step, gs->dx); } } /* called for each full received packet from the touchpad */ static void read_input(LocalDevicePtr local) { struct Gestures gs; struct MTouch *mt = local->private; while (read_packet(mt, local->fd) > 0) { extract_gestures(&gs, mt); handle_gestures(local, &gs, &mt->caps); } if (has_delayed_gestures(mt, local->fd)) { extract_delayed_gestures(&gs, mt); handle_gestures(local, &gs, &mt->caps); } } static Bool device_control(DeviceIntPtr dev, int mode) { LocalDevicePtr local = dev->public.devicePrivate; switch (mode) { case DEVICE_INIT: xf86Msg(X_INFO, "device control: init\n"); return device_init(dev, local); case DEVICE_ON: xf86Msg(X_INFO, "device control: on\n"); return device_on(local); case DEVICE_OFF: xf86Msg(X_INFO, "device control: off\n"); return device_off(local); case DEVICE_CLOSE: xf86Msg(X_INFO, "device control: close\n"); return device_close(local); default: xf86Msg(X_INFO, "device control: default\n"); return BadValue; } } #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 static int preinit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) { struct MTouch *mt; mt = calloc(1, sizeof(*mt)); if (!mt) return BadAlloc; pInfo->private = mt; pInfo->type_name = XI_TOUCHPAD; pInfo->device_control = device_control; pInfo->read_input = read_input; pInfo->switch_mode = 0; //xf86CollectInputOptions(local, NULL); //xf86ProcessCommonOptions(local, local->options); return Success; } #else static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags) { struct MTouch *mt; InputInfoPtr local = xf86AllocateInput(drv, 0); if (!local) goto error; mt = calloc(1, sizeof(struct MTouch)); if (!mt) goto error; local->name = dev->identifier; local->type_name = XI_TOUCHPAD; local->device_control = device_control; local->read_input = read_input; local->private = mt; local->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS; local->conf_idev = dev; xf86CollectInputOptions(local, NULL, NULL); /* xf86OptionListReport(local->options); */ xf86ProcessCommonOptions(local, local->options); local->flags |= XI86_CONFIGURED; error: return local; } #endif static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags) { free(local->private); local->private = 0; xf86DeleteInput(local, 0); } static InputDriverRec MULTITOUCH = { 1, "multitouch", NULL, preinit, uninit, NULL, 0 }; static XF86ModuleVersionInfo VERSION = { "multitouch", MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, XORG_VERSION_CURRENT, 0, 1, 0, ABI_CLASS_XINPUT, ABI_XINPUT_VERSION, MOD_CLASS_XINPUT, {0, 0, 0, 0} }; static pointer setup(pointer module, pointer options, int *errmaj, int *errmin) { xf86AddInputDriver(&MULTITOUCH, module, 0); return module; } XF86ModuleData multitouchModuleData = {&VERSION, &setup, NULL }; xf86-input-multitouch-1.0~rc2+git20110312/include/000077500000000000000000000000001156123733600213255ustar00rootroot00000000000000xf86-input-multitouch-1.0~rc2+git20110312/include/button.h000066400000000000000000000027111156123733600230120ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef BUTTON_H #define BUTTON_H #define DIM_BUTTON 15 #define MT_BUTTON_LEFT 0 #define MT_BUTTON_MIDDLE 1 #define MT_BUTTON_RIGHT 2 #define MT_BUTTON_WHEEL_UP 3 #define MT_BUTTON_WHEEL_DOWN 4 #define MT_BUTTON_HWHEEL_LEFT 5 #define MT_BUTTON_HWHEEL_RIGHT 6 #define MT_BUTTON_SWIPE_UP 7 #define MT_BUTTON_SWIPE_DOWN 8 #define MT_BUTTON_SWIPE_LEFT 9 #define MT_BUTTON_SWIPE_RIGHT 10 #define MT_BUTTON_SCALE_DOWN 11 #define MT_BUTTON_SCALE_UP 12 #define MT_BUTTON_ROTATE_LEFT 13 #define MT_BUTTON_ROTATE_RIGHT 14 #endif xf86-input-multitouch-1.0~rc2+git20110312/include/capabilities.h000066400000000000000000000032041156123733600241260ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef CAPABILITIES_H #define CAPABILITIES_H #include "common.h" #include "button.h" struct Capabilities { struct input_id devid; char devname[32]; int has_left, has_middle, has_right; int has_mtdata, has_ibt; int has_slot; int has_abs[MT_ABS_SIZE]; struct input_absinfo slot; struct input_absinfo abs[MT_ABS_SIZE]; }; int read_capabilities(struct Capabilities *cap, int fd); int get_cap_xsize(const struct Capabilities *cap); int get_cap_ysize(const struct Capabilities *cap); int get_cap_wsize(const struct Capabilities *cap); int get_cap_xmid(const struct Capabilities *cap); int get_cap_ymid(const struct Capabilities *cap); void output_capabilities(const struct Capabilities *cap); #endif xf86-input-multitouch-1.0~rc2+git20110312/include/common.h000066400000000000000000000047501156123733600227740ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef COMMON_H #define COMMON_H #include "xorg-server.h" #include #include #include #include #include #define DIM_FINGER 32 #define DIM2_FINGER (DIM_FINGER * DIM_FINGER) /* year-proof millisecond event time */ typedef __u64 mstime_t; /* all bit masks have this type */ typedef unsigned int bitmask_t; #define BITMASK(x) (1U << (x)) #define BITONES(x) (BITMASK(x) - 1U) #define GETBIT(m, x) (((m) >> (x)) & 1U) #define SETBIT(m, x) (m |= BITMASK(x)) #define CLEARBIT(m, x) (m &= ~BITMASK(x)) #define MODBIT(m, x, b) ((b) ? SETBIT(m, x) : CLEARBIT(m, x)) static inline int maxval(int x, int y) { return x > y ? x : y; } static inline int minval(int x, int y) { return x < y ? x : y; } static inline int clamp15(int x) { return x < -32767 ? -32767 : x > 32767 ? 32767 : x; } /* absolute scale is assumed to fit in 15 bits */ static inline int dist2(int dx, int dy) { dx = clamp15(dx); dy = clamp15(dy); return dx * dx + dy * dy; } /* Count number of bits (Sean Eron Andersson's Bit Hacks) */ static inline int bitcount(unsigned v) { v -= ((v>>1) & 0x55555555); v = (v&0x33333333) + ((v>>2) & 0x33333333); return (((v + (v>>4)) & 0xF0F0F0F) * 0x1010101) >> 24; } /* Return index of first bit [0-31], -1 on zero */ #define firstbit(v) (__builtin_ffs(v) - 1) /* boost-style foreach bit */ #define foreach_bit(i, m) \ for (i = firstbit(m); i >= 0; i = firstbit((m) & (~0U << i + 1))) /* robust system ioctl calls */ #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) #endif xf86-input-multitouch-1.0~rc2+git20110312/include/gestures.h000066400000000000000000000030221156123733600233340ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef GESTURES_H #define GESTURES_H #include "mtouch.h" #define GS_BUTTON 0 #define GS_MOVE 1 #define GS_VSCROLL 2 #define GS_HSCROLL 3 #define GS_VSWIPE 4 #define GS_HSWIPE 5 #define GS_SCALE 6 #define GS_ROTATE 7 #define GS_TAP 8 #define GS_VSWIPE4 9 #define GS_HSWIPE4 10 struct Gestures { bitmask_t type, btmask, btdata; int same_fingers, dx, dy, scale, rot; bitmask_t tapmask; int ntap; }; void extract_gestures(struct Gestures *gs, struct MTouch* mt); void extract_delayed_gestures(struct Gestures *gs, struct MTouch* mt); void output_gesture(const struct Gestures *gs); #endif xf86-input-multitouch-1.0~rc2+git20110312/include/hwstate.h000066400000000000000000000033101156123733600231520ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef HWSTATE_H #define HWSTATE_H #include "capabilities.h" struct FingerState { int touch_major, touch_minor; int width_major, width_minor; int orientation, pressure; int position_x, position_y; int tracking_id; }; struct HWState { struct FingerState data[DIM_FINGER]; bitmask_t used; bitmask_t slot; bitmask_t button; mstime_t evtime; }; void init_hwstate(struct HWState *s, const struct Capabilities *caps); int modify_hwstate(struct HWState *s, struct mtdev *dev, int fd, const struct Capabilities *caps); void output_hwstate(const struct HWState *s); static inline int finger_dist2(const struct FingerState *a, const struct FingerState *b) { return dist2(a->position_x - b->position_x, a->position_y - b->position_y); } #endif xf86-input-multitouch-1.0~rc2+git20110312/include/memory.h000066400000000000000000000054331156123733600230130ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef MEMORY_H #define MEMORY_H #include "mtstate.h" /** * struct Memory - parsing state * * @btdata: logical finger state * @same: true if the finger configuration is unchanged * @fingers: bitmask of fingers on the pad * @added: bitmask of new fingers on the pad * @thumb: bitmask of thumbs on the pad * @pointing: bitmask of pointing fingers * @pending: bitmask of tentatively moving fingers * @moving: bitmask of moving fingers * @ybar: vertical position on pad marking the clicking area * @mvhold: movement before this point in time is accumulated * @mvforget: movement before this point in time is discarded * @dx: array of accumulated horiontal movement per finger * @dy: array of accumulated vertical movement per finger * @tpdown: time of first touch * @tpup: time of last release * @tprelax: time of next possible touch * @xdown: x position of first touch * @ydown: y position of first touch * @xup: x position of last release * @yup: y position of last release * @wait: time to wait for a second tap * @maxtap: max number of pointing fingers during touch * @ntap: number of taps in sequence * */ struct Memory { bitmask_t btdata, same; bitmask_t fingers, added, thumb; bitmask_t pointing, pending, moving; int ybar; mstime_t mvhold, mvforget; int dx[DIM_FINGER], dy[DIM_FINGER]; mstime_t tpdown, tpup, tprelax; int xdown, ydown, xup, yup; int wait, maxtap, ntap; }; void init_memory(struct Memory *mem); void refresh_memory(struct Memory *m, const struct MTState *prev_state, const struct MTState *state, const struct Capabilities *caps); void output_memory(const struct Memory *m); static inline void mem_hold_movement(struct Memory *m, mstime_t t) { if (t > m->mvhold) m->mvhold = t; } static inline void mem_forget_movement(struct Memory *m, mstime_t t) { if (t > m->mvforget) m->mvforget = t; } #endif xf86-input-multitouch-1.0~rc2+git20110312/include/mtouch.h000066400000000000000000000031521156123733600227760ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef MTOUCH_H #define MTOUCH_H #include "memory.h" struct MTouch { struct Capabilities caps; struct mtdev dev; struct HWState hs; struct MTState prev_state, state; struct Memory mem; }; int configure_mtouch(struct MTouch *mt, int fd); int open_mtouch(struct MTouch *mt, int fd); int close_mtouch(struct MTouch *mt, int fd); int read_packet(struct MTouch *mt, int fd); int has_delayed_gestures(struct MTouch *mt, int fd); static inline void mt_delay_movement(struct MTouch *mt, int t) { mem_hold_movement(&mt->mem, mt->state.evtime + t); } static inline void mt_skip_movement(struct MTouch *mt, int t) { mem_forget_movement(&mt->mem, mt->state.evtime + t); } #endif xf86-input-multitouch-1.0~rc2+git20110312/include/mtstate.h000066400000000000000000000033501156123733600231600ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #ifndef MTSTATE_H #define MTSTATE_H #include "hwstate.h" struct MTState { struct FingerState finger[DIM_FINGER]; int nfinger; bitmask_t thumb; bitmask_t button; mstime_t evtime; }; void init_mtstate(struct MTState *s); void extract_mtstate(struct MTState *s, const struct HWState *hs, const struct Capabilities *caps); void output_mtstate(const struct MTState *s); const struct FingerState *find_finger(const struct MTState *s, int id); static inline int center_dist2(const struct FingerState *a, const struct Capabilities *caps) { return dist2(a->position_x - get_cap_xmid(caps), a->position_y - get_cap_ymid(caps)); } static inline int center_maxdist2(const struct Capabilities *caps) { return dist2(get_cap_xsize(caps) / 2, get_cap_ysize(caps) / 2); } #endif xf86-input-multitouch-1.0~rc2+git20110312/include/xbypass.h000066400000000000000000000003151156123733600231660ustar00rootroot00000000000000#ifndef XBYPASS_H #define XBYPASS_H #include void xf86Msg(int type, const char *format, ...) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } #endif xf86-input-multitouch-1.0~rc2+git20110312/src/000077500000000000000000000000001156123733600204715ustar00rootroot00000000000000xf86-input-multitouch-1.0~rc2+git20110312/src/capabilities.c000066400000000000000000000123111156123733600232640ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include "capabilities.h" #define SETABS(c, x, map, key, fd) \ (c->has_##x = getbit(map, key) && getabs(&c->x, key, fd)) #define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "") static const int SN_COORD = 250; /* coordinate signal-to-noise ratio */ static const int SN_WIDTH = 100; /* width signal-to-noise ratio */ static const int SN_ORIENT = 10; /* orientation signal-to-noise ratio */ static const int bits_per_long = 8 * sizeof(long); static inline int nlongs(int nbit) { return (nbit + bits_per_long - 1) / bits_per_long; } static inline int getbit(const unsigned long *map, int key) { return (map[key / bits_per_long] >> (key % bits_per_long)) & 0x01; } static int getabs(struct input_absinfo *abs, int key, int fd) { int rc; SYSCALL(rc = ioctl(fd, EVIOCGABS(key), abs)); return rc >= 0; } static int has_mt_data(const struct Capabilities *cap) { return cap->has_abs[MTDEV_POSITION_X] && cap->has_abs[MTDEV_POSITION_Y]; } static int has_integrated_button(const struct Capabilities *cap) { static const int bcm5974_vmask_ibt = 1; /* magic trackpad */ if (cap->devid.vendor == 0x05ac && cap->devid.product == 0x030e) return 1; /* macbooks */ if (strcmp(cap->devname, "bcm5974")) return 0; return cap->devid.version & bcm5974_vmask_ibt; } static void default_fuzz(struct Capabilities *cap, unsigned int code, int sn) { int bit = mtdev_abs2mt(code); if (cap->has_abs[bit] && cap->abs[bit].fuzz == 0) cap->abs[bit].fuzz = (cap->abs[bit].maximum - cap->abs[bit].minimum) / sn; } int read_capabilities(struct Capabilities *cap, int fd) { unsigned long evbits[nlongs(EV_MAX)]; unsigned long absbits[nlongs(ABS_MAX)]; unsigned long keybits[nlongs(KEY_MAX)]; int rc, i; memset(cap, 0, sizeof(struct Capabilities)); SYSCALL(rc = ioctl(fd, EVIOCGID, &cap->devid)); if (rc < 0) return rc; SYSCALL(rc = ioctl(fd, EVIOCGNAME(sizeof(cap->devname)), cap->devname)); if (rc < 0) return rc; SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_SYN, sizeof(evbits)), evbits)); if (rc < 0) return rc; SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits)); if (rc < 0) return rc; SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits)); if (rc < 0) return rc; cap->has_left = getbit(keybits, BTN_LEFT); cap->has_middle = getbit(keybits, BTN_MIDDLE); cap->has_right = getbit(keybits, BTN_RIGHT); SETABS(cap, slot, absbits, ABS_MT_SLOT, fd); for (i = 0; i < MT_ABS_SIZE; i++) SETABS(cap, abs[i], absbits, mtdev_mt2abs(i), fd); cap->has_mtdata = has_mt_data(cap); cap->has_ibt = has_integrated_button(cap); default_fuzz(cap, ABS_MT_POSITION_X, SN_COORD); default_fuzz(cap, ABS_MT_POSITION_Y, SN_COORD); default_fuzz(cap, ABS_MT_TOUCH_MAJOR, SN_WIDTH); default_fuzz(cap, ABS_MT_TOUCH_MINOR, SN_WIDTH); default_fuzz(cap, ABS_MT_WIDTH_MAJOR, SN_WIDTH); default_fuzz(cap, ABS_MT_WIDTH_MINOR, SN_WIDTH); default_fuzz(cap, ABS_MT_ORIENTATION, SN_ORIENT); return 0; } int get_cap_xsize(const struct Capabilities *cap) { const struct input_absinfo *x = &cap->abs[MTDEV_POSITION_X]; return x->maximum - x->minimum; } int get_cap_ysize(const struct Capabilities *cap) { const struct input_absinfo *y = &cap->abs[MTDEV_POSITION_Y]; return y->maximum - y->minimum; } int get_cap_wsize(const struct Capabilities *cap) { const struct input_absinfo *w = &cap->abs[MTDEV_TOUCH_MAJOR]; return w->maximum - w->minimum; } int get_cap_xmid(const struct Capabilities *cap) { const struct input_absinfo *x = &cap->abs[MTDEV_POSITION_X]; return (x->maximum + x->minimum) >> 1; } int get_cap_ymid(const struct Capabilities *cap) { const struct input_absinfo *y = &cap->abs[MTDEV_POSITION_Y]; return (y->maximum + y->minimum) >> 1; } void output_capabilities(const struct Capabilities *cap) { char line[1024]; int i; memset(line, 0, sizeof(line)); ADDCAP(line, cap, left); ADDCAP(line, cap, middle); ADDCAP(line, cap, right); ADDCAP(line, cap, mtdata); ADDCAP(line, cap, ibt); xf86Msg(X_INFO, "multitouch: devname: %s\n", cap->devname); xf86Msg(X_INFO, "multitouch: devid: %x %x %x\n", cap->devid.vendor, cap->devid.product, cap->devid.version); xf86Msg(X_INFO, "multitouch: caps:%s\n", line); for (i = 0; i < MT_ABS_SIZE; i++) { if (cap->has_abs[i]) xf86Msg(X_INFO, "multitouch: %d: min: %d max: %d\n", i, cap->abs[i].minimum, cap->abs[i].maximum); } } xf86-input-multitouch-1.0~rc2+git20110312/src/gestures.c000066400000000000000000000136471156123733600225110ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * Gestures * Copyright (C) 2008 Henrik Rydberg * Copyright (C) 2010 Arturo Castro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include "gestures.h" static const int FINGER_THUMB_MS = 600; static const int BUTTON_HOLD_MS = 200; /** * extract_buttons * * Set the button gesture. * * Reset memory after use. * */ static void extract_buttons(struct Gestures *gs, struct MTouch* mt) { bitmask_t btdata = mt->state.button & BITONES(DIM_BUTTON); int npoint = bitcount(mt->mem.pointing); if (mt->state.button == BITMASK(MT_BUTTON_LEFT)) { if (npoint == 2) btdata = BITMASK(MT_BUTTON_RIGHT); if (npoint == 3) btdata = BITMASK(MT_BUTTON_MIDDLE); } if (mt->state.button != mt->prev_state.button) { gs->btmask = (btdata ^ mt->mem.btdata) & BITONES(DIM_BUTTON); gs->btdata = btdata; mt->mem.btdata = btdata; } else if (btdata == 0 && mt->mem.ntap) { if (npoint == 1 && mt->mem.maxtap == 1) btdata = BITMASK(MT_BUTTON_LEFT); gs->btmask = (btdata ^ mt->mem.btdata) & BITONES(DIM_BUTTON); gs->btdata = btdata; mt->mem.btdata = btdata; } if (gs->btmask) { mt_delay_movement(mt, BUTTON_HOLD_MS); SETBIT(gs->type, GS_BUTTON); } } /** * extract_movement * * Set the movement gesture. * * Reset memory after use. * */ static void extract_movement(struct Gestures *gs, struct MTouch* mt) { int npoint = bitcount(mt->mem.pointing); int nmove = bitcount(mt->mem.moving); int i; float xp[DIM_FINGER], yp[DIM_FINGER]; float xm[DIM_FINGER], ym[DIM_FINGER]; float xpos = 0, ypos = 0; float move, xmove = 0, ymove = 0; float rad, rad2 = 0, scale = 0, rot = 0; if (!nmove || nmove != npoint) return; foreach_bit(i, mt->mem.moving) { xp[i] = mt->state.finger[i].position_x - xpos; yp[i] = mt->state.finger[i].position_y - ypos; xm[i] = mt->mem.dx[i]; ym[i] = mt->mem.dy[i]; mt->mem.dx[i] = 0; mt->mem.dy[i] = 0; xpos += xp[i]; ypos += yp[i]; xmove += xm[i]; ymove += ym[i]; } xpos /= nmove; ypos /= nmove; xmove /= nmove; ymove /= nmove; move = sqrt(xmove * xmove + ymove * ymove); if (nmove == 1) { if (mt->mem.moving & mt->mem.thumb) { mt_skip_movement(mt, FINGER_THUMB_MS); return; } gs->dx = xmove; gs->dy = ymove; if (gs->dx || gs->dy) SETBIT(gs->type, GS_MOVE); return; } foreach_bit(i, mt->mem.moving) { xp[i] -= xpos; yp[i] -= ypos; rad2 += xp[i] * xp[i]; rad2 += yp[i] * yp[i]; scale += xp[i] * xm[i]; scale += yp[i] * ym[i]; rot += xp[i] * ym[i]; rot -= yp[i] * xm[i]; } rad2 /= nmove; scale /= nmove; rot /= nmove; rad = sqrt(rad2); scale /= rad; rot /= rad; if (abs(rot) > move && abs(rot) > abs(scale)) { gs->rot = rot; if (gs->rot) { if (nmove == 2) SETBIT(gs->type, GS_ROTATE); } } else if (abs(scale) > move) { gs->scale = scale; if (gs->scale) { if (nmove == 2) SETBIT(gs->type, GS_SCALE); } } else { if (mt->mem.moving & mt->mem.thumb) { mt_skip_movement(mt, FINGER_THUMB_MS); return; } gs->dx = xmove; gs->dy = ymove; if (abs(gs->dx) > abs(gs->dy)) { if (nmove == 2) SETBIT(gs->type, GS_HSCROLL); if (nmove == 3) SETBIT(gs->type, GS_HSWIPE); if (nmove == 4) SETBIT(gs->type, GS_HSWIPE4); } if (abs(gs->dy) > abs(gs->dx)) { if (nmove == 2) SETBIT(gs->type, GS_VSCROLL); if (nmove == 3) SETBIT(gs->type, GS_VSWIPE); if (nmove == 4) SETBIT(gs->type, GS_VSWIPE4); } } } /** * extract_gestures * * Extract the gestures. * * Reset memory after use. * */ void extract_gestures(struct Gestures *gs, struct MTouch* mt) { memset(gs, 0, sizeof(struct Gestures)); gs->same_fingers = mt->mem.same; extract_buttons(gs, mt); extract_movement(gs, mt); mt->prev_state = mt->state; } /** * extract_delayed_gestures * * Extract delayed gestures, such as tapping * * Reset memory after use. * */ void extract_delayed_gestures(struct Gestures *gs, struct MTouch* mt) { memset(gs, 0, sizeof(struct Gestures)); mt->mem.wait = 0; if (mt->mem.tpdown < mt->mem.tpup) { switch (mt->mem.maxtap) { case 1: gs->tapmask = BITMASK(MT_BUTTON_LEFT); break; case 2: gs->tapmask = BITMASK(MT_BUTTON_RIGHT); break; case 3: gs->tapmask = BITMASK(MT_BUTTON_MIDDLE); break; } } if (gs->tapmask) SETBIT(gs->type, GS_TAP); gs->ntap = mt->mem.ntap; } void output_gesture(const struct Gestures *gs) { int i; foreach_bit(i, gs->btmask) xf86Msg(X_INFO, "button bit: %d %d\n", i, GETBIT(gs->btdata, i)); if (GETBIT(gs->type, GS_MOVE)) xf86Msg(X_INFO, "motion: %d %d\n", gs->dx, gs->dy); if (GETBIT(gs->type, GS_VSCROLL)) xf86Msg(X_INFO, "vscroll: %d\n", gs->dy); if (GETBIT(gs->type, GS_HSCROLL)) xf86Msg(X_INFO, "hscroll: %d\n", gs->dx); if (GETBIT(gs->type, GS_VSWIPE)) xf86Msg(X_INFO, "vswipe: %d\n", gs->dy); if (GETBIT(gs->type, GS_HSWIPE)) xf86Msg(X_INFO, "hswipe: %d\n", gs->dx); if (GETBIT(gs->type, GS_SCALE)) xf86Msg(X_INFO, "scale: %d\n", gs->scale); if (GETBIT(gs->type, GS_ROTATE)) xf86Msg(X_INFO, "rotate: %d\n", gs->rot); foreach_bit(i, gs->tapmask) xf86Msg(X_INFO, "tap: %d %d\n", i, gs->ntap); } xf86-input-multitouch-1.0~rc2+git20110312/src/hwstate.c000066400000000000000000000064351156123733600223240ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include "hwstate.h" void init_hwstate(struct HWState *s, const struct Capabilities *caps) { int i; memset(s, 0, sizeof(struct HWState)); for (i = 0; i < DIM_FINGER; i++) s->data[i].tracking_id = MT_ID_NULL; } static void finish_packet(struct HWState *s, const struct Capabilities *caps, const struct input_event *syn) { static const mstime_t ms = 1000; int i; foreach_bit(i, s->used) { if (!caps->has_abs[MTDEV_TOUCH_MINOR]) s->data[i].touch_minor = s->data[i].touch_major; if (!caps->has_abs[MTDEV_WIDTH_MINOR]) s->data[i].width_minor = s->data[i].width_major; } s->evtime = syn->time.tv_usec / ms + syn->time.tv_sec * ms; } static int read_event(struct HWState *s, const struct Capabilities *caps, const struct input_event *ev) { switch (ev->type) { case EV_SYN: switch (ev->code) { case SYN_REPORT: finish_packet(s, caps, ev); return 1; } break; case EV_KEY: switch (ev->code) { case BTN_LEFT: MODBIT(s->button, MT_BUTTON_LEFT, ev->value); break; case BTN_MIDDLE: MODBIT(s->button, MT_BUTTON_MIDDLE, ev->value); break; case BTN_RIGHT: MODBIT(s->button, MT_BUTTON_RIGHT, ev->value); break; } break; case EV_ABS: switch (ev->code) { case ABS_MT_SLOT: if (ev->value >= 0 && ev->value < DIM_FINGER) s->slot = ev->value; break; case ABS_MT_TOUCH_MAJOR: s->data[s->slot].touch_major = ev->value; break; case ABS_MT_TOUCH_MINOR: s->data[s->slot].touch_minor = ev->value; break; case ABS_MT_WIDTH_MAJOR: s->data[s->slot].width_major = ev->value; break; case ABS_MT_WIDTH_MINOR: s->data[s->slot].width_minor = ev->value; break; case ABS_MT_ORIENTATION: s->data[s->slot].orientation = ev->value; break; case ABS_MT_PRESSURE: s->data[s->slot].pressure = ev->value; break; case ABS_MT_POSITION_X: s->data[s->slot].position_x = ev->value; break; case ABS_MT_POSITION_Y: s->data[s->slot].position_y = ev->value; break; case ABS_MT_TRACKING_ID: s->data[s->slot].tracking_id = ev->value; MODBIT(s->used, s->slot, ev->value != MT_ID_NULL); break; } break; } return 0; } int modify_hwstate(struct HWState *s, struct mtdev *dev, int fd, const struct Capabilities *caps) { struct input_event ev; int ret; while ((ret = mtdev_get(dev, fd, &ev, 1)) > 0) if (read_event(s, caps, &ev)) return 1; return ret; } xf86-input-multitouch-1.0~rc2+git20110312/src/memory.c000066400000000000000000000171621156123733600221540ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include "memory.h" #define use_tapping 1 /* click area definition */ #define CLICK_AREA(c) ((c->has_ibt ? 0.20 : 0.00) * get_cap_ysize(c)) /* fraction of max movement threshold */ #define DELTA_CUT(x) (0.5 * (x)) /* fraction of tap movement threshold */ #define TAP_XMOVE(c) (0.05 * get_cap_xsize(c)) #define TAP_YMOVE(c) (0.05 * get_cap_ysize(c)) /* timer for cursor stability on finger touch/release */ static const int FINGER_ATTACK_MS = 40; static const int FINGER_DECAY_MS = 120; static const int FINGER_CORNER_MS = 300; /* tapping timings */ static const int TAP_SETTLE_MS = 400; static const int TAP_TOUCH_MS = 120; static const int TAP_GAP_MS = 200; static inline int dxval(const struct FingerState *a, const struct FingerState *b) { return a->position_x - b->position_x; } static inline int dyval(const struct FingerState *a, const struct FingerState *b) { return a->position_y - b->position_y; } static inline void relax_tapping(struct Memory *m, const struct MTState *state) { m->tprelax = state->evtime + TAP_SETTLE_MS; m->wait = 0; m->ntap = 0; } static inline int unrelated_taps(const struct Memory *m, const struct Capabilities *caps) { return abs(m->xdown - m->xup) > TAP_XMOVE(caps) || abs(m->ydown - m->yup) > TAP_YMOVE(caps); } /** * init_memory */ void init_memory(struct Memory *mem) { memset(mem, 0, sizeof(struct Memory)); } /** * update_configuration * * Update the same, fingers, added, and thumb memory variables. * * Precondition: none * * Postcondition: same, fingers, added, thumb are set * */ static void update_configuration(struct Memory *m, const struct MTState *prev_state, const struct MTState *state) { const struct FingerState *f = state->finger; bitmask_t fingers = BITONES(state->nfinger); int i; m->added = 0; foreach_bit(i, fingers) if (!find_finger(prev_state, f[i].tracking_id)) SETBIT(m->added, i); m->same = m->fingers == fingers && m->added == 0; m->fingers = fingers; if (!m->same) m->thumb = 0; m->thumb |= state->thumb; } /** * update_pointers * * Update the pointing and ybar memory variables. * * Precondition: fingers, added, thumb are set * * Postcondition: pointing, ybar are set * */ static void update_pointers(struct Memory *m, const struct MTState *state, const struct Capabilities *caps) { const struct FingerState *f = state->finger; int yclick = caps->abs[MTDEV_POSITION_Y].maximum - CLICK_AREA(caps); int i; if (state->nfinger < 2) { m->pointing = m->fingers; m->ybar = caps->abs[MTDEV_POSITION_Y].maximum; return; } if (m->same) { foreach_bit(i, m->fingers & ~m->pointing) { if (f[i].position_y <= m->ybar) { m->pointing = m->fingers; return; } } return; } m->pointing = 0; m->ybar = yclick; foreach_bit(i, m->fingers) { if (f[i].position_y > yclick) continue; if (!m->pointing || f[i].position_y > m->ybar) m->ybar = f[i].position_y; SETBIT(m->pointing, i); } } /** * update_movement * * Update the pending, moving, mvhold, mvforget, dx and dy memory variables. * * When moving is nonzero, gestures can be extracted from the dx and dy * variables. These variables should be cleared after use. * * Precondition: fingers, added, thumb, pointing are set * * Postcondition: pending, moving, mvhold, mvforget, dx, dy are set * */ static void update_movement(struct Memory *m, const struct MTState *prev_state, const struct MTState *state, const struct Capabilities *caps) { const struct FingerState *prev, *f = state->finger; int i, xcut, ycut, xmax = 0, ymax = 0; m->moving = 0; m->pending = 0; if (!m->same) { mstime_t d2, d2max = center_maxdist2(caps); mem_hold_movement(m, state->evtime + FINGER_ATTACK_MS); if (!m->added) mem_hold_movement(m, state->evtime + FINGER_DECAY_MS); foreach_bit(i, m->added) { d2 = center_dist2(&f[i], caps); d2 *= FINGER_CORNER_MS - FINGER_ATTACK_MS; d2 /= d2max; m->mvhold += d2; } memset(m->dx, 0, sizeof(m->dx)); memset(m->dy, 0, sizeof(m->dy)); return; } if (state->evtime < m->mvforget) return; foreach_bit(i, m->pointing) { int dx, dy; prev = find_finger(prev_state, f[i].tracking_id); dx = dxval(&f[i], prev); dy = dyval(&f[i], prev); m->dx[i] += dx; m->dy[i] += dy; xmax = maxval(xmax, abs(m->dx[i])); ymax = maxval(ymax, abs(m->dy[i])); } xcut = DELTA_CUT(xmax); ycut = DELTA_CUT(ymax); foreach_bit(i, m->pointing) if (abs(m->dx[i]) > xcut || abs(m->dy[i]) > ycut) SETBIT(m->pending, i); if (state->evtime < m->mvhold) return; m->moving = m->pending; } /** * update_tapping * * Update tpdown, tpup, tprelax, wait, maxtap, ntap. * * Precondition: pointing and thumb are set * * Postcondition: tpdown, tpup, tprelax, wait, maxtap, ntap set * */ static void update_tapping(struct Memory *m, const struct MTState *prev_state, const struct MTState *state, const struct Capabilities *caps) { int x, y, i, npoint = bitcount(m->pointing); /* use a position independent on the number of fingers */ if (state->nfinger) { x = state->finger[0].position_x; y = state->finger[0].position_y; for (i = 1; i < state->nfinger; i++) { x = minval(x, state->finger[i].position_x); y = minval(y, state->finger[i].position_y); } } if (m->thumb || state->evtime < m->mvforget) { relax_tapping(m, state); } else if (state->nfinger && !prev_state->nfinger) { m->tpdown = state->evtime; m->xdown = x; m->ydown = y; m->wait = 0; m->maxtap = npoint; if (m->tpdown > m->tpup + TAP_GAP_MS) m->ntap = 0; else if (unrelated_taps(m, caps)) relax_tapping(m, state); m->xup = x; m->yup = y; } else if (!state->nfinger && prev_state->nfinger) { m->tpup = state->evtime; if (m->tpup > m->tprelax && m->tpup <= m->tpdown + TAP_TOUCH_MS) { m->wait = TAP_GAP_MS; m->ntap++; if (unrelated_taps(m, caps)) relax_tapping(m, state); } } else if (state->nfinger) { m->xup = minval(m->xup, x); m->yup = minval(m->yup, y); m->maxtap = maxval(m->maxtap, npoint); } } void refresh_memory(struct Memory *m, const struct MTState *prev_state, const struct MTState *state, const struct Capabilities *caps) { update_configuration(m, prev_state, state); update_pointers(m, state, caps); update_movement(m, prev_state, state, caps); if (use_tapping || !caps->has_left) update_tapping(m, prev_state, state, caps); } void output_memory(const struct Memory *m) { int i; xf86Msg(X_INFO, "btdata: %04x\n", m->btdata); xf86Msg(X_INFO, "fingers: %04x\n", m->fingers); xf86Msg(X_INFO, "added: %04x\n", m->added); xf86Msg(X_INFO, "pointing: %04x\n", m->pointing); xf86Msg(X_INFO, "pending: %04x\n", m->pending); xf86Msg(X_INFO, "moving: %04x\n", m->moving); xf86Msg(X_INFO, "ybar: %d\n", m->ybar); } xf86-input-multitouch-1.0~rc2+git20110312/src/mtouch.c000066400000000000000000000043471156123733600221440ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include "mtouch.h" static const int use_grab = 0; int configure_mtouch(struct MTouch *mt, int fd) { int rc = read_capabilities(&mt->caps, fd); if (rc < 0) return rc; output_capabilities(&mt->caps); return 0; } int open_mtouch(struct MTouch *mt, int fd) { int ret; ret = mtdev_open(&mt->dev, fd); if (ret) goto error; init_hwstate(&mt->hs, &mt->caps); init_mtstate(&mt->prev_state); init_mtstate(&mt->state); init_memory(&mt->mem); if (use_grab) { SYSCALL(ret = ioctl(fd, EVIOCGRAB, 1)); if (ret) goto close; } return 0; close: mtdev_close(&mt->dev); error: return ret; } int close_mtouch(struct MTouch *mt, int fd) { int ret; if (use_grab) { SYSCALL(ret = ioctl(fd, EVIOCGRAB, 0)); if (ret) xf86Msg(X_WARNING, "mtouch: ungrab failed\n"); } mtdev_close(&mt->dev); return 0; } int read_packet(struct MTouch *mt, int fd) { int ret = modify_hwstate(&mt->hs, &mt->dev, fd, &mt->caps); if (ret <= 0) return ret; extract_mtstate(&mt->state, &mt->hs, &mt->caps); #if 0 output_mtstate(&mt->state); #endif refresh_memory(&mt->mem, &mt->prev_state, &mt->state, &mt->caps); #if 0 output_memory(&mt->mem); #endif return 1; } int has_delayed_gestures(struct MTouch *mt, int fd) { return mt->mem.wait && mtdev_empty(&mt->dev) && mtdev_idle(&mt->dev, fd, mt->mem.wait); } xf86-input-multitouch-1.0~rc2+git20110312/src/mtstate.c000066400000000000000000000074521156123733600223260ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include "mtstate.h" #define TOUCH_WIDTH(hw) (0.05 * hw->width_major) #define TOUCH_SCALE(caps) (0.05 * caps->abs[MTDEV_TOUCH_MAJOR].maximum) #define THUMB_TOUCH(hw) (1.2 * hw->touch_minor) #define THUMB_TOUCH_SIZE(hw, caps) (0.14 * get_cap_xsize(caps)) #define THUMB_WIDTH_TOUCH(hw) (4 * hw->touch_major) #define THUMB_WIDTH_WIDTH(hw) (1.2 * hw->width_minor) #define THUMB_WIDTH_SIZE(hw, caps) (0.25 * get_cap_xsize(caps)) void init_mtstate(struct MTState *s) { memset(s, 0, sizeof(struct MTState)); } static int touching_finger(const struct FingerState *hw, const struct Capabilities *caps) { if (caps->has_abs[MTDEV_TOUCH_MAJOR] && caps->has_abs[MTDEV_WIDTH_MAJOR]) return hw->touch_major > TOUCH_WIDTH(hw); if (caps->has_abs[MTDEV_TOUCH_MAJOR]) return hw->touch_major > TOUCH_SCALE(caps); return 1; } /* * Thumb detection: * * The thumb is large and oval, even when not pressed hard against the * surface. The width_major parameter is therefore bounded from below * by all three values touch_major, width_minor, and trackpad size. * */ static int is_thumb(const struct FingerState *hw, const struct Capabilities *caps) { if (!caps->has_abs[MTDEV_TOUCH_MAJOR] || !caps->has_abs[MTDEV_TOUCH_MINOR]) return 0; if (!caps->has_abs[MTDEV_WIDTH_MAJOR] || !caps->has_abs[MTDEV_WIDTH_MINOR]) { return hw->touch_major > THUMB_TOUCH(hw) && hw->touch_major > THUMB_TOUCH_SIZE(hw, caps); } return hw->touch_major > THUMB_TOUCH(hw) && hw->width_major > THUMB_WIDTH_TOUCH(hw) && hw->width_major > THUMB_WIDTH_WIDTH(hw) && hw->width_major > THUMB_WIDTH_SIZE(hw, caps); } void extract_mtstate(struct MTState *s, const struct HWState *hs, const struct Capabilities *caps) { int i; s->nfinger = 0; s->thumb = 0; foreach_bit(i, hs->used) { if (!touching_finger(&hs->data[i], caps)) continue; s->finger[s->nfinger] = hs->data[i]; MODBIT(s->thumb, s->nfinger, is_thumb(&hs->data[i], caps)); s->nfinger++; } s->button = hs->button; s->evtime = hs->evtime; } const struct FingerState *find_finger(const struct MTState *s, int id) { int i; for (i = 0; i < s->nfinger; i++) if (s->finger[i].tracking_id == id) return s->finger + i; return NULL; } void output_mtstate(const struct MTState *s) { int i; xf86Msg(X_INFO, "buttons: %d%d%d\n", GETBIT(s->button, MT_BUTTON_LEFT), GETBIT(s->button, MT_BUTTON_MIDDLE), GETBIT(s->button, MT_BUTTON_RIGHT)); xf86Msg(X_INFO, "fingers: %d\n", s->nfinger); xf86Msg(X_INFO, "evtime: %lld\n", s->evtime); for (i = 0; i < s->nfinger; i++) { xf86Msg(X_INFO, " %+02d %+05d:%+05d +%05d:%+05d " "%+06d %+06d %+05d:%+05d\n", s->finger[i].tracking_id, s->finger[i].touch_major, s->finger[i].touch_minor, s->finger[i].width_major, s->finger[i].width_minor, s->finger[i].orientation, s->finger[i].pressure, s->finger[i].position_x, s->finger[i].position_y); } } xf86-input-multitouch-1.0~rc2+git20110312/src/test.c000066400000000000000000000034771156123733600216270ustar00rootroot00000000000000/*************************************************************************** * * Multitouch X driver * Copyright (C) 2008 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * **************************************************************************/ #include #include #include static void loop_device(int fd) { struct Gestures gs; struct MTouch mt; if (configure_mtouch(&mt, fd)) { fprintf(stderr, "error: could not configure device\n"); return; } if (open_mtouch(&mt, fd)) { fprintf(stderr, "error: could not open device\n"); return; } while (!mtdev_idle(&mt.dev, fd, 5000)) { while (read_packet(&mt, fd) > 0) { extract_gestures(&gs, &mt); output_gesture(&gs); } if (has_delayed_gestures(&mt, fd)) { extract_delayed_gestures(&gs, &mt); output_gesture(&gs); } } close_mtouch(&mt, fd); } int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: test \n"); return -1; } int fd = open(argv[1], O_RDONLY | O_NONBLOCK); if (fd < 0) { fprintf(stderr, "error: could not open file\n"); return -1; } loop_device(fd); close(fd); return 0; } xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/000077500000000000000000000000001156123733600227625ustar00rootroot00000000000000xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/README.Debian000066400000000000000000000001731156123733600250240ustar00rootroot00000000000000xf86-input-multitouch Xorg driver * Install the debian package * Restart X Enjoy! Henrik Rydberg xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/changelog000066400000000000000000000002741156123733600246370ustar00rootroot00000000000000xf86-input-multitouch (1.0~rc2-mactel1) unstable; urgency=low * Introducing the multitouch Xorg input driver -- Henrik Rydberg Thu, 21 Oct 2010 19:30:17 +0200 xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/compat000066400000000000000000000000021156123733600241600ustar00rootroot000000000000005 xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/control000066400000000000000000000010461156123733600243660ustar00rootroot00000000000000Source: xf86-input-multitouch Section: misc Priority: optional Maintainer: Henrik Rydberg Build-Depends: debhelper (>= 5), xserver-xorg-dev (>= 2:1.7.6.901), libmtdev-dev (>= 1.0.10) Standards-Version: 3.7.2 Homepage: http://bitmath.org/code/multitouch/ Package: xf86-input-multitouch Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libmtdev1 (>= 1.0) Description: Multitouch X input driver This X input driver provides gestures support for multitouch touchpads, in particular those with integrated button. xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/copyright000066400000000000000000000017031156123733600247160ustar00rootroot00000000000000Source URL: http://bitmath.org/code/multitouch/ Upstream Author: Henrik Rydberg Copyright: Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) License: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Packaging: Copyright (C) 2008 by Henrik Rydberg released under GPL 2 xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/dirs000066400000000000000000000000011156123733600236350ustar00rootroot00000000000000 xf86-input-multitouch-1.0~rc2+git20110312/upstream-debian/rules000077500000000000000000000012551156123733600240450ustar00rootroot00000000000000#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 build-arch: dh_testdir $(MAKE) build-indep: build: build-arch build-indep install: dh_testdir dh_testroot dh_clean -k dh_installdirs $(MAKE) DESTDIR=$(CURDIR)/debian/xf86-input-multitouch install binary-arch: build-arch install dh_testdir dh_testroot dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary-indep: build-indep binary: binary-arch binary-indep clean: dh_testdir dh_testroot $(MAKE) clean dh_clean .PHONY: build-arch build-indep build install binary-arch binary-indep binary clean