pax_global_header00006660000000000000000000000064130532566720014523gustar00rootroot0000000000000052 comment=40e036bf1e5d5a6c5671d93f473a261a5e50f6b4 input-1.3/000077500000000000000000000000001305325667200125255ustar00rootroot00000000000000input-1.3/.gitignore000066400000000000000000000002201305325667200145070ustar00rootroot00000000000000Make.config BTN.h BUS.h EV.h KEY.h REL.h ABS.h LED.h MSC.h REP.h SND.h SW.h lircd.conf input-events input-kbd input-recv input-send lsinput *.o input-1.3/.tito/000077500000000000000000000000001305325667200135625ustar00rootroot00000000000000input-1.3/.tito/VERSION.template000066400000000000000000000000111305325667200164340ustar00rootroot00000000000000$version input-1.3/.tito/packages/000077500000000000000000000000001305325667200153405ustar00rootroot00000000000000input-1.3/.tito/packages/.readme000066400000000000000000000002371305325667200166000ustar00rootroot00000000000000the .tito/packages directory contains metadata files named after their packages. Each file has the latest tagged version and the project's relative directory. input-1.3/.tito/packages/input000066400000000000000000000000111305325667200164120ustar00rootroot000000000000001.3-1 ./ input-1.3/.tito/tito.props000066400000000000000000000003511305325667200156250ustar00rootroot00000000000000[buildconfig] builder = tito.builder.Builder tagger = tito.tagger.VersionTagger changelog_do_not_remove_cherrypick = 0 changelog_format = %s (%ae) [version_template] destination_file = VERSION template_file = .tito/VERSION.template input-1.3/COPYING000066400000000000000000000430771305325667200135730ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. input-1.3/GNUmakefile000066400000000000000000000024271305325667200146040ustar00rootroot00000000000000# config -include Make.config include mk/Variables.mk # add our flags + libs CFLAGS += -DVERSION='"$(VERSION)"' # build TARGETS := input-events input-kbd input-send input-recv TARGETS += lsinput emulate-key lircd.conf HEADERS := EV.h REL.h ABS.h MSC.h LED.h SND.h REP.h KEY.h BTN.h BUS.h SW.h # default target all: build ######################################################################## # rules build: $(TARGETS) $(HEADERS): name.sh sh name.sh $* > $@ lircd.conf: lirc.sh sh lirc.sh > $@ lsinput: lsinput.o input.o input-events: input-events.o input.o input-kbd: input-kbd.o input.o input-send: input-send.o input.o tcp.o input-recv: input-recv.o input.o tcp.o emulate-key: emulate-key.o input.o input.o: input.c $(HEADERS) install: build $(INSTALL_DIR) $(bindir) $(mandir)/man8 $(INSTALL_BINARY) lsinput input-events input-kbd input-send input-recv $(bindir) $(INSTALL_DATA) lsinput.man $(mandir)/man8/lsinput.8 $(INSTALL_DATA) input-kbd.man $(mandir)/man8/input-kbd.8 $(INSTALL_DATA) input-events.man $(mandir)/man8/input-events.8 clean: -rm -f *.o $(depfiles) realclean distclean: clean -rm -f Make.config -rm -f $(TARGETS) $(HEADERS) *~ xpm/*~ *.bak ############################################# include mk/Compile.mk include mk/Maintainer.mk -include $(depfiles) input-1.3/INSTALL000066400000000000000000000033511305325667200135600ustar00rootroot00000000000000 howto compile and install this package ====================================== really short install instructions --------------------------------- $ make $ su -c "make install" the more detailed version ------------------------- Make sure you use GNU make. The file name "GNUmakefile" isn't a joke, this package really requires GNU make. As first step make will do some config checks on your system and write the results to Make.config. If you want to have a look at Make.config before the actual build starts you can run this step separately using "make config". The Makefiles use the usual GNU-ish Makefile conventions for variable names and default values, i.e. prefix=/usr/local, ... The values for some frequently adapted variables are initialized from the enviroment. Thus you can change the defaults simply by setting environment variables: $ prefix="/usr" $ CFLAGS="-O3 -mcpu=i686" $ export prefix CFLAGS Almost any variable can be overridden on the make command line. It is often used this way to install into some buildroot for packaging ... $ su -c "make DESTDIR=/tmp/buildroot install" ... but it works for most other variables equally well. There are some exceptions through, it usually does _not_ work for CFLAGS for example. Try "make verbose=yes" if you want to see the complete command lines executed by make instead of the short messages (for trouble shooting, because you like this way, for whatever reason ...). This also makes the config checks performed by "make config" more verbose. If you don't trust my Makefiles you can run "make -n install" to see what "make install" would do on your system. It will produce human-readable output (unlike automake ...). Have fun, Gerd -- Gerd Hoffmann input-1.3/README000066400000000000000000000033741305325667200134140ustar00rootroot00000000000000 This is a small collection of input layer utilities. I wrote them mainly for testing and debugging, but maybe others find them useful too :-) lsinput ======= probe and list all devices input-event =========== listen for events and print them. Expects a device number as argument (0 == /dev/input/event0, ...). -t set timeout, quits after seconds without input. default is 10 -g grab device using EVIOCGRAB, i.e. get exclusive access to the device input-kbd ========= read/write keyboard maps (scancode => linux keycode). Also expects a device number as argument. If the input device supports maps, it will print them to stdout. Looks like this (AT Keyboard): 0x0001 = 67 # KEY_F9 0x0002 = 65 # KEY_F7 0x0003 = 63 # KEY_F5 0x0004 = 61 # KEY_F3 [ ... ] If the device doesn't support maps the utility just prints the keys and/or buttons supported by the device (my mouse): bits: BTN_LEFT bits: BTN_RIGHT bits: BTN_MIDDLE If you pass a map file via -f switch the utility will parse it and reconfigure the device. Syntax is identical to the maps printed out, i.e. you can dump the current map to some file, edit it and then apply the changes. The key names are also accepted, i.e. both this ... 0x0001 = 67 ... and this ... 0x0001 = KEY_F9 ... works. input-send ========== small daemon which reads from a input device and sends it over the network to everyone who connects. Listens on tcp port 1234. input-recv ========== the receiving end for the send utility. Connects to localhost:1234 right now and prints stuff to stderr. Plan is to put events into /dev/input/uinput some day which basically gives you a remote input device. Have fun, Gerd -- Gerd Hoffmann input-1.3/VERSION000066400000000000000000000000041305325667200135670ustar00rootroot000000000000001.3 input-1.3/emulate-key.c000066400000000000000000000061131305325667200151140ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include "input.h" /* ------------------------------------------------------------------ */ static int usage(char *prog, int error) { fprintf(error ? stderr : stdout, "usage: %s -h this text\n" "usage: %s -l list keys\n" "usage: %s [ -v ] send key\n", prog, prog, prog); exit(error); } static int send_key(int fd, int key, bool down) { struct input_event ev; memset(&ev, 0, sizeof(ev)); ev.type = EV_KEY; ev.code = key; ev.value = down ? 0 : 1; write(fd, &ev, sizeof(ev)); memset(&ev, 0, sizeof(ev)); ev.type = EV_SYN; write(fd, &ev, sizeof(ev)); return 0; } int main(int argc, char *argv[]) { static struct uinput_user_dev uidev = { .name = "emulate-key", }; int verbose = 0; int c, key, fd; char *name; for (;;) { if (-1 == (c = getopt(argc, argv, "hvl"))) break; switch (c) { case 'v': verbose = 1; break; case 'l': for (key = 0; key < KEY_MAX; key++) { name = ev_type_name(EV_KEY, key); if (!name) continue; if (strcmp(name, "???") == 0) continue; printf("%s%s", key ? ", " : "", name); } printf("\n"); exit(0); case 'h': usage(argv[0],0); default: usage(argv[0],1); } } if (optind == argc) { fprintf(stderr, "%s: no keyname given\n", argv[0]); exit(1); } for (key = 0; key < KEY_MAX; key++) { if (strcmp(ev_type_name(EV_KEY, key), argv[optind]) == 0) { break; } } if (key == KEY_MAX) { fprintf(stderr, "%s: key '%s' not found\n", argv[0], argv[optind]); exit(1); } if (verbose) { printf("Sending '%s' (%d) key (down+up).\n", argv[optind], key); } fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); if (fd < 0) { perror("open /dev/uinput"); exit(1); } ioctl(fd, UI_SET_EVBIT, EV_SYN); ioctl(fd, UI_SET_EVBIT, EV_KEY); ioctl(fd, UI_SET_KEYBIT, key); write(fd, &uidev, sizeof(uidev)); ioctl(fd, UI_DEV_CREATE); usleep(100000); send_key(fd, key, true); usleep(100000); send_key(fd, key, false); usleep(100000); ioctl(fd, UI_DEV_DESTROY); return 0; } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.3/input-events.c000066400000000000000000000043431305325667200153360ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include "input.h" /* ------------------------------------------------------------------ */ static void show_events(int nr, int timeout, int grab) { struct input_event event; struct timeval tv; int fd, quit; fd_set set; fd = device_open(nr,1); if (-1 == fd) return; device_info(nr, fd, true); if (grab) { usleep(100000); // let kernel process return key-up event if (-1 == ioctl(fd,EVIOCGRAB,1)) { perror("ioctl EVIOCGRAB(1)"); close(fd); return; } fprintf(stderr,"grabbed input device\n"); } fprintf(stderr,"waiting for events\n"); quit = 0; for (;;) { /* wait for input */ FD_ZERO(&set); FD_SET(fd,&set); tv.tv_sec = timeout; tv.tv_usec = 0; switch (select(fd+1,&set,NULL,NULL,&tv)) { case -1: perror("select"); quit = 1; break; case 0: fprintf(stderr,"timeout, quitting\n"); quit = 1; break; } if (quit) break; /* read input */ if (FD_ISSET(fd,&set)) { switch (read(fd,&event,sizeof(event))) { case -1: perror("read"); quit = 1; break; case 0: fprintf(stderr,"EOF\n"); quit = 1; break; default: print_event(&event); break; } } if (quit) break; } if (grab) { if (-1 == ioctl(fd,EVIOCGRAB,0)) { perror("ioctl EVIOCGRAB(0)"); close(fd); return; } fprintf(stderr,"released input device\n"); } close(fd); } static int usage(char *prog, int error) { fprintf(error ? stderr : stdout, "usage: %s" " [ -g ] [ -t ]" " devnr\n", prog); exit(error); } int main(int argc, char *argv[]) { int timeout = 10; int grab = 0; int c,devnr; for (;;) { if (-1 == (c = getopt(argc, argv, "hgt:"))) break; switch (c) { case 't': timeout = atoi(optarg); break; case 'g': grab = 1; break; case 'h': usage(argv[0],0); default: usage(argv[0],1); } } if (optind == argc) usage(argv[0],1); devnr = atoi(argv[optind]); show_events(devnr,timeout,grab); return 0; } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.3/input-events.man000066400000000000000000000012141305325667200156610ustar00rootroot00000000000000.TH INPUT-EVENTS 8 "July 2005" "" "" .SH NAME input-events \- print input events .SH SYNOPSIS \fBinput\-events \fR [\fB\-t\fR\ \fIsec\fR] [\fB\-g\fR]\ \fIdevnr\fR .SH DESCRIPTION .PP \fBinput\-events\fR listens for events on kernel input device \fIdevnr\fR and prints them. .SH OPTIONS .TP \fIdevnr\fR The index of the input device to use (0 for /dev/input/event0 and so on). .TP \fB\-g\fR Grab device using EVIOCGRAB, i\&.e\&., get exclusive access to the device. .TP \fB\-t\fR\ \fIsec\fR Set the timeout. The program will quit after \fIsec\fR seconds without activity. .SH SEE ALSO .PP lsinput(8) .SH AUTHOR Gerd Hoffmann input-1.3/input-kbd.c000066400000000000000000000140731305325667200145730ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include "input.h" struct input_keymap_entry_v2 { #define KEYMAP_BY_INDEX (1 << 0) uint8_t flags; uint8_t len; uint16_t index; uint32_t keycode; uint8_t scancode[32]; }; #ifndef EVIOCGKEYCODE_V2 #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry_v2) #endif struct kbd_entry { unsigned int scancode; unsigned int keycode; }; struct kbd_map { struct kbd_entry *map; int keys; int size; int alloc; }; /* ------------------------------------------------------------------ */ static struct kbd_map* kbd_map_read(int fd, unsigned int version) { struct kbd_entry entry; struct kbd_map *map; int rc; map = malloc(sizeof(*map)); memset(map,0,sizeof(*map)); for (map->size = 0; map->size < 65536; map->size++) { if (version < 0x10001) { entry.scancode = map->size; entry.keycode = KEY_RESERVED; rc = ioctl(fd, EVIOCGKEYCODE, &entry); if (rc < 0) { break; } } else { struct input_keymap_entry_v2 ke = { .index = map->size, .flags = KEYMAP_BY_INDEX, .len = sizeof(uint32_t), .keycode = KEY_RESERVED, }; rc = ioctl(fd, EVIOCGKEYCODE_V2, &ke); if (rc < 0) break; memcpy(&entry.scancode, ke.scancode, sizeof(entry.scancode)); entry.keycode = ke.keycode; } if (map->size >= map->alloc) { map->alloc += 64; map->map = realloc(map->map, map->alloc * sizeof(entry)); } map->map[map->size] = entry; if (KEY_RESERVED != entry.keycode) map->keys++; } if (map->keys) { fprintf(stderr,"map: %d keys, size: %d/%d\n", map->keys, map->size, map->alloc); return map; } else { free(map); return NULL; } } static int kbd_map_write(int fh, struct kbd_map *map) { int i,rc; for (i = 0; i < map->size; i++) { rc = ioctl(fh, EVIOCSKEYCODE, &map->map[i]); if (0 != rc) { fprintf(stderr,"ioctl EVIOCSKEYCODE(%d,%d): %s\n", map->map[i].scancode,map->map[i].keycode, strerror(errno)); return -1; } } return 0; } static void kbd_key_print(FILE *fp, int scancode, int keycode) { if ( keycode < 10 ) fprintf(fp, "0x%04x = 0x%x # %s\n", scancode, keycode, ev_type_name(EV_KEY, keycode)); else fprintf(fp, "0x%04x = %3d # %s\n", scancode, keycode, ev_type_name(EV_KEY, keycode)); } static void kbd_map_print(FILE *fp, struct kbd_map *map, int complete) { int i; for (i = 0; i < map->size; i++) { if (!complete && KEY_RESERVED == map->map[i].keycode) continue; kbd_key_print(fp,map->map[i].scancode,map->map[i].keycode); } } static struct kbd_map* kbd_map_parse(FILE *fp) { struct kbd_entry entry; struct kbd_map *map; char line[1024],scancode[80],keycode[80]; char *c; int i; map = malloc(sizeof(*map)); memset(map,0,sizeof(*map)); while (NULL != fgets(line,sizeof(line),fp)) { c = strchr(line,'#'); if (c) *c = 0; c = line; while (*c == ' ' || *c == '\t') c++; if (!*c || *c == '\n') continue; // Blank or comment line if (2 != sscanf(line," %79s = %79s", scancode, keycode)) { fprintf(stderr,"parse error: %s",line); return NULL; } /* parse scancode */ entry.scancode = strtol(scancode, NULL, 0); if (entry.scancode < 0) { fprintf(stderr,"scancode %d invalid\n", entry.scancode); return NULL; } /* parse keycode */ for (i = 0; i < KEY_MAX; i++) { if (!EV_TYPE_NAME[EV_KEY][i]) continue; if (0 == strcmp(keycode,EV_TYPE_NAME[EV_KEY][i])) break; } if (i == KEY_MAX) entry.keycode = strtol(keycode, NULL, 0); else entry.keycode = i; fprintf(stderr,"set: "); kbd_key_print(stderr,entry.scancode,entry.keycode); if (map->size >= map->alloc) { map->alloc += 64; map->map = realloc(map->map, map->alloc * sizeof(entry)); } map->map[map->size] = entry; map->size++; } return map; } /* ------------------------------------------------------------------ */ static void kbd_print_bits(int fd) { BITFIELD bits[KEY_CNT/sizeof(BITFIELD)]; int rc,bit; rc = ioctl(fd,EVIOCGBIT(EV_KEY,sizeof(bits)),bits); if (rc < 0) return; for (bit = 0; bit < rc*8 && bit < KEY_MAX; bit++) { if (!test_bit(bit,bits)) continue; if (EV_TYPE_NAME[EV_KEY][bit]) { fprintf(stderr,"bits: %s\n", EV_TYPE_NAME[EV_KEY][bit]); } else { fprintf(stderr,"bits: unknown [%d]\n", bit); } } } static void show_kbd(int nr, int fd, unsigned int protocol_version) { struct kbd_map *map; device_info(nr, fd, true); map = kbd_map_read(fd, protocol_version); if (map) kbd_map_print(stdout, map, 0); else kbd_print_bits(fd); } static int set_kbd(int fd, unsigned int protocol_version, char *mapfile) { struct kbd_map *map; FILE *fp; if (0 == strcmp(mapfile,"-")) fp = stdin; else { fp = fopen(mapfile,"r"); if (NULL == fp) { fprintf(stderr,"open %s: %s\n",mapfile,strerror(errno)); close(fd); return -1; } } map = kbd_map_parse(fp); if (map == NULL || 0 != kbd_map_write(fd,map)) { return -1; } return 0; } static int usage(char *prog, int error) { fprintf(error ? stderr : stdout, "usage: %s [ -f file ] devnr\n", prog); exit(error); } int main(int argc, char *argv[]) { int c, devnr, fd; char *mapfile = NULL; unsigned int protocol_version; int rc = EXIT_FAILURE; for (;;) { if (-1 == (c = getopt(argc, argv, "hf:"))) break; switch (c) { case 'f': mapfile = optarg; break; case 'h': usage(argv[0],0); default: usage(argv[0],1); } } if (optind == argc) usage(argv[0],1); devnr = atoi(argv[optind]); fd = device_open(devnr, 1); if (fd < 0) goto out; if (ioctl(fd, EVIOCGVERSION, &protocol_version) < 0) { fprintf(stderr, "Unable to query evdev protocol version: %s\n", strerror(errno)); goto out_close; } if (mapfile) set_kbd(fd, protocol_version, mapfile); else show_kbd(devnr, fd, protocol_version); rc = EXIT_SUCCESS; out_close: close(fd); out: return rc; } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.3/input-kbd.man000066400000000000000000000033371305325667200151250ustar00rootroot00000000000000.TH INPUT-KBD 8 "July 2005" "" "" .SH NAME input-kbd \- print or modify keyboard maps for input devices .SH SYNOPSIS \fBinput\-kbd\fR \fInum\fR .HP 10 \fBinput\-kbd \fR [\fB\-f\fR\ \fIfile\fR] \fIdevnr\fR .SH DESCRIPTION .PP \fBinput\-kbd\fR prints the keyboard map of kernel input device \fIdevnr\fR on stdout. The keyboard map maps scancodes to keycodes. .PP If the device supports a keyboard map, it is printed in the following format (from the output for an AT keyboard): .IP 0x0001 = 67 # KEY_F9 0x0002 = 65 # KEY_F7 0x0003 = 63 # KEY_F5 0x0004 = 61 # KEY_F3 .PP If the device does not support a keyboard map, \fBinput\-kbd\fR just lists the keys and buttons supported by the device, like this (for a mouse): .IP bits: BTN_LEFT bits: BTN_RIGHT bits: BTN_MIDDLE .SH OPTIONS .TP \fIdevnr\fR The index of the input device to use (0 for /dev/input/event0 and so on). .TP \fB\-f\fR \fIfile\fR Read a keyboard map from a file and reconfigure the device with this map. If the file name is '-' then stdin is used. The map file uses the same format as the output of this command. Blank lines are ignored. A '#' character and anything following it on the same line are ignored as a comment. Scancodes and keycodes are decimal values unless proceeded by "0x" for hexadecimal. To remove a mapping entirely, set it to 0x00 (RESERVED). Key names are also accepted instead of keycodes, like this: .IP 0x0001 = KEY_F9 .TP Be careful setting values from 0 to 9, as they will be parsed as the key symbols, not the decimal numbers. If you want to list a single-digit decimal keycode, specify it as a hexadecimal value to remove any ambiguity. .SH AUTHOR Gerd Hoffmann input-1.3/input-recv.c000066400000000000000000000031561305325667200147720ustar00rootroot00000000000000#include #include #include #include #include #include #include "input.h" #include "tcp.h" /* ------------------------------------------------------------------ */ static int usage(char *prog, int error) { fprintf(error ? stderr : stdout, "usage: %s" "\n", prog); exit(error); } int main(int argc, char *argv[]) { char *addr = NULL; char *port = NULL; char *host = "localhost"; char *serv = "1234"; struct addrinfo ask; int c,sock; memset(&ask,0,sizeof(ask)); ask.ai_family = PF_UNSPEC; ask.ai_socktype = SOCK_STREAM; for (;;) { if (-1 == (c = getopt(argc, argv, "h"))) break; switch (c) { case 'h': usage(argv[0],0); default: usage(argv[0],1); } } tcp_verbose = 1; sock = tcp_connect(&ask,addr,port,host,serv); if (-1 == sock) exit(1); for (;;) { struct input_event ev; fd_set set; int rc; FD_ZERO(&set); FD_SET(sock,&set); rc = select(sock+1,&set,NULL,NULL,NULL); if (1 != rc) { perror("select"); exit(1); } rc = read(sock,&ev,sizeof(ev)); if (rc != sizeof(ev)) { fprintf(stderr,"read ret=%d (expected %d), errno=%s\n", rc,(int)sizeof(ev),strerror(errno)); exit(1); } /* convert from network byte order ... */ ev.time.tv_sec = ntohl(ev.time.tv_sec); ev.time.tv_usec = ntohl(ev.time.tv_usec); ev.type = ntohs(ev.type); ev.code = ntohs(ev.code); ev.value = ntohl(ev.value); print_event(&ev); } return 0; } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.3/input-send.c000066400000000000000000000106731305325667200147660ustar00rootroot00000000000000#include #include #include #include #include #include #include "list.h" #include "input.h" #include "tcp.h" struct connection { int socket; struct sockaddr_storage peer; struct list_head list; char peerhost[INET6_ADDRSTRLEN+1]; char peerserv[33]; }; /* ------------------------------------------------------------------ */ int debug = 0; int timeout = 10; int slisten; int input; LIST_HEAD(connections); static void conn_new(void) { struct connection *conn; unsigned int len; conn = malloc(sizeof(*conn)); memset(conn,0,sizeof(*conn)); len = sizeof(conn->peer); conn->socket = accept(slisten,(struct sockaddr*)&conn->peer,&len); if (-1 == conn->socket) { if (tcp_verbose) perror("accept"); free(conn); return; } if (tcp_verbose) { getnameinfo((struct sockaddr*)&conn->peer,len, conn->peerhost,INET6_ADDRSTRLEN, conn->peerserv,32, NI_NUMERICHOST | NI_NUMERICSERV); fprintf(stderr,"connect from [%s]\n",conn->peerhost); } fcntl(conn->socket,F_SETFL,O_NONBLOCK); /* FIXME: access control */ list_add_tail(&conn->list,&connections); } static void conn_del(struct connection *conn) { if (tcp_verbose) fprintf(stderr,"connection from [%s] closed\n",conn->peerhost); close(conn->socket); list_del(&conn->list); free(conn); } static void input_bcast(struct input_event *ev) { struct connection *conn; struct list_head *item; struct list_head *safe; int rc; if (debug) print_event(ev); /* convert to network byte order ... */ ev->time.tv_sec = htonl(ev->time.tv_sec); ev->time.tv_usec = htonl(ev->time.tv_usec); ev->type = htons(ev->type); ev->code = htons(ev->code); ev->value = htonl(ev->value); /* send out */ list_for_each_safe(item,safe,&connections) { conn = list_entry(item, struct connection, list); rc = write(conn->socket,ev,sizeof(*ev)); if (rc != sizeof(*ev)) conn_del(conn); } } static void loop(void) { struct connection *conn; struct list_head *item; struct list_head *safe; fd_set set; struct timeval tv; int max,rc; for (;;) { tv.tv_sec = timeout; tv.tv_usec = 0; FD_ZERO(&set); FD_SET(slisten,&set); max = slisten; FD_SET(input,&set); if (max < input) max = input; list_for_each(item,&connections) { conn = list_entry(item, struct connection, list); FD_SET(conn->socket,&set); if (max < conn->socket) max = conn->socket; } rc = select(max+1,&set,NULL,NULL,&tv); if (rc < 0) { /* Huh? */ perror("select"); exit(1); } if (0 == rc) { /* timeout */ continue; } list_for_each_safe(item,safe,&connections) { conn = list_entry(item, struct connection, list); if (FD_ISSET(conn->socket,&set)) { char dummy[16]; rc = read(conn->socket,dummy,sizeof(dummy)); if (rc <= 0) conn_del(conn); } } if (FD_ISSET(input,&set)) { struct input_event ev; rc = read(input,&ev,sizeof(ev)); if (rc != sizeof(ev)) exit(1); input_bcast(&ev); } if (FD_ISSET(slisten,&set)) conn_new(); } } /* ------------------------------------------------------------------ */ static void daemonize(void) { switch (fork()) { case -1: perror("fork"); exit(1); case 0: close(0); close(1); close(2); setsid(); open("/dev/null",O_RDWR); dup(0); dup(0); break; default: exit(0); } } static int usage(char *prog, int error) { fprintf(error ? stderr : stdout, "usage: %s" " [ -t ] [ -g ]" " devnr\n", prog); exit(error); } int main(int argc, char *argv[]) { char *addr = NULL; char *port = "1234"; int c,devnr; struct addrinfo ask; memset(&ask,0,sizeof(ask)); ask.ai_family = PF_UNSPEC; ask.ai_socktype = SOCK_STREAM; for (;;) { if (-1 == (c = getopt(argc, argv, "hdt:"))) break; switch (c) { case 'd': debug = 1; tcp_verbose = 1; break; case 't': timeout = atoi(optarg); break; case 'h': usage(argv[0],0); default: usage(argv[0],1); } } if (optind == argc) usage(argv[0],1); devnr = atoi(argv[optind]); input = device_open(devnr,debug); if (-1 == input) exit(1); slisten = tcp_listen(&ask,addr,port); if (-1 == slisten) exit(1); if (!debug) daemonize(); loop(); return 0; } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.3/input.c000066400000000000000000000161441305325667200140360ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include "input.h" /* ------------------------------------------------------------------ */ char *EV_NAME[EV_CNT] = { #include "EV.h" }; static char *REL_NAME[REL_CNT] = { #include "REL.h" }; static char *ABS_NAME[ABS_CNT] = { #include "ABS.h" }; static char *MSC_NAME[MSC_CNT] = { #include "MSC.h" }; static char *LED_NAME[LED_CNT] = { #include "LED.h" }; static char *SND_NAME[SND_CNT] = { #include "SND.h" }; #ifndef REP_CNT #define REP_CNT (REP_MAX + 1) #endif static char *REP_NAME[REP_CNT] = { #include "REP.h" }; static char *KEY_NAME[KEY_CNT] = { #include "KEY.h" #include "BTN.h" }; static char *SW_NAME[SW_CNT] = { #include "SW.h" }; int EV_TYPE_MAX[EV_CNT] = { [EV_REL] = REL_MAX, [EV_ABS] = ABS_MAX, [EV_MSC] = MSC_MAX, [EV_LED] = LED_MAX, [EV_SND] = SND_MAX, [EV_REP] = REP_MAX, [EV_KEY] = KEY_MAX, [EV_SW] = SW_MAX, }; char **EV_TYPE_NAME[EV_CNT] = { [EV_REL] = REL_NAME, [EV_ABS] = ABS_NAME, [EV_MSC] = MSC_NAME, [EV_LED] = LED_NAME, [EV_SND] = SND_NAME, [EV_REP] = REP_NAME, [EV_KEY] = KEY_NAME, [EV_SW] = SW_NAME, }; char *BUS_NAME[] = { #include "BUS.h" }; /* ------------------------------------------------------------------ */ int device_open(int nr, int verbose) { char filename[32]; int fd; snprintf(filename,sizeof(filename), "/dev/input/event%d",nr); fd = open(filename,O_RDONLY); if (-1 == fd) { fprintf(stderr,"open %s: %s\n", filename,strerror(errno)); return -1; } if (verbose) fprintf(stderr,"%s\n",filename); return fd; } int device_info(int nr, int fd, int verbose) { struct input_id id; struct input_absinfo abs; char name[64]; char phys[64]; char buf[64]; BITFIELD evtmap[32]; BITFIELD bitmap[256]; int rc, pos, evts, evt, bits, bit, count; rc = ioctl(fd,EVIOCGID,&id); if (rc < 0) return -1; memset(name, 0, sizeof(name)); memset(phys, 0, sizeof(phys)); memset(evtmap, 0, sizeof(evtmap)); ioctl(fd, EVIOCGNAME(sizeof(name)-1), name); ioctl(fd, EVIOCGPHYS(sizeof(phys)-1), phys); evts = ioctl(fd, EVIOCGBIT(0,sizeof(evtmap)), evtmap); if (!verbose) { memset(buf, 0, sizeof(buf)); for (evt = 0, pos = 0; evt < evts*8 && evt < EV_MAX; evt++) { if (evt == EV_SYN || evt == EV_REP) continue; if (!test_bit(evt,evtmap)) continue; if (pos >= sizeof(buf)) continue; pos += snprintf(buf+pos, sizeof(buf)-pos, "%s%s", pos ? " " : "", EV_NAME[evt]); } fprintf(stderr, "%2d: %04x:%04x %-6.6s %-16.16s %-24.24s %-16s\n", nr, id.vendor, id.product, BUS_NAME[id.bustype], phys, name, buf); } else { fprintf(stderr, " id : %04x:%04x, %s, v%d\n", id.vendor, id.product, BUS_NAME[id.bustype], id.version); fprintf(stderr, " phys : \"%s\"\n",phys); fprintf(stderr, " name : \"%s\"\n",name); for (evt = 0; evt < evts*8 && evt < EV_MAX; evt++) { if (evt == EV_SYN || evt == EV_REP) continue; if (!test_bit(evt,evtmap)) continue; bits = ioctl(fd, EVIOCGBIT(evt,sizeof(bitmap)), bitmap); memset(buf, 0, sizeof(buf)); for (bit = 0, count = 0, pos = 0; bit < bits*8 && bit < EV_TYPE_MAX[evt]; bit++) { if (!test_bit(bit,bitmap)) continue; count++; if (pos >= sizeof(buf)) continue; pos += snprintf(buf+pos, sizeof(buf)-pos, "%s%s", pos ? " " : "", EV_TYPE_NAME[evt][bit]); } if (pos >= sizeof(buf) || ((verbose > 1) && (evt == EV_ABS))) { fprintf(stderr, " %-4.4s : [ %d codes ]\n", EV_NAME[evt], count); if (verbose > 1) { for (bit = 0, count = 0, pos = 0; bit < bits*8 && bit < EV_TYPE_MAX[evt]; bit++) { if (!test_bit(bit,bitmap)) continue; if (evt == EV_ABS) { ioctl(fd, EVIOCGABS(bit), &abs); fprintf(stderr, " " "%-16s [ %5d, %5d ]\n", EV_TYPE_NAME[evt][bit], abs.minimum, abs.maximum); } else { fprintf(stderr, " %s\n", EV_TYPE_NAME[evt][bit]); } } } } else { fprintf(stderr, " %-4.4s : %s\n", EV_NAME[evt], buf); } } fprintf(stderr,"\n"); } return 0; } /* ------------------------------------------------------------------ */ void print_event(struct input_event *event) { char ts[32]; time_t t; t = event->time.tv_sec; strftime(ts,sizeof(ts),"%H:%M:%S",localtime(&t)); fprintf(stderr,"%s.%06ld: %s",ts,event->time.tv_usec, EV_NAME[event->type]); switch (event->type) { case EV_KEY: fprintf(stderr," %s %s", ev_type_name(EV_KEY, event->code), event->value ? "pressed" : "released"); break; case EV_REL: case EV_ABS: case EV_MSC: case EV_LED: case EV_SND: case EV_REP: case EV_SW: fprintf(stderr," %s %d", ev_type_name(event->type, event->code), event->value); break; default: fprintf(stderr," code=%u value=%d", (unsigned int)event->code, event->value); } fprintf(stderr,"\n"); } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.3/input.h000066400000000000000000000014261305325667200140400ustar00rootroot00000000000000#include #include #include #define ev_name(code) ((code) < EV_MAX && EV_NAME[code] ? EV_NAME[code] : "???") #define ev_type_name(type, code) ((code) < EV_TYPE_MAX[type] && EV_TYPE_NAME[type][code] ? EV_TYPE_NAME[type][code] : "???") #define BITFIELD uint32_t extern char *EV_NAME[EV_CNT]; extern int EV_TYPE_MAX[EV_CNT]; extern char **EV_TYPE_NAME[EV_CNT]; extern char *BUS_NAME[]; static __inline__ int test_bit(int nr, BITFIELD * addr) { BITFIELD mask; addr += nr >> 5; mask = 1 << (nr & 0x1f); return ((mask & *addr) != 0); } /* ------------------------------------------------------------------ */ int device_open(int nr, int verbose); int device_info(int nr, int fd, int verbose); void print_event(struct input_event *event); input-1.3/input.spec000066400000000000000000000012371305325667200145430ustar00rootroot00000000000000Name: input License: GPLv2+ Version: 1.3 Release: 1%{?dist} Summary: linux input tools Group: Applications/System URL: http://www.kraxel.org/blog/linux/%{name}/ Source: http://www.kraxel.org/releases/%{name}/%{name}-%{version}.tar.gz %description Tools to handle linux input devices (evdev). List devices, dump input events, ... %prep %setup -q %build export CFLAGS="%{optflags}" make prefix=/usr %install make prefix=/usr DESTDIR=%{buildroot} STRIP="" install %files %doc COPYING %{_bindir}/* %{_mandir}/man8/*.8* %changelog * Wed Feb 22 2017 Gerd Hoffmann 1.3-1 - new package built with tito input-1.3/lirc.sh000077500000000000000000000005221305325667200140140ustar00rootroot00000000000000#!/bin/sh INPUT="/usr/include/linux/input.h" cat <next = (ptr); (ptr)->prev = (ptr); \ } while (0) /* * Insert a item entry between two known consecutive entries. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static __inline__ void __list_add(struct list_head * item, struct list_head * prev, struct list_head * next) { next->prev = item; item->next = next; item->prev = prev; prev->next = item; } /** * list_add - add a item entry * @item: item entry to be added * @head: list head to add it after * * Insert a item entry after the specified head. * This is good for implementing stacks. */ static __inline__ void list_add(struct list_head *item, struct list_head *head) { __list_add(item, head, head->next); } /** * list_add_tail - add a item entry * @item: item entry to be added * @head: list head to add it before * * Insert a item entry before the specified head. * This is useful for implementing queues. */ static __inline__ void list_add_tail(struct list_head *item, struct list_head *head) { __list_add(item, head->prev, head); } /* * Delete a list entry by making the prev/next entries * point to each other. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static __inline__ void __list_del(struct list_head * prev, struct list_head * next) { next->prev = prev; prev->next = next; } /** * list_del - deletes entry from list. * @entry: the element to delete from the list. * Note: list_empty on entry does not return true after this, the entry is in an undefined state. */ static __inline__ void list_del(struct list_head *entry) { __list_del(entry->prev, entry->next); } /** * list_del_init - deletes entry from list and reinitialize it. * @entry: the element to delete from the list. */ static __inline__ void list_del_init(struct list_head *entry) { __list_del(entry->prev, entry->next); INIT_LIST_HEAD(entry); } /** * list_empty - tests whether a list is empty * @head: the list to test. */ static __inline__ int list_empty(struct list_head *head) { return head->next == head; } /** * list_splice - join two lists * @list: the item list to add. * @head: the place to add it in the first list. */ static __inline__ void list_splice(struct list_head *list, struct list_head *head) { struct list_head *first = list->next; if (first != list) { struct list_head *last = list->prev; struct list_head *at = head->next; first->prev = head; head->next = first; last->next = at; at->prev = last; } } /** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ #define list_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) /** * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop counter. * @head: the head for your list. */ #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) /** * list_for_each_safe - iterate over a list safe against removal of list entry * @pos: the &struct list_head to use as a loop counter. * @n: another &struct list_head to use as temporary storage * @head: the head for your list. */ #define list_for_each_safe(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) /** * list_for_each_prev - iterate over a list in reverse order * @pos: the &struct list_head to use as a loop counter. * @head: the head for your list. */ #define list_for_each_prev(pos, head) \ for (pos = (head)->prev; pos != (head); pos = pos->prev) #endif /* _LIST_H */ input-1.3/lsinput.c000066400000000000000000000026601305325667200143730ustar00rootroot00000000000000#include #include #include #include #include #include #include "input.h" /* ------------------------------------------------------------------ */ static void list_devices(int devnr, int verbose) { int i,fd; char filename[32]; struct stat statbuf; for (i = 0; i < 32; i++) { if (devnr > 0 && devnr != i) continue; snprintf(filename,sizeof(filename), "/dev/input/event%d",i); if (stat(filename, &statbuf) != 0) continue; fd = device_open(i, verbose); if (-1 == fd) continue; device_info(i, fd, verbose); close(fd); } return; } static int usage(char *prog, int error) { fprintf(error ? stderr : stdout, "usage: %s" " [ -v ] [ -s ]\n", prog); exit(error); } int main(int argc, char *argv[]) { int verbose = 0; int devnr = -1; int c; for (;;) { if (-1 == (c = getopt(argc, argv, "hvs:"))) break; switch (c) { case 's': devnr = atoi(optarg); break; case 'v': verbose++; break; case 'h': usage(argv[0],0); default: usage(argv[0],1); } } list_devices(devnr, verbose); exit(0); } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.3/lsinput.man000066400000000000000000000011231305325667200147150ustar00rootroot00000000000000.TH LSINPUT 8 "July 2005" "" "" .SH NAME lsinput \- list input devices .SH SYNOPSIS .B lsinput \fBlsinput\fR [\fB\-v\fR]\ [\fB\-s\fR\ \fIdevnr\fR] .SH DESCRIPTION .PP \fBlsinput\fR displays a list of all input devices of the kernel, along with some information about each device. .SH OPTIONS .TP \fB\-v\fR Be verbose, print more details on the input devices. Default is to use a compact format with one line per device. .TP \fB\-s\fR\ \fIdevnr\fR Specify the device to print. Default is to print all devices. .SH SEE ALSO .PP input\-events(8) .SH AUTHOR Gerd Hoffmann input-1.3/mk/000077500000000000000000000000001305325667200131345ustar00rootroot00000000000000input-1.3/mk/.gitignore000066400000000000000000000000061305325667200151200ustar00rootroot00000000000000*.dep input-1.3/mk/Autoconf.mk000066400000000000000000000110261305325667200152430ustar00rootroot00000000000000# # simple autoconf system for GNU make # # (c) 2002-2006 Gerd Hoffmann # # credits for creating this one go to the autotools people because # they managed it to annoy lots of developers and users (including # me) with version incompatibilities. # # This file is public domain. No warranty. If it breaks you keep # both pieces. # ######################################################################## # verbose yes/no verbose ?= no # some stuff used by the tests ifneq ($(verbose),no) # verbose (for debug) ac_init = echo "checking $(1) ... " >&2; rc=no ac_b_cmd = echo "run: $(1)" >&2; $(1) >/dev/null && rc=yes ac_s_cmd = echo "run: $(1)" >&2; rc=`$(1)` ac_fini = echo "... result is $${rc}" >&2; echo >&2; echo "$${rc}" else # normal ac_init = echo -n "checking $(1) ... " >&2; rc=no ac_b_cmd = $(1) >/dev/null 2>&1 && rc=yes ac_s_cmd = rc=`$(1) 2>/dev/null` ac_fini = echo "$${rc}" >&2; echo "$${rc}" endif # some helpers to build cflags and related variables ac_def_cflags_1 = $(if $(filter yes,$($(1))),-D$(1)) ac_lib_cflags = $(foreach lib,$(1),$(call ac_def_cflags_1,HAVE_LIB$(lib))) ac_inc_cflags = $(foreach inc,$(1),$(call ac_def_cflags_1,HAVE_$(inc))) ac_lib_mkvar_1 = $(if $(filter yes,$(HAVE_LIB$(1))),$($(1)_$(2))) ac_lib_mkvar = $(foreach lib,$(1),$(call ac_lib_mkvar_1,$(lib),$(2))) ######################################################################## # the tests ... # get uname ac_uname = $(shell \ $(call ac_init,for system);\ $(call ac_s_cmd,uname -s | tr 'A-Z' 'a-z');\ $(call ac_fini)) ac_uname_arch = $(shell \ $(call ac_init,for arch);\ $(call ac_s_cmd,uname -m | tr 'A-Z' 'a-z');\ $(call ac_fini)) # check for some header file # args: header file ac_header = $(shell \ $(call ac_init,for $(1));\ $(call ac_b_cmd,echo '\#include <$(1)>' |\ $(CC) $(CFLAGS) -E -);\ $(call ac_fini)) # check for some function # args: function [, additional libs ] ac_func = $(shell \ $(call ac_init,for $(1));\ echo 'void $(1)(void); int main(void) {$(1)();return 0;}' \ > __actest.c;\ $(call ac_b_cmd,$(CC) $(CFLAGS) $(LDFLAGS) -o \ __actest __actest.c $(2));\ rm -f __actest __actest.c;\ $(call ac_fini)) # check for some library # args: function, library [, additional libs ] ac_lib = $(shell \ $(call ac_init,for $(1) in $(2));\ echo 'void $(1)(void); int main(void) {$(1)();return 0;}' \ > __actest.c;\ $(call ac_b_cmd,$(CC) $(CFLAGS) $(LDFLAGS) -o \ __actest __actest.c -l$(2) $(3));\ rm -f __actest __actest.c;\ $(call ac_fini)) # check if some compiler flag works # args: compiler flag ac_cflag = $(shell \ $(call ac_init,for $(CC) cflags);\ echo 'int main() {return 0;}' > __actest.c;\ $(call ac_b_cmd,$(CC) $(CFLAGS) $(1) $(LDFLAGS) -o \ __actest __actest.c);\ rm -f __actest __actest.c;\ if test "$${rc}" = "yes"; then rc="$(1)"; else rc="$(2)"; fi;\ $(call ac_fini)) # check for some binary # args: binary name ac_binary = $(shell \ $(call ac_init,for $(1));\ $(call ac_s_cmd,which $(1));\ bin="$$rc";rc="no";\ $(call ac_b_cmd,test -x "$$$$bin");\ $(call ac_fini)) # check if lib64 is used #ac_lib64 = $(shell \ # $(call ac_init,for libdir name);\ # $(call ac_s_cmd,$(CC) -print-search-dirs | grep -q lib64 &&\ # echo "lib64" || echo "lib");\ # $(call ac_fini)) ac_lib64 = $(shell \ $(call ac_init,for libdir name);\ $(call ac_s_cmd,/sbin/ldconfig -p | grep -q lib64 &&\ echo "lib64" || echo "lib");\ $(call ac_fini)) # check for x11 ressource dir prefix ac_resdir = $(shell \ $(call ac_init,for X11 app-defaults prefix);\ $(call ac_s_cmd, for dir in \ /etc/X11/app-defaults \ /usr/X11R6/lib/X11/app-defaults \ /usr/share/X11/app-defaults \ /usr/lib/X11/app-defaults \ ; do test -d "$$dir" || continue;\ dirname "$$dir"; break; done);\ $(call ac_fini)) # check if package is installed, via pkg-config # args: pkg name ac_pkg_config = $(shell \ $(call ac_init,for $(1) (using pkg-config));\ $(call ac_b_cmd, pkg-config $(1));\ $(call ac_fini)) # grep some file # args: regex, file ac_grep = $(shell \ $(call ac_init,for $(1) in $(2));\ $(call ac_b_cmd, grep -q $(1) $(2));\ $(call ac_fini)) ######################################################################## # build Make.config define newline endef make-config-q = $(subst $(newline),\n,$(make-config)) ifeq ($(filter config,$(MAKECMDGOALS)),config) .PHONY: Make.config LIB := $(call ac_lib64) else LIB ?= $(call ac_lib64) LIB := $(LIB) endif .PHONY: config config: Make.config @true Make.config: $(srcdir)/GNUmakefile @echo -e "$(make-config-q)" > $@ @echo @echo "Make.config written, edit if needed" @echo input-1.3/mk/Compile.mk000066400000000000000000000042311305325667200150550ustar00rootroot00000000000000# # some rules to compile stuff ... # # (c) 2002-2006 Gerd Hoffmann # # main features: # * autodependencies via "cpp -MD" # * fancy, non-verbose output # # This file is public domain. No warranty. If it breaks you keep # both pieces. # ######################################################################## # verbose yes/no verbose ?= no # dependency files tmpdep = mk/$(subst /,_,$*).tmp depfile = mk/$(subst /,_,$*).dep depfiles = mk/*.dep compile_c = $(CC) $(CFLAGS) -Wp,-MD,$(tmpdep) -c -o $@ $< compile_c_pic = $(CC) $(CFLAGS) -fPIC -Wp,-MD,$(tmpdep) -c -o $@ $< compile_cc = $(CXX) $(CXXFLAGS) -Wp,-MD,$(tmpdep) -c -o $@ $< fixup_deps = sed -e "s|.*\.o:|$@:|" < $(tmpdep) > $(depfile) && rm -f $(tmpdep) cc_makedirs = mkdir -p $(dir $@) $(dir $(depfile)) link_app = $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) link_so = $(CC) $(LDFLAGS) -shared -Wl,-soname,$(@F) -o $@ $^ $(LDLIBS) ar_lib = rm -f $@ && ar -r $@ $^ && ranlib $@ moc_h = $(MOC) $< -o $@ msgfmt_po = msgfmt -o $@ $< # non-verbose output ifeq ($(verbose),no) echo_compile_c = echo " CC " $@ echo_compile_c_pic = echo " CC " $@ echo_compile_cc = echo " CXX " $@ echo_link_app = echo " LD " $@ echo_link_so = echo " LD " $@ echo_ar_lib = echo " AR " $@ echo_moc_h = echo " MOC " $@ echo_msgfmt_po = echo " MSGFMT " $@ else echo_compile_c = echo $(compile_c) echo_compile_c_pic = echo $(compile_c_pic) echo_compile_cc = echo $(compile_cc) echo_link_app = echo $(link_app) echo_link_so = echo $(link_so) echo_ar_lib = echo $(ar_lib) echo_moc_h = echo $(moc_h) echo_msgfmt_po = echo $(msgfmt_po) endif %.o: %.c @$(cc_makedirs) @$(echo_compile_c) @$(compile_c) @$(fixup_deps) %.opic: %.c @$(cc_makedirs) @$(echo_compile_c_pic) @$(compile_c_pic) @$(fixup_deps) %.o: %.cc @$(cc_makedirs) @$(echo_compile_cc) @$(compile_cc) @$(fixup_deps) %.o: %.cpp @$(cc_makedirs) @$(echo_compile_cc) @$(compile_cc) @$(fixup_deps) %: %.o @$(echo_link_app) @$(link_app) %.so: %.o @$(echo_link_so) @$(link_so) %.a: %.o @$(echo_ar_lib) @$(ar_lib) %.moc : %.h @$(echo_moc_h) @$(moc_h) %.mo : %.po @$(echo_msgfmt_po) @$(msgfmt_po) input-1.3/mk/Maintainer.mk000066400000000000000000000021641305325667200155570ustar00rootroot00000000000000# just some maintainer stuff for me ... ######################################################################## make-sync-dir = $(HOME)/projects/gnu-makefiles .PHONY: sync sync:: distclean test -d $(make-sync-dir) rm -f $(srcdir)/INSTALL $(srcdir)/mk/*.mk cp -v $(make-sync-dir)/INSTALL $(srcdir)/. cp -v $(make-sync-dir)/*.mk $(srcdir)/mk chmod 444 $(srcdir)/INSTALL $(srcdir)/mk/*.mk repository := $(shell basename $(PWD)) usetito := $(shell if test -d .tito; then echo yes; else echo no; fi) release-dir ?= $(HOME)/projects/Releases release-pub ?= bigendian.kraxel.org:/public/vhosts/www.kraxel.org/releases/$(repository) tarball = $(release-dir)/$(repository)-$(VERSION).tar ifeq ($(usetito),yes) .PHONY: release release: @echo "tito config found, so use this ;)" else $(tarball).gz: git tag -m "release $(VERSION)" "$(VERSION)" git push --tags git archive --format=tar --prefix=$(repository)-$(VERSION)/ \ -o $(tarball) $(VERSION) gzip $(tarball) $(tarball).gz.asc: $(tarball).gz gpg --detach-sign --armor $(tarball).gz .PHONY: release release: $(tarball).gz scp $(tarball).gz* $(release-pub) endif input-1.3/mk/Variables.mk000066400000000000000000000024341305325667200154000ustar00rootroot00000000000000# common variables ... ######################################################################## # directories DESTDIR = srcdir ?= . prefix ?= /usr/local bindir = $(DESTDIR)$(prefix)/bin sbindir = $(DESTDIR)$(prefix)/sbin libdir = $(DESTDIR)$(prefix)/$(LIB) shrdir = $(DESTDIR)$(prefix)/share mandir = $(shrdir)/man locdir = $(shrdir)/locale appdir = $(shrdir)/applications # package + version empty := space := $(empty) $(empty) ifneq ($(wildcard $(srcdir)/VERSION),) VERSION := $(shell cat $(srcdir)/VERSION) else VERSION := 42 endif RELTAG := v$(subst .,_,$(VERSION)) # programs CC ?= gcc CXX ?= g++ MOC ?= $(if $(QTDIR),$(QTDIR)/bin/moc,moc) STRIP ?= -s INSTALL ?= install INSTALL_BINARY := $(INSTALL) $(STRIP) INSTALL_SCRIPT := $(INSTALL) INSTALL_DATA := $(INSTALL) -m 644 INSTALL_DIR := $(INSTALL) -d # cflags CFLAGS ?= -g -O2 CXXFLAGS ?= $(CFLAGS) CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes \ -Wpointer-arith -Wunused CXXFLAGS += -Wall -Wpointer-arith -Wunused # add /usr/local to the search path if something is in there ... ifneq ($(wildcard /usr/local/include/*.h),) CFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/$(LIB) endif # fixup include path for $(srcdir) != "." ifneq ($(srcdir),.) CFLAGS += -I. -I$(srcdir) endif input-1.3/name.sh000077500000000000000000000007321305325667200140060ustar00rootroot00000000000000#!/bin/sh TYPE="$1" if test -f "/usr/include/linux/input-event-codes.h" -a "$TYPE" != "BUS"; then INPUT="/usr/include/linux/input-event-codes.h" else INPUT="/usr/include/linux/input.h" fi awk " /KEY_MIN_INTERESTING/ {next}; /EV_VERSION/ { next }; /_MAX/ { next }; /_CNT/ { next }; /#define $1_/ { name = \$2; if (\"$TYPE\" != \"BTN\") { sub(\"^${TYPE}_\", \"\", name); } printf(\"\t[ %-16s ] = \\\"%s\\\",\n\", \$2, name); } " < $INPUT input-1.3/tcp.c000066400000000000000000000100521305325667200134550ustar00rootroot00000000000000#include #include #include #include #include #include #include "tcp.h" int tcp_verbose; /* ------------------------------------------------------------------ */ static char *strfamily(int family) { switch (family) { case PF_INET6: return "ipv6"; case PF_INET: return "ipv4"; case PF_UNIX: return "unix"; } return "????"; } int tcp_connect(struct addrinfo *ai, char *addr, char *port, char *host, char *serv) { struct addrinfo *res,*e; struct addrinfo *lres, ask; char uaddr[INET6_ADDRSTRLEN+1]; char uport[33]; char uhost[INET6_ADDRSTRLEN+1]; char userv[33]; int sock,rc,opt=1; /* lookup peer */ ai->ai_flags = AI_CANONNAME; if (0 != (rc = getaddrinfo(host, serv, ai, &res))) { if (tcp_verbose) fprintf(stderr,"getaddrinfo (peer): %s\n",gai_strerror(rc)); return -1; } for (e = res; e != NULL; e = e->ai_next) { if (0 != getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, uhost,INET6_ADDRSTRLEN,userv,32, NI_NUMERICHOST | NI_NUMERICSERV)) { if (tcp_verbose) fprintf(stderr,"getnameinfo (peer): oops\n"); continue; } if (-1 == (sock = socket(e->ai_family, e->ai_socktype, e->ai_protocol))) { if (tcp_verbose) fprintf(stderr,"socket (%s): %s\n", strfamily(e->ai_family),strerror(errno)); continue; } setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)); if (NULL != addr || NULL != port) { /* bind local port */ memset(&ask,0,sizeof(ask)); ask.ai_flags = AI_PASSIVE; ask.ai_family = e->ai_family; ask.ai_socktype = e->ai_socktype; if (0 != (rc = getaddrinfo(addr, port, &ask, &lres))) { if (tcp_verbose) fprintf(stderr,"getaddrinfo (local): %s\n", gai_strerror(rc)); continue; } if (0 != getnameinfo((struct sockaddr*)lres->ai_addr, lres->ai_addrlen, uaddr,INET6_ADDRSTRLEN,uport,32, NI_NUMERICHOST | NI_NUMERICSERV)) { if (tcp_verbose) fprintf(stderr,"getnameinfo (local): oops\n"); continue; } if (-1 == bind(sock, lres->ai_addr, lres->ai_addrlen)) { if (tcp_verbose) fprintf(stderr,"%s [%s] %s bind: %s\n", strfamily(lres->ai_family),uaddr,uport, strerror(errno)); continue; } } /* connect to peer */ if (-1 == connect(sock,e->ai_addr,e->ai_addrlen)) { if (tcp_verbose) fprintf(stderr,"%s %s [%s] %s connect: %s\n", strfamily(e->ai_family),e->ai_canonname,uhost,userv, strerror(errno)); close(sock); continue; } if (tcp_verbose) fprintf(stderr,"%s %s [%s] %s open\n", strfamily(e->ai_family),e->ai_canonname,uhost,userv); fcntl(sock,F_SETFL,O_NONBLOCK); return sock; } return -1; } int tcp_listen(struct addrinfo *ai, char *addr, char *port) { struct addrinfo *res,*e; char uaddr[INET6_ADDRSTRLEN+1]; char uport[33]; int slisten,rc,opt=1; /* lookup */ ai->ai_flags = AI_PASSIVE; if (0 != (rc = getaddrinfo(addr, port, ai, &res))) { if (tcp_verbose) fprintf(stderr,"getaddrinfo: %s\n",gai_strerror(rc)); exit(1); } /* create socket + bind */ for (e = res; e != NULL; e = e->ai_next) { getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, uaddr,INET6_ADDRSTRLEN,uport,32, NI_NUMERICHOST | NI_NUMERICSERV); if (-1 == (slisten = socket(e->ai_family, e->ai_socktype, e->ai_protocol))) { if (tcp_verbose) fprintf(stderr,"socket (%s): %s\n", strfamily(e->ai_family),strerror(errno)); continue; } opt = 1; setsockopt(slisten,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt)); if (-1 == bind(slisten, e->ai_addr, e->ai_addrlen)) { if (tcp_verbose) fprintf(stderr,"%s [%s] %s bind: %s\n", strfamily(e->ai_family),uaddr,uport, strerror(errno)); continue; } listen(slisten,1); break; } if (NULL == e) return -1; /* wait for a incoming connection */ if (tcp_verbose) fprintf(stderr,"listen on %s [%s] %s ...\n", strfamily(e->ai_family),uaddr,uport); fcntl(slisten,F_SETFL,O_NONBLOCK); return slisten; } input-1.3/tcp.h000066400000000000000000000003641305325667200134670ustar00rootroot00000000000000#include #include #include extern int tcp_verbose; int tcp_connect(struct addrinfo *ai, char *addr, char *port, char *host, char *serv); int tcp_listen(struct addrinfo *ai, char *addr, char *port);