pax_global_header00006660000000000000000000000064145756361240014527gustar00rootroot0000000000000052 comment=17c24a81038c7e38ac79569a4a63108b06aa1383 pyinput-python-uinput-17c24a8/000077500000000000000000000000001457563612400164335ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/.gitignore000066400000000000000000000000761457563612400204260ustar00rootroot00000000000000**/*.pyc **/*.swp **/*.egg-info/ build/ dist/ _libsuinput.so pyinput-python-uinput-17c24a8/AUTHORS000066400000000000000000000005711457563612400175060ustar00rootroot00000000000000Eric Mikula Esa-Matti Suuronen Fabian Deutsch Kevin Ward Pascal Garber Tuomas Räsänen Vincent Bernat pablo a maurin timlyo pyinput-python-uinput-17c24a8/COPYING000066400000000000000000001043741457563612400174770ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . pyinput-python-uinput-17c24a8/LICENSE000077700000000000000000000000001457563612400204662COPYINGustar00rootroot00000000000000pyinput-python-uinput-17c24a8/MANIFEST.in000066400000000000000000000003121457563612400201650ustar00rootroot00000000000000include AUTHORS include NEWS include NEWS.rst include README include REAMDE.rst include COPYING include examples/* include libsuinput/src/suinput.h include libsuinput/src/libudev.h include udev-rules/* pyinput-python-uinput-17c24a8/NEWS000077700000000000000000000000001457563612400204332NEWS.rstustar00rootroot00000000000000pyinput-python-uinput-17c24a8/NEWS.rst000066400000000000000000000051341457563612400177440ustar00rootroot00000000000000======================================================= Python-uinput NEWS -- history of user-visible changes ======================================================= 1.0 === - Project repository moved to pyinput/python-uinput - Development Status: Stable - Modern packaging (pyproject.toml) - Python 3.12 support 0.11.2 ====== - Fix accidentally dropped support for libudev.so.0 by using ldconfig to find the available library version. 0.11.1 ====== - Fix compilation to link against libudev.so.1 instead of libudev.so. 0.11.0 ====== - New device method to close the device: ``Device.destroy()`` - ``Device()`` is now a context manager suitable to be used with ``with``-statement. - Improved device initialization error handling. - Updated README to include a recommendation to modprobe uinput kernel before usage. - Launchpad is deprecated in favor of GitHub. - New module function to open a file descriptor to uinput device: ``uinput.fdopen()`` - ``Device`` constructor accepts an open file descriptor to uinput device as a keyword argument. If not given, uinput file descriptor is opened via ``uinput.fdopen()``. - Both ``README`` and ``NEWS`` are renamed and converted to reStructuredText markup. - Input event codes included in ``uinput.ev`` module. - Add example of how to drop privileges after device initialization (contributed by Goncalo Pinheira). 0.10.2 ====== - Fix libudev1-compatibility issue. - Fix mouse example. 0.10.1 ====== - Fix Python3-compatibility issue. 0.10.0 ====== - New device methods: ``Device.emit_click()`` and ``Device.emit_combo()`` - Keyboard example sleeps to give some time for X11 to assign a proper event handler - Does not depend on libudev-dev anymore, because of newer libsuinput which re-distributes ``libudev.h``. 0.9 === - Python3 compatibility - Python2.6 compatibility 0.8 === - device id fields can be given in the constructor: bustype, vendor, product and version - an example of udev rule 0.7 === - libsuinput is included as a subtree 0.6.1 ===== - ``README`` and ``setup.py`` updated 0.6 === - Simplified API. - Uses ``ctypes`` instead of extension modules. - libsuinput is included as submodule in git repository - source distributions include ``suinput.c`` 0.5 === - Documented uinput-module. - A minimal joystick (abs-axis) example: ``examples/joystick.py``. - Reasonable defaults for ``abs_parameters`` (0, 255, 0, 0). 0.4 === - Updated project details, such as homepage, download url, etc. 0.3.3 ===== - Explicit dependence on libsuinput. 0.3.2 ===== - Mention Ubuntu-package in ``README``. 0.3.1 ===== - New license: GPLv3+ pyinput-python-uinput-17c24a8/README000077700000000000000000000000001457563612400207752README.rstustar00rootroot00000000000000pyinput-python-uinput-17c24a8/README.rst000066400000000000000000000055501457563612400201270ustar00rootroot00000000000000============== Python-uinput ============== Python-uinput is Python interface to Linux uinput kernel module which allows attaching userspace device drivers into kernel. In practice, Python-uinput makes it dead simple to create virtual joysticks, keyboards and mice for generating arbitrary input events programmatically. :Homepage: https://github.com/pyinput/python-uinput :License: GPLv3+ Usage examples ============== Generate keyboard clicks ------------------------ :: import uinput with uinput.Device([uinput.KEY_E, uinput.KEY_H, uinput.KEY_L, uinput.KEY_O]) as device: device.emit_click(uinput.KEY_H) device.emit_click(uinput.KEY_E) device.emit_click(uinput.KEY_L) device.emit_click(uinput.KEY_L) device.emit_click(uinput.KEY_O) Move mouse cursor ----------------- :: import uinput with uinput.Device([uinput.REL_X, uinput.REL_Y, uinput.BTN_LEFT, uinput.BTN_RIGHT]) as device: for i in range(20): device.emit(uinput.REL_X, 5) device.emit(uinput.REL_Y, 5) Generate keyboard combinations ------------------------------ :: import uinput with uinput.Device([uinput.KEY_LEFTALT, uinput.KEY_TAB]) as device: device.emit_combo([uinput.KEY_LEFTALT, uinput.KEY_TAB]) See ``examples/`` for other kind of example devices (keyboard, joystick). Note that you must have the uinput kernel module loaded to use python-uinput. To load the module, run:: modprobe -i uinput If you would like to have uinput to be loaded on every sytem boot, add uinput to ``/etc/modules``. How to install ============== Just run the following commands:: python setup.py build python setup.py install How to report bugs ================== The bug database is hosted in GitHub. If you have found a bug or have an improvement idea you want to share, please report it at . However, to avoid duplicate bug reports, before reporting, please check if similar or identical bug has already been reported. If so, you can still subscribe to the existing bug to track its progress. How to contribute ================= In addition to reporting bugs and improvement suggestions, you are encouraged to contribute bug-fixes or features. The source code is maintained in Git and the main repository is hosted at GitHub, . The preferred way to contribute code is to clone the main Git repository and send a pull-request. Good old patches via email are also accepted. How to copy =========== Python-uinput is free (libre) software and licensed under the terms of GNU Public License version 3 or later. In short, it means that you are free to copy, modify and redistribute this software as long as you place the derivative work under a compatible license. See ``COPYING`` for details. pyinput-python-uinput-17c24a8/examples/000077500000000000000000000000001457563612400202515ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/examples/drop_privileges.py000077500000000000000000000013061457563612400240230ustar00rootroot00000000000000import grp import os import pwd import uinput def drop_privileges(uid_name='nobody', gid_name='nogroup'): # https://stackoverflow.com/questions/2699907/dropping-root-permissions-in-python if os.getuid() != 0: return running_uid = pwd.getpwnam(uid_name).pw_uid running_gid = grp.getgrnam(gid_name).gr_gid os.setgroups([]) os.setgid(running_gid) os.setuid(running_uid) old_umask = os.umask(0o77) def main(): uinput_fd = uinput.fdopen() drop_privileges() # No need to be root beyond this line. events = (uinput.KEY_A,) with uinput.Device(events, fd=uinput_fd) as device: device.emit_click(uinput.KEY_A) if __name__ == "__main__": main() pyinput-python-uinput-17c24a8/examples/joystick.py000077500000000000000000000007231457563612400224670ustar00rootroot00000000000000import uinput def main(): events = ( uinput.BTN_JOYSTICK, uinput.ABS_X + (0, 255, 0, 0), uinput.ABS_Y + (0, 255, 0, 0), ) with uinput.Device(events) as device: for i in range(20): # syn=False to emit an "atomic" (5, 5) event. device.emit(uinput.ABS_X, 5, syn=False) device.emit(uinput.ABS_Y, 5) device.emit_click(uinput.BTN_JOYSTICK) if __name__ == "__main__": main() pyinput-python-uinput-17c24a8/examples/keyboard.py000077500000000000000000000022031457563612400224230ustar00rootroot00000000000000import time import uinput def main(): events = ( uinput.KEY_E, uinput.KEY_H, uinput.KEY_L, uinput.KEY_O, ) with uinput.Device(events) as device: time.sleep(1) # This is required here only for demonstration # purposes. Without this, the underlying machinery might # not have time to assign a proper handler for our device # before the execution of this script reaches the end and # the device is destroyed. At least this seems to be the # case with X11 and its generic event device # handlers. Without this magical sleep, "hello" might not # get printed because this example exits before X11 gets # its handlers ready for processing events from this # device. device.emit_click(uinput.KEY_H) device.emit_click(uinput.KEY_E) device.emit_click(uinput.KEY_L) device.emit_click(uinput.KEY_L) device.emit_click(uinput.KEY_O) if __name__ == "__main__": main() pyinput-python-uinput-17c24a8/examples/mouse.py000077500000000000000000000011061457563612400217540ustar00rootroot00000000000000import time import uinput def main(): events = ( uinput.REL_X, uinput.REL_Y, uinput.BTN_LEFT, uinput.BTN_RIGHT, ) with uinput.Device(events) as device: for i in range(20): # syn=False to emit an "atomic" (5, 5) event. device.emit(uinput.REL_X, 5, syn=False) device.emit(uinput.REL_Y, 5) # Just for demonstration purposes: shows the motion. In real # application, this is of course unnecessary. time.sleep(0.01) if __name__ == "__main__": main() pyinput-python-uinput-17c24a8/libsuinput/000077500000000000000000000000001457563612400206315ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/libsuinput/AUTHORS000066400000000000000000000003221457563612400216760ustar00rootroot00000000000000Eric Mikula Esa-Matti Suuronen Pascal Garber Tuomas Räsänen Vincent Bernat pyinput-python-uinput-17c24a8/libsuinput/COPYING000066400000000000000000001043741457563612400216750ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . pyinput-python-uinput-17c24a8/libsuinput/INSTALL000066400000000000000000000271361457563612400216730ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 6. Often, you can also type `make uninstall' to remove the installed files again. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *Note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. pyinput-python-uinput-17c24a8/libsuinput/Makefile.am000066400000000000000000000000501457563612400226600ustar00rootroot00000000000000# ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src pyinput-python-uinput-17c24a8/libsuinput/NEWS000066400000000000000000000021471457563612400213340ustar00rootroot00000000000000==================================================== Libsuinput NEWS -- history of user-visible changes ==================================================== Release x.y.z ============= - Link against libudev.so.1 - Update libudev.h to match with libudev.so.1 from systemd-215 Release 0.6.1 ============= - Compilation improvements (thanks to Eric Mikula and Vincent Bernat) - Give credit to all AUTHORS Release 0.6.0 ============= - API changes: - add new function `suinput_emit_click()`. - add new function `suinput_emit_combo()`. - SO-version: 5.0.1 - Re-distribute libudev.h Release 0.5 =========== - Use GNU Autotools as a build system. - API change: `suinput_set_capabilites()` is replaced by `suinput_enable_event()`. - API change: `suinput_write()` renamed to `suinput_emit()`. - API change: removed `suinput_get_uinput_path()`. - SO-version: 4 Release 0.4 =========== - Licensing changed from LGPLv3+ to GPLv3+. - Usage examples are now included. Release 0.3 =========== - More generic interface that is "compatible" with standard uinput. - Functions operating on an uinput file descriptor. pyinput-python-uinput-17c24a8/libsuinput/README000066400000000000000000000035611457563612400215160ustar00rootroot00000000000000============ Libsuinput ============ Uinput is Linux kernel module which allows attaching userspace device drivers into the Linux kernel. However, its ioctl-interface is pretty low level from an application developer's perspective. This library provides a set of helper functions for making the usage of uinput easier. Libsuinput can be considered thin, because it operates on the same file descriptors as traditional ioctl commands. Author: Tuomas Räsänen Homepage: How to install ============== Just run the following commands: ./configure && make && make install It installs the library to /usr/local/lib and header files to /usr/local/include. See INSTALL for details. How to report bugs ================== The bug database is hosted in GitHub. If you have found a bug or have an improvement idea you want to share, please report it at . However, to avoid duplicate bug reports, before reporting, please check if similar or identical bug has already been reported. If so, you can still subscribe to the existing bug to track its progress. How to contribute ================= In addition to reporting bugs and improvement suggestions, you are encouraged to contribute bug-fixes or features. Source code is maintained in Git and the main repository is hosted at GitHub, . The preferred way to contribute code is to clone the main Git repository and send a pull-request. Good old patches via email are also accepted. How to copy =========== Libsuinput is free (libre) software and licensed under the terms of GNU Public License version 3 or later. In short, it means that you are free to copy, modify and redistribute this software as long as you place the derivative work under a compatible license. See COPYING for details. pyinput-python-uinput-17c24a8/libsuinput/autogen.sh000077500000000000000000000000621457563612400226300ustar00rootroot00000000000000#!/bin/sh autoreconf --install --force --symlink pyinput-python-uinput-17c24a8/libsuinput/configure.ac000066400000000000000000000006071457563612400231220ustar00rootroot00000000000000AC_INIT([libsuinput], [0.6.1], [https://github.com/tuomasjjrasanen/libsuinput/issues], [libsuinput], [http://tjjr.fi/sw/libsuinput/]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AM_PROG_AR AC_PROG_LIBTOOL AC_PROG_CC AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_FILES([ Makefile src/Makefile src/libsuinput.pc ]) AC_OUTPUT pyinput-python-uinput-17c24a8/libsuinput/examples/000077500000000000000000000000001457563612400224475ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/libsuinput/examples/Makefile000066400000000000000000000005731457563612400241140ustar00rootroot00000000000000CFLAGS = -Wall -Wextra -Werror -pedantic CFLAGS_ALL = $(CFLAGS) LDFLAGS = LDFLAGS_ALL = $(LDFLAGS) -lsuinput CPPFLAGS = CPPFLAGS_ALL = $(CPPFLAGS) PROGRAMS = keyboard mouse .PHONY: all clean all: $(PROGRAMS) %.o : %.c $(CC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) -c -o $@ $< $(PROGRAMS) : % : %.o $(CC) $(LDFLAGS_ALL) $(CFLAGS_ALL) -o $@ $< clean: rm -f $(PROGRAMS) rm -f *.o pyinput-python-uinput-17c24a8/libsuinput/examples/keyboard.c000066400000000000000000000023741457563612400244210ustar00rootroot00000000000000#include #include #include #include #include int main(void) { int i; int uinput_fd; int keys[] = {KEY_E, KEY_H, KEY_L, KEY_O}; struct uinput_user_dev user_dev; memset(&user_dev, 0, sizeof(struct uinput_user_dev)); strcpy(user_dev.name, "libsuinput-example-keyboard"); uinput_fd = suinput_open(); if (uinput_fd == -1) err(1, "suinput_open"); /* Error handling is omitted to keep code as readible as possible. */ for (i = 0; i < 4; ++i) { suinput_enable_event(uinput_fd, EV_KEY, keys[i]); } suinput_create(uinput_fd, &user_dev); sleep(1); suinput_emit_click(uinput_fd, KEY_H); suinput_syn(uinput_fd); sleep(1); suinput_emit_click(uinput_fd, KEY_E); suinput_syn(uinput_fd); sleep(1); suinput_emit_click(uinput_fd, KEY_L); suinput_syn(uinput_fd); sleep(1); suinput_emit_click(uinput_fd, KEY_L); suinput_syn(uinput_fd); sleep(1); suinput_emit_click(uinput_fd, KEY_O); suinput_syn(uinput_fd); sleep(1); suinput_destroy(uinput_fd); return 0; } pyinput-python-uinput-17c24a8/libsuinput/examples/mouse.c000066400000000000000000000025451457563612400237510ustar00rootroot00000000000000#include #include #include #include #include #include int main(void) { int uinput_fd; int btns[] = {BTN_LEFT, BTN_RIGHT, BTN_MIDDLE}; int rel_axes[] = {REL_X, REL_Y, REL_WHEEL}; struct uinput_user_dev user_dev; int i; memset(&user_dev, 0, sizeof(struct uinput_user_dev)); strcpy(user_dev.name, "libsuinput-example-mouse"); uinput_fd = suinput_open(); if (uinput_fd == -1) err(1, "suinput_open"); /* Error handling is omitted to keep code as readible as possible. */ for (i = 0; i < 3; ++i) { suinput_enable_event(uinput_fd, EV_KEY, btns[i]); } for (i = 0; i < 3; ++i) { suinput_enable_event(uinput_fd, EV_REL, rel_axes[i]); } suinput_create(uinput_fd, &user_dev); /* Move pointer 20 * 5 units towards bottom-right. */ for (i = 0; i < 20; ++i) { struct timespec sleeptime = {0, 50000000}; suinput_emit(uinput_fd, EV_REL, REL_X, 5); suinput_emit(uinput_fd, EV_REL, REL_Y, 5); suinput_syn(uinput_fd); nanosleep(&sleeptime, NULL); } suinput_emit_click(uinput_fd, BTN_LEFT); suinput_destroy(uinput_fd); return 0; } pyinput-python-uinput-17c24a8/libsuinput/src/000077500000000000000000000000001457563612400214205ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/libsuinput/src/Makefile.am000066400000000000000000000004621457563612400234560ustar00rootroot00000000000000AM_CPPFLAGS = -Wall -Werror -Wextra -pedantic -std=gnu99 lib_LTLIBRARIES = libsuinput.la libsuinput_la_SOURCES = suinput.c libsuinput_la_LDFLAGS = -l:libudev.so.1 -version-info 5:0:1 include_HEADERS = suinput.h noinst_HEADERS = libudev.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libsuinput.pc pyinput-python-uinput-17c24a8/libsuinput/src/libsuinput.pc.in000066400000000000000000000004131457563612400245450ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: @PACKAGE_NAME@ Description: Thin userspace library on top of Linux uinput kernel module Version: @VERSION@ URL: @PACKAGE_URL@ Libs: -L${libdir} -lsuinput Cflags: -I${includedir} pyinput-python-uinput-17c24a8/libsuinput/src/libudev.h000066400000000000000000000237161457563612400232340ustar00rootroot00000000000000/*** This file is part of systemd. Copyright 2008-2012 Kay Sievers systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ #ifndef _LIBUDEV_H_ #define _LIBUDEV_H_ #include #include #include #ifdef __cplusplus extern "C" { #endif /* * udev - library context * * reads the udev config and system environment * allows custom logging */ struct udev; struct udev *udev_ref(struct udev *udev); struct udev *udev_unref(struct udev *udev); struct udev *udev_new(void); void udev_set_log_fn(struct udev *udev, void (*log_fn)(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args)); int udev_get_log_priority(struct udev *udev); void udev_set_log_priority(struct udev *udev, int priority); void *udev_get_userdata(struct udev *udev); void udev_set_userdata(struct udev *udev, void *userdata); /* * udev_list * * access to libudev generated lists */ struct udev_list_entry; struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry); struct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name); const char *udev_list_entry_get_name(struct udev_list_entry *list_entry); const char *udev_list_entry_get_value(struct udev_list_entry *list_entry); /** * udev_list_entry_foreach: * @list_entry: entry to store the current position * @first_entry: first entry to start with * * Helper to iterate over all entries of a list. */ #define udev_list_entry_foreach(list_entry, first_entry) \ for (list_entry = first_entry; \ list_entry != NULL; \ list_entry = udev_list_entry_get_next(list_entry)) /* * udev_device * * access to sysfs/kernel devices */ struct udev_device; struct udev_device *udev_device_ref(struct udev_device *udev_device); struct udev_device *udev_device_unref(struct udev_device *udev_device); struct udev *udev_device_get_udev(struct udev_device *udev_device); struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath); struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum); struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname); struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id); struct udev_device *udev_device_new_from_environment(struct udev *udev); /* udev_device_get_parent_*() does not take a reference on the returned device, it is automatically unref'd with the parent */ struct udev_device *udev_device_get_parent(struct udev_device *udev_device); struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype); /* retrieve device properties */ const char *udev_device_get_devpath(struct udev_device *udev_device); const char *udev_device_get_subsystem(struct udev_device *udev_device); const char *udev_device_get_devtype(struct udev_device *udev_device); const char *udev_device_get_syspath(struct udev_device *udev_device); const char *udev_device_get_sysname(struct udev_device *udev_device); const char *udev_device_get_sysnum(struct udev_device *udev_device); const char *udev_device_get_devnode(struct udev_device *udev_device); int udev_device_get_is_initialized(struct udev_device *udev_device); struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device); struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device); struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device); struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device); const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key); const char *udev_device_get_driver(struct udev_device *udev_device); dev_t udev_device_get_devnum(struct udev_device *udev_device); const char *udev_device_get_action(struct udev_device *udev_device); unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device); unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device); const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr); int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value); int udev_device_has_tag(struct udev_device *udev_device, const char *tag); /* * udev_monitor * * access to kernel uevents and udev events */ struct udev_monitor; struct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor); struct udev_monitor *udev_monitor_unref(struct udev_monitor *udev_monitor); struct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor); /* kernel and udev generated events over netlink */ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name); /* bind socket */ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor); int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size); int udev_monitor_get_fd(struct udev_monitor *udev_monitor); struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor); /* in-kernel socket filters to select messages that get delivered to a listener */ int udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor, const char *subsystem, const char *devtype); int udev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag); int udev_monitor_filter_update(struct udev_monitor *udev_monitor); int udev_monitor_filter_remove(struct udev_monitor *udev_monitor); /* * udev_enumerate * * search sysfs for specific devices and provide a sorted list */ struct udev_enumerate; struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate); struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate); struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate); struct udev_enumerate *udev_enumerate_new(struct udev *udev); /* device properties filter */ int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem); int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem); int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value); int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value); int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname); int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag); int udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent); int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate); int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath); /* run enumeration with active filters */ int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate); int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate); /* return device list */ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate); /* * udev_queue * * access to the currently running udev events */ struct udev_queue; struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue); struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue); struct udev *udev_queue_get_udev(struct udev_queue *udev_queue); struct udev_queue *udev_queue_new(struct udev *udev); unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated)); unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated)); int udev_queue_get_udev_is_active(struct udev_queue *udev_queue); int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue); int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) __attribute__ ((deprecated)); int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue, unsigned long long int start, unsigned long long int end) __attribute__ ((deprecated)); int udev_queue_get_fd(struct udev_queue *udev_queue); int udev_queue_flush(struct udev_queue *udev_queue); struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) __attribute__ ((deprecated)); /* * udev_hwdb * * access to the static hardware properties database */ struct udev_hwdb; struct udev_hwdb *udev_hwdb_new(struct udev *udev); struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb); struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb); struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags); /* * udev_util * * udev specific utilities */ int udev_util_encode_string(const char *str, char *str_enc, size_t len); #ifdef __cplusplus } /* extern "C" */ #endif #endif pyinput-python-uinput-17c24a8/libsuinput/src/suinput.c000066400000000000000000000133301457563612400232730ustar00rootroot00000000000000/* libsuinput - thin userspace library on top of Linux uinput kernel module Copyright (C) 2013 Tuomas Räsänen 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 3 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, see . */ #include #include #include #include #include #include #include "libudev.h" #include "suinput.h" int suinput_write_event(int uinput_fd, const struct input_event *event_p) { ssize_t bytes; bytes = write(uinput_fd, event_p, sizeof(struct input_event)); if (bytes != sizeof(struct input_event)) { return -1; } return 0; } int suinput_emit(int uinput_fd, uint16_t ev_type, uint16_t ev_code, int32_t ev_value) { struct input_event event; memset(&event, 0, sizeof(event)); gettimeofday(&event.time, 0); event.type = ev_type; event.code = ev_code; event.value = ev_value; return suinput_write_event(uinput_fd, &event); } int suinput_emit_click(const int uinput_fd, const uint16_t key_code) { if (suinput_emit(uinput_fd, EV_KEY, key_code, 1) == -1) return -1; return suinput_emit(uinput_fd, EV_KEY, key_code, 0); } int suinput_emit_combo(const int uinput_fd, const uint16_t *const key_codes, const size_t len) { int retval = 0; size_t i; for (i = 0; i < len; ++i) { if (suinput_emit(uinput_fd, EV_KEY, key_codes[i], 1) == -1) { retval = -1; break; /* The combination or the device is somehow broken: there's no sense to press any of the rest of the keys. It's like pressing physical keys one by one and then discovering that one of the keys required for this combination is missing or broken. */ } } /* Try to release every pressed key, no matter what. */ while (i--) { if (suinput_emit(uinput_fd, EV_KEY, key_codes[i], 0) == -1) { retval = -1; } } return retval; } int suinput_syn(int uinput_fd) { return suinput_emit(uinput_fd, EV_SYN, SYN_REPORT, 0); } static char *suinput_get_uinput_path(void) { struct udev *udev; struct udev_device *udev_dev; const char *devnode; char *retval = NULL; int orig_errno; if ((udev = udev_new()) == NULL) { return NULL; } udev_dev = udev_device_new_from_subsystem_sysname(udev, "misc", "uinput"); if (udev_dev == NULL) { goto out; } if ((devnode = udev_device_get_devnode(udev_dev)) == NULL) { goto out; } if ((retval = malloc(strlen(devnode) + 1)) == NULL) { goto out; } strcpy(retval, devnode); out: orig_errno = errno; udev_device_unref(udev_dev); udev_unref(udev); errno = orig_errno; return retval; } int suinput_open(void) { int uinput_fd; char *uinput_path; if ((uinput_path = suinput_get_uinput_path()) == NULL) { return -1; } uinput_fd = open(uinput_path, O_WRONLY | O_NONBLOCK); free(uinput_path); return uinput_fd; } int suinput_create(int uinput_fd, const struct uinput_user_dev *user_dev_p) { ssize_t bytes; bytes = write(uinput_fd, user_dev_p, sizeof(struct uinput_user_dev)); if (bytes != sizeof(struct uinput_user_dev)) { return -1; } if (ioctl(uinput_fd, UI_DEV_CREATE) == -1) { return -1; } return 0; } int suinput_destroy(int uinput_fd) { if (ioctl(uinput_fd, UI_DEV_DESTROY) == -1) { int original_errno = errno; close(uinput_fd); errno = original_errno; return -1; } return close(uinput_fd); } int suinput_enable_event(int uinput_fd, uint16_t ev_type, uint16_t ev_code) { unsigned long io; if (ioctl(uinput_fd, UI_SET_EVBIT, ev_type) == -1) { return -1; } switch (ev_type) { case EV_KEY: io = UI_SET_KEYBIT; break; case EV_REL: io = UI_SET_RELBIT; break; case EV_ABS: io = UI_SET_ABSBIT; break; case EV_MSC: io = UI_SET_MSCBIT; break; case EV_SW: io = UI_SET_SWBIT; break; case EV_LED: io = UI_SET_LEDBIT; break; case EV_SND: io = UI_SET_SNDBIT; break; case EV_FF: io = UI_SET_FFBIT; break; default: errno = EINVAL; return -1; } return ioctl(uinput_fd, io, ev_code); } pyinput-python-uinput-17c24a8/libsuinput/src/suinput.h000066400000000000000000000027701457563612400233060ustar00rootroot00000000000000/* libsuinput - thin userspace library on top of Linux uinput kernel module Copyright (C) 2013 Tuomas Räsänen 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 3 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, see . */ #ifndef SUINPUT_H #define SUINPUT_H #include #include #ifdef __cplusplus extern "C" { #endif int suinput_open(void); int suinput_enable_event(int uinput_fd, uint16_t ev_type, uint16_t ev_code); int suinput_create(int uinput_fd, const struct uinput_user_dev *user_dev_p); int suinput_write_event(int uinput_fd, const struct input_event *event_p); int suinput_emit(int uinput_fd, uint16_t ev_type, uint16_t ev_code, int32_t ev_value); int suinput_emit_click(int uinput_fd, uint16_t key_code); int suinput_emit_combo(int uinput_fd, const uint16_t *key_codes, size_t len); int suinput_syn(int uinput_fd); int suinput_destroy(int uinput_fd); #ifdef __cplusplus } #endif #endif /* SUINPUT_H */ pyinput-python-uinput-17c24a8/pyproject.toml000066400000000000000000000020211457563612400213420ustar00rootroot00000000000000[project] name = "python-uinput" version = "1.0.1" description = "Pythonic API to Linux uinput kernel module." authors = [ {name = "pyinput"}, ] license = {text = "GPLv3+"} readme = "README" dependencies = [] requires-python = ">=2.7" classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: POSIX :: Linux", "Topic :: System :: Operating System Kernels :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.12", ] [project.urls] Homepage = "https://github.com/pyinput/python-uinput" [tool.poetry.dependencies] python = ">=2.7" [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [tool.setuptools] package-dir = { "uinput" = "src" } pyinput-python-uinput-17c24a8/scripts/000077500000000000000000000000001457563612400201225ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/scripts/parse-event-codes000077500000000000000000000021471457563612400234000ustar00rootroot00000000000000#!/usr/bin/env python from __future__ import print_function from __future__ import with_statement import re import sys def parse_event_codes(filepath, ev_type, ev_name): with open(filepath) as f: ev_codes = {} for line in f: match = re.match(r"^#define (" + ev_name + "_.*)\t+((?:0x[0-9a-f]+)|(?:\d+))", line) if match: ev_id = match.group(1).strip() ev_code = match.group(2).strip() ev_codes[ev_id] = ev_code print("%s = (%s, %s)" % (ev_id, ev_type, ev_code)) continue match = re.match(r"^#define (" + ev_name + "_.*)\t+((?:[A-Z_]+))", line) if match: ev_id = match.group(2).strip() ev_code = ev_codes[ev_id] print("%s = (%s, %s)" % (match.group(1).strip(), ev_type, ev_code)) if __name__ == "__main__": filepath = sys.argv[1] parse_event_codes(filepath, "0x01", "KEY") parse_event_codes(filepath, "0x01", "BTN") parse_event_codes(filepath, "0x02", "REL") parse_event_codes(filepath, "0x03", "ABS") pyinput-python-uinput-17c24a8/setup.py000066400000000000000000000046461457563612400201570ustar00rootroot00000000000000# -*- coding: utf-8 -*- import errno import subprocess try: from setuptools import setup, Extension except ImportError: from distutils.core import setup, Extension libudev_so = "libudev.so.1" # Because libsuinput can be linked against both libudev.so.0 and # libudev.so.1, we try to use ldconfig to find out which one is # available. Preferably libudev.so.1. try: ldconfig_output = subprocess.check_output(["ldconfig", "-p"]) for line in ldconfig_output.splitlines(): try: lib = line.split()[0] except IndexError: # An unexpected line, but let's proceed. continue if lib == "libudev.so.0": libudev_so = lib # We are quite happy, but let's look if there's something # better. if lib == "libudev.so.1": libudev_so = lib break # We are really happy, no reason to look further. except: # We don't care if something goes wrong while we scan through all # the available libraries. The whole scan operation is just # best-effort, we can always fall back to the default, hard-coded, # library. pass setup(name='python-uinput', version='1.0.1', description='Pythonic API to Linux uinput kernel module.', author='pyinput', url='https://github.com/pyinput/python-uinput', package_dir={'uinput': 'src'}, packages=['uinput'], license='GPLv3+', platforms=['Linux'], classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: POSIX :: Linux", "Topic :: System :: Operating System Kernels :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.12", ], long_description=""" Python-uinput is Python interface to Linux uinput kernel module which allows attaching userspace device drivers into kernel. In practice, Python-uinput makes it dead simple to create virtual joysticks, keyboards and mice for generating arbitrary input events programmatically. """, ext_modules=[Extension('_libsuinput', ['libsuinput/src/suinput.c'], libraries=[":%s" % libudev_so])] ) pyinput-python-uinput-17c24a8/src/000077500000000000000000000000001457563612400172225ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/src/__init__.py000066400000000000000000000225321457563612400213370ustar00rootroot00000000000000# -*- coding: utf-8 -*- # uinput - Python bindings for Linux uinput system # Copyright © 2012, 2013, 2014 Tuomas Räsänen # 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 3 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, see . """ Python bindings to Linux uinput system. Usage: >>> import uinput >>> events = ( ... uinput.BTN_JOYSTICK, ... uinput.ABS_X + (0, 255, 0, 0), ... uinput.ABS_Y + (0, 255, 0, 0), ... ) >>> with uinput.Device(events) as device: ... device.emit(uinput.ABS_X, 5, syn=False) ... device.emit(uinput.ABS_Y, 5) ... device.emit_click(uinput.BTN_JOYSTICK) """ from __future__ import absolute_import import ctypes import errno import os try: import sysconfig except ImportError: # python < 3.2 import distutils.sysconfig as sysconfig from .ev import * _UINPUT_MAX_NAME_SIZE = 80 _ABS_CNT = ABS_MAX[1] + 1 class _struct_input_id(ctypes.Structure): _fields_ = [("bustype", ctypes.c_int16), ("vendor", ctypes.c_int16), ("product", ctypes.c_int16), ("version", ctypes.c_int16), ] class _struct_uinput_user_dev(ctypes.Structure): _fields_ = [("name", ctypes.c_char * _UINPUT_MAX_NAME_SIZE), ("id", _struct_input_id), ("ff_effects_max", ctypes.c_int), ("absmax", ctypes.c_int * _ABS_CNT), ("absmin", ctypes.c_int * _ABS_CNT), ("absfuzz", ctypes.c_int * _ABS_CNT), ("absflat", ctypes.c_int * _ABS_CNT), ] def _open_error_handler(result, fn, args): if result == -1: code = ctypes.get_errno() msg = "Failed to open the uinput device: %s" % os.strerror(code) if code == errno.ENOENT: raise OSError(code, "%s. Perhaps load the uinput kernel module first?" % msg) else: raise OSError(code, msg) elif result < -1: raise RuntimeError("unexpected return value: %s" % result) return result def _error_handler(result, fn, args): if result == -1: code = ctypes.get_errno() raise OSError(code, os.strerror(code)) elif result < -1: raise RuntimeError("unexpected return value: %s" % result) return result def fdopen(): return _libsuinput.suinput_open() def get_libsuinput_path(): repo_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) # python 2 / 3 compatibility ("SO" is now deprecated) extension = sysconfig.get_config_var("EXT_SUFFIX") or sysconfig.get_config_var("SO") path = os.path.join(repo_dir, "_libsuinput" + extension) return path _libsuinput_path = get_libsuinput_path() _libsuinput = ctypes.CDLL(_libsuinput_path, use_errno=True) _libsuinput.suinput_open.errcheck = _open_error_handler _libsuinput.suinput_enable_event.errcheck = _error_handler _libsuinput.suinput_create.errcheck = _error_handler _libsuinput.suinput_write_event.errcheck = _error_handler _libsuinput.suinput_emit.errcheck = _error_handler _libsuinput.suinput_emit_click.errcheck = _error_handler _libsuinput.suinput_emit_combo.errcheck = _error_handler _libsuinput.suinput_syn.errcheck = _error_handler _libsuinput.suinput_destroy.errcheck = _error_handler _CHAR_MAP = { "a": KEY_A, "b": KEY_B, "c": KEY_C, "d": KEY_D, "e": KEY_E, "f": KEY_F, "g": KEY_G, "h": KEY_H, "i": KEY_I, "j": KEY_J, "k": KEY_K, "l": KEY_L, "m": KEY_M, "n": KEY_N, "o": KEY_O, "p": KEY_P, "q": KEY_Q, "r": KEY_R, "s": KEY_S, "t": KEY_T, "u": KEY_U, "v": KEY_V, "w": KEY_W, "x": KEY_X, "y": KEY_Y, "z": KEY_Z, "1": KEY_1, "2": KEY_2, "3": KEY_3, "4": KEY_4, "5": KEY_5, "6": KEY_6, "7": KEY_7, "8": KEY_8, "9": KEY_9, "0": KEY_0, "\t": KEY_TAB, "\n": KEY_ENTER, " ": KEY_SPACE, ".": KEY_DOT, ",": KEY_COMMA, "/": KEY_SLASH, "\\": KEY_BACKSLASH, } def _chars_to_events(chars): events = [] for char in chars: events.append(_CHAR_MAP.get(char)) return events class Device(object): """Device handle. `events` - a sequence of event capability descriptors `name` - name displayed in /proc/bus/input/devices `bustype` - bus type identifier, see linux/input.h `vendor` - vendor identifier `product` - product identifier `version` - version identifier """ def __init__(self, events, name="python-uinput", bustype=0, vendor=0, product=0, version=0, fd=None): self.__events = events self.__uinput_fd = -1 self.__name = name.encode() user_dev = _struct_uinput_user_dev(self.__name) user_dev.id.bustype = bustype user_dev.id.vendor = vendor user_dev.id.product = product user_dev.id.version = version self.__uinput_fd = fd or fdopen() for ev_spec in self.__events: ev_type, ev_code = ev_spec[:2] _libsuinput.suinput_enable_event(self.__uinput_fd, ev_type, ev_code) if len(ev_spec) > 2: absmin, absmax, absfuzz, absflat = ev_spec[2:] user_dev.absmin[ev_code] = absmin user_dev.absmax[ev_code] = absmax user_dev.absfuzz[ev_code] = absfuzz user_dev.absflat[ev_code] = absflat _libsuinput.suinput_create(self.__uinput_fd, ctypes.pointer(user_dev)) def syn(self): """Fire all emitted events. All emitted events will be placed in a certain kind of event queue. Queued events will be fired when this method is called. This makes it possible to emit "atomic" events. For example sending REL_X and REL_Y atomically requires to emit first event without syn and the second with syn:: d.emit(uinput.REL_X, 1, syn=False) d.emit(uinput.REL_Y, 1) The call above appears as a single (+1, +1) event. """ _libsuinput.suinput_syn(self.__uinput_fd) def emit(self, event, value, syn=True): """Emit event. `event` - event identifier, for example uinput.REL_X `value` - value of the event KEY/BTN : 1 (key-press) or 0 (key-release) REL : integer value of the relative change ABS : integer value in the range of min and max values `syn` - If True, Device.syn(self) will be called before return. """ ev_type, ev_code = event _libsuinput.suinput_emit(self.__uinput_fd, ev_type, ev_code, value) if syn: self.syn() def emit_click(self, event, syn=True): """Emit click event. Only KEY and BTN events are accepted, otherwise ValueError is raised. `event` - event identifier, for example uinput.KEY_A `syn` - if True, Device.syn(self) is called before returning. """ ev_type, ev_code = event if ev_type != 0x01: raise ValueError("event must be of type KEY or BTN") _libsuinput.suinput_emit_click(self.__uinput_fd, ev_code) if syn: self.syn() def emit_combo(self, events, syn=True): """Emit key combination. Only KEY and BTN events are accepted, otherwise ValueError is raised. `events` - a sequence of event identifiers, for example (uinput.KEY_LEFTCTRL, uinput.KEY_LEFTALT, uinput.KEY_DELETE). `syn` if True, Device.syn(self) is called before returning. """ ev_types, ev_codes = zip(*events) if not all([ev_type == 0x01 for ev_type in ev_types]): raise ValueError("all events must be of type KEY or BTN") arrtype = ctypes.c_uint16 * len(events) _libsuinput.suinput_emit_combo(self.__uinput_fd, arrtype(*ev_codes), len(events)) if syn: self.syn() def destroy(self): """Destroy the device. This method destroys the device file and closes the underlying file descriptor. This method must be called exactly once for each created device. Alternatively, use ``with``-statement for example as follows: >>> import uinput >>> with uinput.Device([uinput.KEY_A]) as device: ... device.emit_click(uinput.KEY_A) This ensures ``Device.destroy()`` is called at the end of the block. """ try: _libsuinput.suinput_destroy(self.__uinput_fd) finally: ## There's probably nothing more we can do. If the suinput_destroy() ## has failed once, it almost certainly will fail again. Let's just ## reset the descriptor and give up. self.__uinput_fd = -1 def __enter__(self): return self def __exit__(self, *args): self.destroy() return False ## Not handling any exceptions. def __del__(self): if self.__uinput_fd >= 0: self.destroy() pyinput-python-uinput-17c24a8/src/ev.py000066400000000000000000000371751457563612400202230ustar00rootroot00000000000000KEY_RESERVED = (0x01, 0) KEY_ESC = (0x01, 1) KEY_1 = (0x01, 2) KEY_2 = (0x01, 3) KEY_3 = (0x01, 4) KEY_4 = (0x01, 5) KEY_5 = (0x01, 6) KEY_6 = (0x01, 7) KEY_7 = (0x01, 8) KEY_8 = (0x01, 9) KEY_9 = (0x01, 10) KEY_0 = (0x01, 11) KEY_MINUS = (0x01, 12) KEY_EQUAL = (0x01, 13) KEY_BACKSPACE = (0x01, 14) KEY_TAB = (0x01, 15) KEY_Q = (0x01, 16) KEY_W = (0x01, 17) KEY_E = (0x01, 18) KEY_R = (0x01, 19) KEY_T = (0x01, 20) KEY_Y = (0x01, 21) KEY_U = (0x01, 22) KEY_I = (0x01, 23) KEY_O = (0x01, 24) KEY_P = (0x01, 25) KEY_LEFTBRACE = (0x01, 26) KEY_RIGHTBRACE = (0x01, 27) KEY_ENTER = (0x01, 28) KEY_LEFTCTRL = (0x01, 29) KEY_A = (0x01, 30) KEY_S = (0x01, 31) KEY_D = (0x01, 32) KEY_F = (0x01, 33) KEY_G = (0x01, 34) KEY_H = (0x01, 35) KEY_J = (0x01, 36) KEY_K = (0x01, 37) KEY_L = (0x01, 38) KEY_SEMICOLON = (0x01, 39) KEY_APOSTROPHE = (0x01, 40) KEY_GRAVE = (0x01, 41) KEY_LEFTSHIFT = (0x01, 42) KEY_BACKSLASH = (0x01, 43) KEY_Z = (0x01, 44) KEY_X = (0x01, 45) KEY_C = (0x01, 46) KEY_V = (0x01, 47) KEY_B = (0x01, 48) KEY_N = (0x01, 49) KEY_M = (0x01, 50) KEY_COMMA = (0x01, 51) KEY_DOT = (0x01, 52) KEY_SLASH = (0x01, 53) KEY_RIGHTSHIFT = (0x01, 54) KEY_KPASTERISK = (0x01, 55) KEY_LEFTALT = (0x01, 56) KEY_SPACE = (0x01, 57) KEY_CAPSLOCK = (0x01, 58) KEY_F1 = (0x01, 59) KEY_F2 = (0x01, 60) KEY_F3 = (0x01, 61) KEY_F4 = (0x01, 62) KEY_F5 = (0x01, 63) KEY_F6 = (0x01, 64) KEY_F7 = (0x01, 65) KEY_F8 = (0x01, 66) KEY_F9 = (0x01, 67) KEY_F10 = (0x01, 68) KEY_NUMLOCK = (0x01, 69) KEY_SCROLLLOCK = (0x01, 70) KEY_KP7 = (0x01, 71) KEY_KP8 = (0x01, 72) KEY_KP9 = (0x01, 73) KEY_KPMINUS = (0x01, 74) KEY_KP4 = (0x01, 75) KEY_KP5 = (0x01, 76) KEY_KP6 = (0x01, 77) KEY_KPPLUS = (0x01, 78) KEY_KP1 = (0x01, 79) KEY_KP2 = (0x01, 80) KEY_KP3 = (0x01, 81) KEY_KP0 = (0x01, 82) KEY_KPDOT = (0x01, 83) KEY_ZENKAKUHANKAKU = (0x01, 85) KEY_102ND = (0x01, 86) KEY_F11 = (0x01, 87) KEY_F12 = (0x01, 88) KEY_RO = (0x01, 89) KEY_KATAKANA = (0x01, 90) KEY_HIRAGANA = (0x01, 91) KEY_HENKAN = (0x01, 92) KEY_KATAKANAHIRAGANA = (0x01, 93) KEY_MUHENKAN = (0x01, 94) KEY_KPJPCOMMA = (0x01, 95) KEY_KPENTER = (0x01, 96) KEY_RIGHTCTRL = (0x01, 97) KEY_KPSLASH = (0x01, 98) KEY_SYSRQ = (0x01, 99) KEY_RIGHTALT = (0x01, 100) KEY_LINEFEED = (0x01, 101) KEY_HOME = (0x01, 102) KEY_UP = (0x01, 103) KEY_PAGEUP = (0x01, 104) KEY_LEFT = (0x01, 105) KEY_RIGHT = (0x01, 106) KEY_END = (0x01, 107) KEY_DOWN = (0x01, 108) KEY_PAGEDOWN = (0x01, 109) KEY_INSERT = (0x01, 110) KEY_DELETE = (0x01, 111) KEY_MACRO = (0x01, 112) KEY_MUTE = (0x01, 113) KEY_VOLUMEDOWN = (0x01, 114) KEY_VOLUMEUP = (0x01, 115) KEY_POWER = (0x01, 116) KEY_KPEQUAL = (0x01, 117) KEY_KPPLUSMINUS = (0x01, 118) KEY_PAUSE = (0x01, 119) KEY_SCALE = (0x01, 120) KEY_KPCOMMA = (0x01, 121) KEY_HANGEUL = (0x01, 122) KEY_HANGUEL = (0x01, 122) KEY_HANJA = (0x01, 123) KEY_YEN = (0x01, 124) KEY_LEFTMETA = (0x01, 125) KEY_RIGHTMETA = (0x01, 126) KEY_COMPOSE = (0x01, 127) KEY_STOP = (0x01, 128) KEY_AGAIN = (0x01, 129) KEY_PROPS = (0x01, 130) KEY_UNDO = (0x01, 131) KEY_FRONT = (0x01, 132) KEY_COPY = (0x01, 133) KEY_OPEN = (0x01, 134) KEY_PASTE = (0x01, 135) KEY_FIND = (0x01, 136) KEY_CUT = (0x01, 137) KEY_HELP = (0x01, 138) KEY_MENU = (0x01, 139) KEY_CALC = (0x01, 140) KEY_SETUP = (0x01, 141) KEY_SLEEP = (0x01, 142) KEY_WAKEUP = (0x01, 143) KEY_FILE = (0x01, 144) KEY_SENDFILE = (0x01, 145) KEY_DELETEFILE = (0x01, 146) KEY_XFER = (0x01, 147) KEY_PROG1 = (0x01, 148) KEY_PROG2 = (0x01, 149) KEY_WWW = (0x01, 150) KEY_MSDOS = (0x01, 151) KEY_COFFEE = (0x01, 152) KEY_SCREENLOCK = (0x01, 152) KEY_ROTATE_DISPLAY = (0x01, 153) KEY_DIRECTION = (0x01, 153) KEY_CYCLEWINDOWS = (0x01, 154) KEY_MAIL = (0x01, 155) KEY_BOOKMARKS = (0x01, 156) KEY_COMPUTER = (0x01, 157) KEY_BACK = (0x01, 158) KEY_FORWARD = (0x01, 159) KEY_CLOSECD = (0x01, 160) KEY_EJECTCD = (0x01, 161) KEY_EJECTCLOSECD = (0x01, 162) KEY_NEXTSONG = (0x01, 163) KEY_PLAYPAUSE = (0x01, 164) KEY_PREVIOUSSONG = (0x01, 165) KEY_STOPCD = (0x01, 166) KEY_RECORD = (0x01, 167) KEY_REWIND = (0x01, 168) KEY_PHONE = (0x01, 169) KEY_ISO = (0x01, 170) KEY_CONFIG = (0x01, 171) KEY_HOMEPAGE = (0x01, 172) KEY_REFRESH = (0x01, 173) KEY_EXIT = (0x01, 174) KEY_MOVE = (0x01, 175) KEY_EDIT = (0x01, 176) KEY_SCROLLUP = (0x01, 177) KEY_SCROLLDOWN = (0x01, 178) KEY_KPLEFTPAREN = (0x01, 179) KEY_KPRIGHTPAREN = (0x01, 180) KEY_NEW = (0x01, 181) KEY_REDO = (0x01, 182) KEY_F13 = (0x01, 183) KEY_F14 = (0x01, 184) KEY_F15 = (0x01, 185) KEY_F16 = (0x01, 186) KEY_F17 = (0x01, 187) KEY_F18 = (0x01, 188) KEY_F19 = (0x01, 189) KEY_F20 = (0x01, 190) KEY_F21 = (0x01, 191) KEY_F22 = (0x01, 192) KEY_F23 = (0x01, 193) KEY_F24 = (0x01, 194) KEY_PLAYCD = (0x01, 200) KEY_PAUSECD = (0x01, 201) KEY_PROG3 = (0x01, 202) KEY_PROG4 = (0x01, 203) KEY_DASHBOARD = (0x01, 204) KEY_SUSPEND = (0x01, 205) KEY_CLOSE = (0x01, 206) KEY_PLAY = (0x01, 207) KEY_FASTFORWARD = (0x01, 208) KEY_BASSBOOST = (0x01, 209) KEY_PRINT = (0x01, 210) KEY_HP = (0x01, 211) KEY_CAMERA = (0x01, 212) KEY_SOUND = (0x01, 213) KEY_QUESTION = (0x01, 214) KEY_EMAIL = (0x01, 215) KEY_CHAT = (0x01, 216) KEY_SEARCH = (0x01, 217) KEY_CONNECT = (0x01, 218) KEY_FINANCE = (0x01, 219) KEY_SPORT = (0x01, 220) KEY_SHOP = (0x01, 221) KEY_ALTERASE = (0x01, 222) KEY_CANCEL = (0x01, 223) KEY_BRIGHTNESSDOWN = (0x01, 224) KEY_BRIGHTNESSUP = (0x01, 225) KEY_MEDIA = (0x01, 226) KEY_SWITCHVIDEOMODE = (0x01, 227) KEY_KBDILLUMTOGGLE = (0x01, 228) KEY_KBDILLUMDOWN = (0x01, 229) KEY_KBDILLUMUP = (0x01, 230) KEY_SEND = (0x01, 231) KEY_REPLY = (0x01, 232) KEY_FORWARDMAIL = (0x01, 233) KEY_SAVE = (0x01, 234) KEY_DOCUMENTS = (0x01, 235) KEY_BATTERY = (0x01, 236) KEY_BLUETOOTH = (0x01, 237) KEY_WLAN = (0x01, 238) KEY_UWB = (0x01, 239) KEY_UNKNOWN = (0x01, 240) KEY_VIDEO_NEXT = (0x01, 241) KEY_VIDEO_PREV = (0x01, 242) KEY_BRIGHTNESS_CYCLE = (0x01, 243) KEY_BRIGHTNESS_AUTO = (0x01, 244) KEY_BRIGHTNESS_ZERO = (0x01, 244) KEY_DISPLAY_OFF = (0x01, 245) KEY_WWAN = (0x01, 246) KEY_WIMAX = (0x01, 246) KEY_RFKILL = (0x01, 247) KEY_MICMUTE = (0x01, 248) KEY_OK = (0x01, 0x160) KEY_SELECT = (0x01, 0x161) KEY_GOTO = (0x01, 0x162) KEY_CLEAR = (0x01, 0x163) KEY_POWER2 = (0x01, 0x164) KEY_OPTION = (0x01, 0x165) KEY_INFO = (0x01, 0x166) KEY_TIME = (0x01, 0x167) KEY_VENDOR = (0x01, 0x168) KEY_ARCHIVE = (0x01, 0x169) KEY_PROGRAM = (0x01, 0x16a) KEY_CHANNEL = (0x01, 0x16b) KEY_FAVORITES = (0x01, 0x16c) KEY_EPG = (0x01, 0x16d) KEY_PVR = (0x01, 0x16e) KEY_MHP = (0x01, 0x16f) KEY_LANGUAGE = (0x01, 0x170) KEY_TITLE = (0x01, 0x171) KEY_SUBTITLE = (0x01, 0x172) KEY_ANGLE = (0x01, 0x173) KEY_ZOOM = (0x01, 0x174) KEY_MODE = (0x01, 0x175) KEY_KEYBOARD = (0x01, 0x176) KEY_SCREEN = (0x01, 0x177) KEY_PC = (0x01, 0x178) KEY_TV = (0x01, 0x179) KEY_TV2 = (0x01, 0x17a) KEY_VCR = (0x01, 0x17b) KEY_VCR2 = (0x01, 0x17c) KEY_SAT = (0x01, 0x17d) KEY_SAT2 = (0x01, 0x17e) KEY_CD = (0x01, 0x17f) KEY_TAPE = (0x01, 0x180) KEY_RADIO = (0x01, 0x181) KEY_TUNER = (0x01, 0x182) KEY_PLAYER = (0x01, 0x183) KEY_TEXT = (0x01, 0x184) KEY_DVD = (0x01, 0x185) KEY_AUX = (0x01, 0x186) KEY_MP3 = (0x01, 0x187) KEY_AUDIO = (0x01, 0x188) KEY_VIDEO = (0x01, 0x189) KEY_DIRECTORY = (0x01, 0x18a) KEY_LIST = (0x01, 0x18b) KEY_MEMO = (0x01, 0x18c) KEY_CALENDAR = (0x01, 0x18d) KEY_RED = (0x01, 0x18e) KEY_GREEN = (0x01, 0x18f) KEY_YELLOW = (0x01, 0x190) KEY_BLUE = (0x01, 0x191) KEY_CHANNELUP = (0x01, 0x192) KEY_CHANNELDOWN = (0x01, 0x193) KEY_FIRST = (0x01, 0x194) KEY_LAST = (0x01, 0x195) KEY_AB = (0x01, 0x196) KEY_NEXT = (0x01, 0x197) KEY_RESTART = (0x01, 0x198) KEY_SLOW = (0x01, 0x199) KEY_SHUFFLE = (0x01, 0x19a) KEY_BREAK = (0x01, 0x19b) KEY_PREVIOUS = (0x01, 0x19c) KEY_DIGITS = (0x01, 0x19d) KEY_TEEN = (0x01, 0x19e) KEY_TWEN = (0x01, 0x19f) KEY_VIDEOPHONE = (0x01, 0x1a0) KEY_GAMES = (0x01, 0x1a1) KEY_ZOOMIN = (0x01, 0x1a2) KEY_ZOOMOUT = (0x01, 0x1a3) KEY_ZOOMRESET = (0x01, 0x1a4) KEY_WORDPROCESSOR = (0x01, 0x1a5) KEY_EDITOR = (0x01, 0x1a6) KEY_SPREADSHEET = (0x01, 0x1a7) KEY_GRAPHICSEDITOR = (0x01, 0x1a8) KEY_PRESENTATION = (0x01, 0x1a9) KEY_DATABASE = (0x01, 0x1aa) KEY_NEWS = (0x01, 0x1ab) KEY_VOICEMAIL = (0x01, 0x1ac) KEY_ADDRESSBOOK = (0x01, 0x1ad) KEY_MESSENGER = (0x01, 0x1ae) KEY_DISPLAYTOGGLE = (0x01, 0x1af) KEY_BRIGHTNESS_TOGGLE = (0x01, 0x1af) KEY_SPELLCHECK = (0x01, 0x1b0) KEY_LOGOFF = (0x01, 0x1b1) KEY_DOLLAR = (0x01, 0x1b2) KEY_EURO = (0x01, 0x1b3) KEY_FRAMEBACK = (0x01, 0x1b4) KEY_FRAMEFORWARD = (0x01, 0x1b5) KEY_CONTEXT_MENU = (0x01, 0x1b6) KEY_MEDIA_REPEAT = (0x01, 0x1b7) KEY_10CHANNELSUP = (0x01, 0x1b8) KEY_10CHANNELSDOWN = (0x01, 0x1b9) KEY_IMAGES = (0x01, 0x1ba) KEY_DEL_EOL = (0x01, 0x1c0) KEY_DEL_EOS = (0x01, 0x1c1) KEY_INS_LINE = (0x01, 0x1c2) KEY_DEL_LINE = (0x01, 0x1c3) KEY_FN = (0x01, 0x1d0) KEY_FN_ESC = (0x01, 0x1d1) KEY_FN_F1 = (0x01, 0x1d2) KEY_FN_F2 = (0x01, 0x1d3) KEY_FN_F3 = (0x01, 0x1d4) KEY_FN_F4 = (0x01, 0x1d5) KEY_FN_F5 = (0x01, 0x1d6) KEY_FN_F6 = (0x01, 0x1d7) KEY_FN_F7 = (0x01, 0x1d8) KEY_FN_F8 = (0x01, 0x1d9) KEY_FN_F9 = (0x01, 0x1da) KEY_FN_F10 = (0x01, 0x1db) KEY_FN_F11 = (0x01, 0x1dc) KEY_FN_F12 = (0x01, 0x1dd) KEY_FN_1 = (0x01, 0x1de) KEY_FN_2 = (0x01, 0x1df) KEY_FN_D = (0x01, 0x1e0) KEY_FN_E = (0x01, 0x1e1) KEY_FN_F = (0x01, 0x1e2) KEY_FN_S = (0x01, 0x1e3) KEY_FN_B = (0x01, 0x1e4) KEY_BRL_DOT1 = (0x01, 0x1f1) KEY_BRL_DOT2 = (0x01, 0x1f2) KEY_BRL_DOT3 = (0x01, 0x1f3) KEY_BRL_DOT4 = (0x01, 0x1f4) KEY_BRL_DOT5 = (0x01, 0x1f5) KEY_BRL_DOT6 = (0x01, 0x1f6) KEY_BRL_DOT7 = (0x01, 0x1f7) KEY_BRL_DOT8 = (0x01, 0x1f8) KEY_BRL_DOT9 = (0x01, 0x1f9) KEY_BRL_DOT10 = (0x01, 0x1fa) KEY_NUMERIC_0 = (0x01, 0x200) KEY_NUMERIC_1 = (0x01, 0x201) KEY_NUMERIC_2 = (0x01, 0x202) KEY_NUMERIC_3 = (0x01, 0x203) KEY_NUMERIC_4 = (0x01, 0x204) KEY_NUMERIC_5 = (0x01, 0x205) KEY_NUMERIC_6 = (0x01, 0x206) KEY_NUMERIC_7 = (0x01, 0x207) KEY_NUMERIC_8 = (0x01, 0x208) KEY_NUMERIC_9 = (0x01, 0x209) KEY_NUMERIC_STAR = (0x01, 0x20a) KEY_NUMERIC_POUND = (0x01, 0x20b) KEY_NUMERIC_A = (0x01, 0x20c) KEY_NUMERIC_B = (0x01, 0x20d) KEY_NUMERIC_C = (0x01, 0x20e) KEY_NUMERIC_D = (0x01, 0x20f) KEY_CAMERA_FOCUS = (0x01, 0x210) KEY_WPS_BUTTON = (0x01, 0x211) KEY_TOUCHPAD_TOGGLE = (0x01, 0x212) KEY_TOUCHPAD_ON = (0x01, 0x213) KEY_TOUCHPAD_OFF = (0x01, 0x214) KEY_CAMERA_ZOOMIN = (0x01, 0x215) KEY_CAMERA_ZOOMOUT = (0x01, 0x216) KEY_CAMERA_UP = (0x01, 0x217) KEY_CAMERA_DOWN = (0x01, 0x218) KEY_CAMERA_LEFT = (0x01, 0x219) KEY_CAMERA_RIGHT = (0x01, 0x21a) KEY_ATTENDANT_ON = (0x01, 0x21b) KEY_ATTENDANT_OFF = (0x01, 0x21c) KEY_ATTENDANT_TOGGLE = (0x01, 0x21d) KEY_LIGHTS_TOGGLE = (0x01, 0x21e) KEY_ALS_TOGGLE = (0x01, 0x230) KEY_BUTTONCONFIG = (0x01, 0x240) KEY_TASKMANAGER = (0x01, 0x241) KEY_JOURNAL = (0x01, 0x242) KEY_CONTROLPANEL = (0x01, 0x243) KEY_APPSELECT = (0x01, 0x244) KEY_SCREENSAVER = (0x01, 0x245) KEY_VOICECOMMAND = (0x01, 0x246) KEY_BRIGHTNESS_MIN = (0x01, 0x250) KEY_BRIGHTNESS_MAX = (0x01, 0x251) KEY_KBDINPUTASSIST_PREV = (0x01, 0x260) KEY_KBDINPUTASSIST_NEXT = (0x01, 0x261) KEY_KBDINPUTASSIST_PREVGROUP = (0x01, 0x262) KEY_KBDINPUTASSIST_NEXTGROUP = (0x01, 0x263) KEY_KBDINPUTASSIST_ACCEPT = (0x01, 0x264) KEY_KBDINPUTASSIST_CANCEL = (0x01, 0x265) KEY_MIN_INTERESTING = (0x01, 113) KEY_MAX = (0x01, 0x2ff) BTN_MISC = (0x01, 0x100) BTN_0 = (0x01, 0x100) BTN_1 = (0x01, 0x101) BTN_2 = (0x01, 0x102) BTN_3 = (0x01, 0x103) BTN_4 = (0x01, 0x104) BTN_5 = (0x01, 0x105) BTN_6 = (0x01, 0x106) BTN_7 = (0x01, 0x107) BTN_8 = (0x01, 0x108) BTN_9 = (0x01, 0x109) BTN_MOUSE = (0x01, 0x110) BTN_LEFT = (0x01, 0x110) BTN_RIGHT = (0x01, 0x111) BTN_MIDDLE = (0x01, 0x112) BTN_SIDE = (0x01, 0x113) BTN_EXTRA = (0x01, 0x114) BTN_FORWARD = (0x01, 0x115) BTN_BACK = (0x01, 0x116) BTN_TASK = (0x01, 0x117) BTN_JOYSTICK = (0x01, 0x120) BTN_TRIGGER = (0x01, 0x120) BTN_THUMB = (0x01, 0x121) BTN_THUMB2 = (0x01, 0x122) BTN_TOP = (0x01, 0x123) BTN_TOP2 = (0x01, 0x124) BTN_PINKIE = (0x01, 0x125) BTN_BASE = (0x01, 0x126) BTN_BASE2 = (0x01, 0x127) BTN_BASE3 = (0x01, 0x128) BTN_BASE4 = (0x01, 0x129) BTN_BASE5 = (0x01, 0x12a) BTN_BASE6 = (0x01, 0x12b) BTN_DEAD = (0x01, 0x12f) BTN_GAMEPAD = (0x01, 0x130) BTN_SOUTH = (0x01, 0x130) BTN_A = (0x01, 0x130) BTN_EAST = (0x01, 0x131) BTN_B = (0x01, 0x131) BTN_C = (0x01, 0x132) BTN_NORTH = (0x01, 0x133) BTN_X = (0x01, 0x133) BTN_WEST = (0x01, 0x134) BTN_Y = (0x01, 0x134) BTN_Z = (0x01, 0x135) BTN_TL = (0x01, 0x136) BTN_TR = (0x01, 0x137) BTN_TL2 = (0x01, 0x138) BTN_TR2 = (0x01, 0x139) BTN_SELECT = (0x01, 0x13a) BTN_START = (0x01, 0x13b) BTN_MODE = (0x01, 0x13c) BTN_THUMBL = (0x01, 0x13d) BTN_THUMBR = (0x01, 0x13e) BTN_DIGI = (0x01, 0x140) BTN_TOOL_PEN = (0x01, 0x140) BTN_TOOL_RUBBER = (0x01, 0x141) BTN_TOOL_BRUSH = (0x01, 0x142) BTN_TOOL_PENCIL = (0x01, 0x143) BTN_TOOL_AIRBRUSH = (0x01, 0x144) BTN_TOOL_FINGER = (0x01, 0x145) BTN_TOOL_MOUSE = (0x01, 0x146) BTN_TOOL_LENS = (0x01, 0x147) BTN_TOOL_QUINTTAP = (0x01, 0x148) BTN_TOUCH = (0x01, 0x14a) BTN_STYLUS = (0x01, 0x14b) BTN_STYLUS2 = (0x01, 0x14c) BTN_TOOL_DOUBLETAP = (0x01, 0x14d) BTN_TOOL_TRIPLETAP = (0x01, 0x14e) BTN_TOOL_QUADTAP = (0x01, 0x14f) BTN_WHEEL = (0x01, 0x150) BTN_GEAR_DOWN = (0x01, 0x150) BTN_GEAR_UP = (0x01, 0x151) BTN_DPAD_UP = (0x01, 0x220) BTN_DPAD_DOWN = (0x01, 0x221) BTN_DPAD_LEFT = (0x01, 0x222) BTN_DPAD_RIGHT = (0x01, 0x223) BTN_TRIGGER_HAPPY = (0x01, 0x2c0) BTN_TRIGGER_HAPPY1 = (0x01, 0x2c0) BTN_TRIGGER_HAPPY2 = (0x01, 0x2c1) BTN_TRIGGER_HAPPY3 = (0x01, 0x2c2) BTN_TRIGGER_HAPPY4 = (0x01, 0x2c3) BTN_TRIGGER_HAPPY5 = (0x01, 0x2c4) BTN_TRIGGER_HAPPY6 = (0x01, 0x2c5) BTN_TRIGGER_HAPPY7 = (0x01, 0x2c6) BTN_TRIGGER_HAPPY8 = (0x01, 0x2c7) BTN_TRIGGER_HAPPY9 = (0x01, 0x2c8) BTN_TRIGGER_HAPPY10 = (0x01, 0x2c9) BTN_TRIGGER_HAPPY11 = (0x01, 0x2ca) BTN_TRIGGER_HAPPY12 = (0x01, 0x2cb) BTN_TRIGGER_HAPPY13 = (0x01, 0x2cc) BTN_TRIGGER_HAPPY14 = (0x01, 0x2cd) BTN_TRIGGER_HAPPY15 = (0x01, 0x2ce) BTN_TRIGGER_HAPPY16 = (0x01, 0x2cf) BTN_TRIGGER_HAPPY17 = (0x01, 0x2d0) BTN_TRIGGER_HAPPY18 = (0x01, 0x2d1) BTN_TRIGGER_HAPPY19 = (0x01, 0x2d2) BTN_TRIGGER_HAPPY20 = (0x01, 0x2d3) BTN_TRIGGER_HAPPY21 = (0x01, 0x2d4) BTN_TRIGGER_HAPPY22 = (0x01, 0x2d5) BTN_TRIGGER_HAPPY23 = (0x01, 0x2d6) BTN_TRIGGER_HAPPY24 = (0x01, 0x2d7) BTN_TRIGGER_HAPPY25 = (0x01, 0x2d8) BTN_TRIGGER_HAPPY26 = (0x01, 0x2d9) BTN_TRIGGER_HAPPY27 = (0x01, 0x2da) BTN_TRIGGER_HAPPY28 = (0x01, 0x2db) BTN_TRIGGER_HAPPY29 = (0x01, 0x2dc) BTN_TRIGGER_HAPPY30 = (0x01, 0x2dd) BTN_TRIGGER_HAPPY31 = (0x01, 0x2de) BTN_TRIGGER_HAPPY32 = (0x01, 0x2df) BTN_TRIGGER_HAPPY33 = (0x01, 0x2e0) BTN_TRIGGER_HAPPY34 = (0x01, 0x2e1) BTN_TRIGGER_HAPPY35 = (0x01, 0x2e2) BTN_TRIGGER_HAPPY36 = (0x01, 0x2e3) BTN_TRIGGER_HAPPY37 = (0x01, 0x2e4) BTN_TRIGGER_HAPPY38 = (0x01, 0x2e5) BTN_TRIGGER_HAPPY39 = (0x01, 0x2e6) BTN_TRIGGER_HAPPY40 = (0x01, 0x2e7) REL_X = (0x02, 0x00) REL_Y = (0x02, 0x01) REL_Z = (0x02, 0x02) REL_RX = (0x02, 0x03) REL_RY = (0x02, 0x04) REL_RZ = (0x02, 0x05) REL_HWHEEL = (0x02, 0x06) REL_DIAL = (0x02, 0x07) REL_WHEEL = (0x02, 0x08) REL_MISC = (0x02, 0x09) REL_WHEEL_HI_RES = (0x02, 0x0b) REL_HWHEEL_HI_RES = (0x02, 0x0c) REL_MAX = (0x02, 0x0f) ABS_X = (0x03, 0x00) ABS_Y = (0x03, 0x01) ABS_Z = (0x03, 0x02) ABS_RX = (0x03, 0x03) ABS_RY = (0x03, 0x04) ABS_RZ = (0x03, 0x05) ABS_THROTTLE = (0x03, 0x06) ABS_RUDDER = (0x03, 0x07) ABS_WHEEL = (0x03, 0x08) ABS_GAS = (0x03, 0x09) ABS_BRAKE = (0x03, 0x0a) ABS_HAT0X = (0x03, 0x10) ABS_HAT0Y = (0x03, 0x11) ABS_HAT1X = (0x03, 0x12) ABS_HAT1Y = (0x03, 0x13) ABS_HAT2X = (0x03, 0x14) ABS_HAT2Y = (0x03, 0x15) ABS_HAT3X = (0x03, 0x16) ABS_HAT3Y = (0x03, 0x17) ABS_PRESSURE = (0x03, 0x18) ABS_DISTANCE = (0x03, 0x19) ABS_TILT_X = (0x03, 0x1a) ABS_TILT_Y = (0x03, 0x1b) ABS_TOOL_WIDTH = (0x03, 0x1c) ABS_VOLUME = (0x03, 0x20) ABS_MISC = (0x03, 0x28) ABS_MT_SLOT = (0x03, 0x2f) ABS_MT_TOUCH_MAJOR = (0x03, 0x30) ABS_MT_TOUCH_MINOR = (0x03, 0x31) ABS_MT_WIDTH_MAJOR = (0x03, 0x32) ABS_MT_WIDTH_MINOR = (0x03, 0x33) ABS_MT_ORIENTATION = (0x03, 0x34) ABS_MT_POSITION_X = (0x03, 0x35) ABS_MT_POSITION_Y = (0x03, 0x36) ABS_MT_TOOL_TYPE = (0x03, 0x37) ABS_MT_BLOB_ID = (0x03, 0x38) ABS_MT_TRACKING_ID = (0x03, 0x39) ABS_MT_PRESSURE = (0x03, 0x3a) ABS_MT_DISTANCE = (0x03, 0x3b) ABS_MT_TOOL_X = (0x03, 0x3c) ABS_MT_TOOL_Y = (0x03, 0x3d) ABS_MAX = (0x03, 0x3f) pyinput-python-uinput-17c24a8/tests/000077500000000000000000000000001457563612400175755ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/tests/test_uinput.py000066400000000000000000000011001457563612400225220ustar00rootroot00000000000000import unittest import uinput MOUSE_KEYS = [uinput.REL_X, uinput.REL_Y, uinput.BTN_LEFT, uinput.BTN_RIGHT] class DeviceTest(unittest.TestCase): def test_device_empty(self): with uinput.Device([]) as device: pass def test_keyboard_click(self): test_key = uinput.KEY_LEFTCTRL with uinput.Device([test_key]) as device: device.emit_click(test_key) def test_mouse_move(self): with uinput.Device(MOUSE_KEYS) as device: device.emit(uinput.REL_X, 1) if __name__ == "__main__": unittest.main() pyinput-python-uinput-17c24a8/udev-rules/000077500000000000000000000000001457563612400205265ustar00rootroot00000000000000pyinput-python-uinput-17c24a8/udev-rules/40-uinput.rules000066400000000000000000000001011457563612400233370ustar00rootroot00000000000000SUBSYSTEM=="misc", KERNEL=="uinput", MODE="0660", GROUP="uinput"