pax_global_header00006660000000000000000000000064116110615710014511gustar00rootroot0000000000000052 comment=28d1d454f6b6871b8dab529cbfad8fb7bf416ecc input-1.0/000077500000000000000000000000001161106157100125105ustar00rootroot00000000000000input-1.0/.cvsignore000066400000000000000000000002151161106157100145060ustar00rootroot00000000000000Make.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 input-1.0/.gitignore000066400000000000000000000002201161106157100144720ustar00rootroot00000000000000Make.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.0/COPYING000066400000000000000000000430761161106157100135550ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, 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.0/GNUmakefile000066400000000000000000000026121161106157100145630ustar00rootroot00000000000000# config -include Make.config include mk/Variables.mk # add our flags + libs CFLAGS += -DVERSION='"$(VERSION)"' LDLIBS += -lm # build TARGETS := lsinput input-events input-kbd input-send input-recv 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 ################################################################# # poor man's autoconf ;-) include mk/Autoconf.mk define make-config LIB := $(LIB) endef ######################################################################## # 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 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.0/INSTALL000066400000000000000000000033511161106157100135430ustar00rootroot00000000000000 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.0/README000066400000000000000000000034061161106157100133730ustar00rootroot00000000000000 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 Knorr [SUSE Labs] input-1.0/VERSION000066400000000000000000000000041161106157100135520ustar00rootroot000000000000001.0 input-1.0/input-events.c000066400000000000000000000042101161106157100153120ustar00rootroot00000000000000#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(fd); if (grab) { 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.0/input-events.man000066400000000000000000000011661161106157100156520ustar00rootroot00000000000000.TH INPUT-EVENTS 8 "July 2005" "" "" .SH NAME input-events \- list input devices .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 Knorr. input-1.0/input-kbd.c000066400000000000000000000134561161106157100145620ustar00rootroot00000000000000#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) { map->size--; 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) { 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 int kbd_map_parse(FILE *fp, struct kbd_map *map) { struct kbd_entry entry; char line[80],scancode[80],keycode[80]; int i; while (NULL != fgets(line,sizeof(line),fp)) { if (2 != sscanf(line," %80s = %80s", scancode, keycode)) { fprintf(stderr,"parse error: %s",line); return -1; } /* parse scancode */ if (0 == strncasecmp(scancode,"0x",2)) { entry.scancode = strtol(scancode, NULL, 16); } else { entry.scancode = strtol(scancode, NULL, 10); } if (entry.scancode < 0 || entry.scancode >= map->size) { fprintf(stderr,"scancode %d out of range (0-%d)\n", entry.scancode,map->size); return -1; } /* 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 = atoi(keycode); else entry.keycode = i; fprintf(stderr,"set: "); kbd_key_print(stderr,entry.scancode,entry.keycode); map->map[entry.scancode] = entry; } return 0; } /* ------------------------------------------------------------------ */ 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 fd, unsigned int protocol_version) { struct kbd_map *map; device_info(fd); 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; map = kbd_map_read(fd, protocol_version); if (NULL == map) { fprintf(stderr,"device has no map\n"); close(fd); return -1; } 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; } } if (0 != kbd_map_parse(fp,map) || 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(fd, protocol_version); rc = EXIT_SUCCESS; out_close: close(fd); out: return rc; } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.0/input-kbd.man000066400000000000000000000023031161106157100151000ustar00rootroot00000000000000.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. The map file uses the same format as the output of this command. Key names are also accepted instead of keycodes, like this: .IP 0x0001 = KEY_F9 .SH AUTHOR Gerd Knorr. input-1.0/input-recv.c000066400000000000000000000031311161106157100147460ustar00rootroot00000000000000#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.0/input-send.c000066400000000000000000000107341161106157100147470ustar00rootroot00000000000000#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[]) { int grab = 0; 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, "hdgt:"))) break; switch (c) { case 'd': debug = 1; tcp_verbose = 1; break; 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]); 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.0/input.c000066400000000000000000000066431161106157100140240ustar00rootroot00000000000000#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; } void device_info(int fd) { struct input_id id; BITFIELD bits[32]; char buf[32]; int rc,bit; rc = ioctl(fd,EVIOCGID,&id); if (rc >= 0) fprintf(stderr, " bustype : %s\n" " vendor : 0x%x\n" " product : 0x%x\n" " version : %d\n", BUS_NAME[id.bustype], id.vendor, id.product, id.version); rc = ioctl(fd,EVIOCGNAME(sizeof(buf)),buf); if (rc >= 0) fprintf(stderr," name : \"%.*s\"\n",rc,buf); rc = ioctl(fd,EVIOCGPHYS(sizeof(buf)),buf); if (rc >= 0) fprintf(stderr," phys : \"%.*s\"\n",rc,buf); rc = ioctl(fd,EVIOCGUNIQ(sizeof(buf)),buf); if (rc >= 0) fprintf(stderr," uniq : \"%.*s\"\n",rc,buf); rc = ioctl(fd,EVIOCGBIT(0,sizeof(bits)),bits); if (rc >= 0) { fprintf(stderr," bits ev :"); for (bit = 0; bit < rc*8 && bit < EV_MAX; bit++) { if (test_bit(bit,bits)) fprintf(stderr," %s", EV_NAME[bit]); } fprintf(stderr,"\n"); } fprintf(stderr,"\n"); } /* ------------------------------------------------------------------ */ 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.0/input.h000066400000000000000000000014021161106157100140150ustar00rootroot00000000000000#include #include #include "linux-input.h" #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); void device_info(int fd); void print_event(struct input_event *event); input-1.0/linux-input.h000066400000000000000000001150171161106157100151620ustar00rootroot00000000000000/* from 2.6.27 */ #ifndef _INPUT_H #define _INPUT_H /* * Copyright (c) 1999-2002 Vojtech Pavlik * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ #ifdef __KERNEL__ #include #include #else #include #include #include #include #endif /* * The event structure itself */ struct input_event { struct timeval time; __u16 type; __u16 code; __s32 value; }; /* * Protocol version. */ #define EV_VERSION 0x010000 /* * IOCTLs (0x00 - 0x7f) */ struct input_id { __u16 bustype; __u16 vendor; __u16 product; __u16 version; }; struct input_absinfo { __s32 value; __s32 minimum; __s32 maximum; __s32 fuzz; __s32 flat; }; #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ #define EVIOCGREP _IOR('E', 0x03, int[2]) /* get repeat settings */ #define EVIOCSREP _IOW('E', 0x03, int[2]) /* set repeat settings */ #define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */ #define EVIOCSKEYCODE _IOW('E', 0x04, int[2]) /* set keycode */ #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */ #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ #define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */ #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */ #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ /* * Event types */ #define EV_SYN 0x00 #define EV_KEY 0x01 #define EV_REL 0x02 #define EV_ABS 0x03 #define EV_MSC 0x04 #define EV_SW 0x05 #define EV_LED 0x11 #define EV_SND 0x12 #define EV_REP 0x14 #define EV_FF 0x15 #define EV_PWR 0x16 #define EV_FF_STATUS 0x17 #define EV_MAX 0x1f #define EV_CNT (EV_MAX+1) /* * Synchronization events. */ #define SYN_REPORT 0 #define SYN_CONFIG 1 /* * Keys and buttons * * Most of the keys/buttons are modeled after USB HUT 1.12 * (see http://www.usb.org/developers/hidpage). * Abbreviations in the comments: * AC - Application Control * AL - Application Launch Button * SC - System Control */ #define KEY_RESERVED 0 #define KEY_ESC 1 #define KEY_1 2 #define KEY_2 3 #define KEY_3 4 #define KEY_4 5 #define KEY_5 6 #define KEY_6 7 #define KEY_7 8 #define KEY_8 9 #define KEY_9 10 #define KEY_0 11 #define KEY_MINUS 12 #define KEY_EQUAL 13 #define KEY_BACKSPACE 14 #define KEY_TAB 15 #define KEY_Q 16 #define KEY_W 17 #define KEY_E 18 #define KEY_R 19 #define KEY_T 20 #define KEY_Y 21 #define KEY_U 22 #define KEY_I 23 #define KEY_O 24 #define KEY_P 25 #define KEY_LEFTBRACE 26 #define KEY_RIGHTBRACE 27 #define KEY_ENTER 28 #define KEY_LEFTCTRL 29 #define KEY_A 30 #define KEY_S 31 #define KEY_D 32 #define KEY_F 33 #define KEY_G 34 #define KEY_H 35 #define KEY_J 36 #define KEY_K 37 #define KEY_L 38 #define KEY_SEMICOLON 39 #define KEY_APOSTROPHE 40 #define KEY_GRAVE 41 #define KEY_LEFTSHIFT 42 #define KEY_BACKSLASH 43 #define KEY_Z 44 #define KEY_X 45 #define KEY_C 46 #define KEY_V 47 #define KEY_B 48 #define KEY_N 49 #define KEY_M 50 #define KEY_COMMA 51 #define KEY_DOT 52 #define KEY_SLASH 53 #define KEY_RIGHTSHIFT 54 #define KEY_KPASTERISK 55 #define KEY_LEFTALT 56 #define KEY_SPACE 57 #define KEY_CAPSLOCK 58 #define KEY_F1 59 #define KEY_F2 60 #define KEY_F3 61 #define KEY_F4 62 #define KEY_F5 63 #define KEY_F6 64 #define KEY_F7 65 #define KEY_F8 66 #define KEY_F9 67 #define KEY_F10 68 #define KEY_NUMLOCK 69 #define KEY_SCROLLLOCK 70 #define KEY_KP7 71 #define KEY_KP8 72 #define KEY_KP9 73 #define KEY_KPMINUS 74 #define KEY_KP4 75 #define KEY_KP5 76 #define KEY_KP6 77 #define KEY_KPPLUS 78 #define KEY_KP1 79 #define KEY_KP2 80 #define KEY_KP3 81 #define KEY_KP0 82 #define KEY_KPDOT 83 #define KEY_ZENKAKUHANKAKU 85 #define KEY_102ND 86 #define KEY_F11 87 #define KEY_F12 88 #define KEY_RO 89 #define KEY_KATAKANA 90 #define KEY_HIRAGANA 91 #define KEY_HENKAN 92 #define KEY_KATAKANAHIRAGANA 93 #define KEY_MUHENKAN 94 #define KEY_KPJPCOMMA 95 #define KEY_KPENTER 96 #define KEY_RIGHTCTRL 97 #define KEY_KPSLASH 98 #define KEY_SYSRQ 99 #define KEY_RIGHTALT 100 #define KEY_LINEFEED 101 #define KEY_HOME 102 #define KEY_UP 103 #define KEY_PAGEUP 104 #define KEY_LEFT 105 #define KEY_RIGHT 106 #define KEY_END 107 #define KEY_DOWN 108 #define KEY_PAGEDOWN 109 #define KEY_INSERT 110 #define KEY_DELETE 111 #define KEY_MACRO 112 #define KEY_MUTE 113 #define KEY_VOLUMEDOWN 114 #define KEY_VOLUMEUP 115 #define KEY_POWER 116 /* SC System Power Down */ #define KEY_KPEQUAL 117 #define KEY_KPPLUSMINUS 118 #define KEY_PAUSE 119 #define KEY_KPCOMMA 121 #define KEY_HANGEUL 122 #define KEY_HANGUEL KEY_HANGEUL #define KEY_HANJA 123 #define KEY_YEN 124 #define KEY_LEFTMETA 125 #define KEY_RIGHTMETA 126 #define KEY_COMPOSE 127 #define KEY_STOP 128 /* AC Stop */ #define KEY_AGAIN 129 #define KEY_PROPS 130 /* AC Properties */ #define KEY_UNDO 131 /* AC Undo */ #define KEY_FRONT 132 #define KEY_COPY 133 /* AC Copy */ #define KEY_OPEN 134 /* AC Open */ #define KEY_PASTE 135 /* AC Paste */ #define KEY_FIND 136 /* AC Search */ #define KEY_CUT 137 /* AC Cut */ #define KEY_HELP 138 /* AL Integrated Help Center */ #define KEY_MENU 139 /* Menu (show menu) */ #define KEY_CALC 140 /* AL Calculator */ #define KEY_SETUP 141 #define KEY_SLEEP 142 /* SC System Sleep */ #define KEY_WAKEUP 143 /* System Wake Up */ #define KEY_FILE 144 /* AL Local Machine Browser */ #define KEY_SENDFILE 145 #define KEY_DELETEFILE 146 #define KEY_XFER 147 #define KEY_PROG1 148 #define KEY_PROG2 149 #define KEY_WWW 150 /* AL Internet Browser */ #define KEY_MSDOS 151 #define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ #define KEY_SCREENLOCK KEY_COFFEE #define KEY_DIRECTION 153 #define KEY_CYCLEWINDOWS 154 #define KEY_MAIL 155 #define KEY_BOOKMARKS 156 /* AC Bookmarks */ #define KEY_COMPUTER 157 #define KEY_BACK 158 /* AC Back */ #define KEY_FORWARD 159 /* AC Forward */ #define KEY_CLOSECD 160 #define KEY_EJECTCD 161 #define KEY_EJECTCLOSECD 162 #define KEY_NEXTSONG 163 #define KEY_PLAYPAUSE 164 #define KEY_PREVIOUSSONG 165 #define KEY_STOPCD 166 #define KEY_RECORD 167 #define KEY_REWIND 168 #define KEY_PHONE 169 /* Media Select Telephone */ #define KEY_ISO 170 #define KEY_CONFIG 171 /* AL Consumer Control Configuration */ #define KEY_HOMEPAGE 172 /* AC Home */ #define KEY_REFRESH 173 /* AC Refresh */ #define KEY_EXIT 174 /* AC Exit */ #define KEY_MOVE 175 #define KEY_EDIT 176 #define KEY_SCROLLUP 177 #define KEY_SCROLLDOWN 178 #define KEY_KPLEFTPAREN 179 #define KEY_KPRIGHTPAREN 180 #define KEY_NEW 181 /* AC New */ #define KEY_REDO 182 /* AC Redo/Repeat */ #define KEY_F13 183 #define KEY_F14 184 #define KEY_F15 185 #define KEY_F16 186 #define KEY_F17 187 #define KEY_F18 188 #define KEY_F19 189 #define KEY_F20 190 #define KEY_F21 191 #define KEY_F22 192 #define KEY_F23 193 #define KEY_F24 194 #define KEY_PLAYCD 200 #define KEY_PAUSECD 201 #define KEY_PROG3 202 #define KEY_PROG4 203 #define KEY_SUSPEND 205 #define KEY_CLOSE 206 /* AC Close */ #define KEY_PLAY 207 #define KEY_FASTFORWARD 208 #define KEY_BASSBOOST 209 #define KEY_PRINT 210 /* AC Print */ #define KEY_HP 211 #define KEY_CAMERA 212 #define KEY_SOUND 213 #define KEY_QUESTION 214 #define KEY_EMAIL 215 #define KEY_CHAT 216 #define KEY_SEARCH 217 #define KEY_CONNECT 218 #define KEY_FINANCE 219 /* AL Checkbook/Finance */ #define KEY_SPORT 220 #define KEY_SHOP 221 #define KEY_ALTERASE 222 #define KEY_CANCEL 223 /* AC Cancel */ #define KEY_BRIGHTNESSDOWN 224 #define KEY_BRIGHTNESSUP 225 #define KEY_MEDIA 226 #define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video outputs (Monitor/LCD/TV-out/etc) */ #define KEY_KBDILLUMTOGGLE 228 #define KEY_KBDILLUMDOWN 229 #define KEY_KBDILLUMUP 230 #define KEY_SEND 231 /* AC Send */ #define KEY_REPLY 232 /* AC Reply */ #define KEY_FORWARDMAIL 233 /* AC Forward Msg */ #define KEY_SAVE 234 /* AC Save */ #define KEY_DOCUMENTS 235 #define KEY_BATTERY 236 #define KEY_BLUETOOTH 237 #define KEY_WLAN 238 #define KEY_UWB 239 #define KEY_UNKNOWN 240 #define KEY_VIDEO_NEXT 241 /* drive next video source */ #define KEY_VIDEO_PREV 242 /* drive previous video source */ #define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ #define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */ #define KEY_DISPLAY_OFF 245 /* display device to off state */ #define KEY_WIMAX 246 /* Range 248 - 255 is reserved for special needs of AT keyboard driver */ #define BTN_MISC 0x100 #define BTN_0 0x100 #define BTN_1 0x101 #define BTN_2 0x102 #define BTN_3 0x103 #define BTN_4 0x104 #define BTN_5 0x105 #define BTN_6 0x106 #define BTN_7 0x107 #define BTN_8 0x108 #define BTN_9 0x109 #define BTN_MOUSE 0x110 #define BTN_LEFT 0x110 #define BTN_RIGHT 0x111 #define BTN_MIDDLE 0x112 #define BTN_SIDE 0x113 #define BTN_EXTRA 0x114 #define BTN_FORWARD 0x115 #define BTN_BACK 0x116 #define BTN_TASK 0x117 #define BTN_JOYSTICK 0x120 #define BTN_TRIGGER 0x120 #define BTN_THUMB 0x121 #define BTN_THUMB2 0x122 #define BTN_TOP 0x123 #define BTN_TOP2 0x124 #define BTN_PINKIE 0x125 #define BTN_BASE 0x126 #define BTN_BASE2 0x127 #define BTN_BASE3 0x128 #define BTN_BASE4 0x129 #define BTN_BASE5 0x12a #define BTN_BASE6 0x12b #define BTN_DEAD 0x12f #define BTN_GAMEPAD 0x130 #define BTN_A 0x130 #define BTN_B 0x131 #define BTN_C 0x132 #define BTN_X 0x133 #define BTN_Y 0x134 #define BTN_Z 0x135 #define BTN_TL 0x136 #define BTN_TR 0x137 #define BTN_TL2 0x138 #define BTN_TR2 0x139 #define BTN_SELECT 0x13a #define BTN_START 0x13b #define BTN_MODE 0x13c #define BTN_THUMBL 0x13d #define BTN_THUMBR 0x13e #define BTN_DIGI 0x140 #define BTN_TOOL_PEN 0x140 #define BTN_TOOL_RUBBER 0x141 #define BTN_TOOL_BRUSH 0x142 #define BTN_TOOL_PENCIL 0x143 #define BTN_TOOL_AIRBRUSH 0x144 #define BTN_TOOL_FINGER 0x145 #define BTN_TOOL_MOUSE 0x146 #define BTN_TOOL_LENS 0x147 #define BTN_TOUCH 0x14a #define BTN_STYLUS 0x14b #define BTN_STYLUS2 0x14c #define BTN_TOOL_DOUBLETAP 0x14d #define BTN_TOOL_TRIPLETAP 0x14e #define BTN_WHEEL 0x150 #define BTN_GEAR_DOWN 0x150 #define BTN_GEAR_UP 0x151 #define KEY_OK 0x160 #define KEY_SELECT 0x161 #define KEY_GOTO 0x162 #define KEY_CLEAR 0x163 #define KEY_POWER2 0x164 #define KEY_OPTION 0x165 #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ #define KEY_TIME 0x167 #define KEY_VENDOR 0x168 #define KEY_ARCHIVE 0x169 #define KEY_PROGRAM 0x16a /* Media Select Program Guide */ #define KEY_CHANNEL 0x16b #define KEY_FAVORITES 0x16c #define KEY_EPG 0x16d #define KEY_PVR 0x16e /* Media Select Home */ #define KEY_MHP 0x16f #define KEY_LANGUAGE 0x170 #define KEY_TITLE 0x171 #define KEY_SUBTITLE 0x172 #define KEY_ANGLE 0x173 #define KEY_ZOOM 0x174 #define KEY_MODE 0x175 #define KEY_KEYBOARD 0x176 #define KEY_SCREEN 0x177 #define KEY_PC 0x178 /* Media Select Computer */ #define KEY_TV 0x179 /* Media Select TV */ #define KEY_TV2 0x17a /* Media Select Cable */ #define KEY_VCR 0x17b /* Media Select VCR */ #define KEY_VCR2 0x17c /* VCR Plus */ #define KEY_SAT 0x17d /* Media Select Satellite */ #define KEY_SAT2 0x17e #define KEY_CD 0x17f /* Media Select CD */ #define KEY_TAPE 0x180 /* Media Select Tape */ #define KEY_RADIO 0x181 #define KEY_TUNER 0x182 /* Media Select Tuner */ #define KEY_PLAYER 0x183 #define KEY_TEXT 0x184 #define KEY_DVD 0x185 /* Media Select DVD */ #define KEY_AUX 0x186 #define KEY_MP3 0x187 #define KEY_AUDIO 0x188 #define KEY_VIDEO 0x189 #define KEY_DIRECTORY 0x18a #define KEY_LIST 0x18b #define KEY_MEMO 0x18c /* Media Select Messages */ #define KEY_CALENDAR 0x18d #define KEY_RED 0x18e #define KEY_GREEN 0x18f #define KEY_YELLOW 0x190 #define KEY_BLUE 0x191 #define KEY_CHANNELUP 0x192 /* Channel Increment */ #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ #define KEY_FIRST 0x194 #define KEY_LAST 0x195 /* Recall Last */ #define KEY_AB 0x196 #define KEY_NEXT 0x197 #define KEY_RESTART 0x198 #define KEY_SLOW 0x199 #define KEY_SHUFFLE 0x19a #define KEY_BREAK 0x19b #define KEY_PREVIOUS 0x19c #define KEY_DIGITS 0x19d #define KEY_TEEN 0x19e #define KEY_TWEN 0x19f #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ #define KEY_GAMES 0x1a1 /* Media Select Games */ #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ #define KEY_EDITOR 0x1a6 /* AL Text Editor */ #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ #define KEY_DATABASE 0x1aa /* AL Database App */ #define KEY_NEWS 0x1ab /* AL Newsreader */ #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ #define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ #define KEY_LOGOFF 0x1b1 /* AL Logoff */ #define KEY_DOLLAR 0x1b2 #define KEY_EURO 0x1b3 #define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ #define KEY_FRAMEFORWARD 0x1b5 #define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ #define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ #define KEY_DEL_EOL 0x1c0 #define KEY_DEL_EOS 0x1c1 #define KEY_INS_LINE 0x1c2 #define KEY_DEL_LINE 0x1c3 #define KEY_FN 0x1d0 #define KEY_FN_ESC 0x1d1 #define KEY_FN_F1 0x1d2 #define KEY_FN_F2 0x1d3 #define KEY_FN_F3 0x1d4 #define KEY_FN_F4 0x1d5 #define KEY_FN_F5 0x1d6 #define KEY_FN_F6 0x1d7 #define KEY_FN_F7 0x1d8 #define KEY_FN_F8 0x1d9 #define KEY_FN_F9 0x1da #define KEY_FN_F10 0x1db #define KEY_FN_F11 0x1dc #define KEY_FN_F12 0x1dd #define KEY_FN_1 0x1de #define KEY_FN_2 0x1df #define KEY_FN_D 0x1e0 #define KEY_FN_E 0x1e1 #define KEY_FN_F 0x1e2 #define KEY_FN_S 0x1e3 #define KEY_FN_B 0x1e4 #define KEY_BRL_DOT1 0x1f1 #define KEY_BRL_DOT2 0x1f2 #define KEY_BRL_DOT3 0x1f3 #define KEY_BRL_DOT4 0x1f4 #define KEY_BRL_DOT5 0x1f5 #define KEY_BRL_DOT6 0x1f6 #define KEY_BRL_DOT7 0x1f7 #define KEY_BRL_DOT8 0x1f8 #define KEY_BRL_DOT9 0x1f9 #define KEY_BRL_DOT10 0x1fa /* We avoid low common keys in module aliases so they don't get huge. */ #define KEY_MIN_INTERESTING KEY_MUTE #define KEY_MAX 0x1ff #define KEY_CNT (KEY_MAX+1) /* * Relative axes */ #define REL_X 0x00 #define REL_Y 0x01 #define REL_Z 0x02 #define REL_RX 0x03 #define REL_RY 0x04 #define REL_RZ 0x05 #define REL_HWHEEL 0x06 #define REL_DIAL 0x07 #define REL_WHEEL 0x08 #define REL_MISC 0x09 #define REL_MAX 0x0f #define REL_CNT (REL_MAX+1) /* * Absolute axes */ #define ABS_X 0x00 #define ABS_Y 0x01 #define ABS_Z 0x02 #define ABS_RX 0x03 #define ABS_RY 0x04 #define ABS_RZ 0x05 #define ABS_THROTTLE 0x06 #define ABS_RUDDER 0x07 #define ABS_WHEEL 0x08 #define ABS_GAS 0x09 #define ABS_BRAKE 0x0a #define ABS_HAT0X 0x10 #define ABS_HAT0Y 0x11 #define ABS_HAT1X 0x12 #define ABS_HAT1Y 0x13 #define ABS_HAT2X 0x14 #define ABS_HAT2Y 0x15 #define ABS_HAT3X 0x16 #define ABS_HAT3Y 0x17 #define ABS_PRESSURE 0x18 #define ABS_DISTANCE 0x19 #define ABS_TILT_X 0x1a #define ABS_TILT_Y 0x1b #define ABS_TOOL_WIDTH 0x1c #define ABS_VOLUME 0x20 #define ABS_MISC 0x28 #define ABS_MAX 0x3f #define ABS_CNT (ABS_MAX+1) /* * Switch events */ #define SW_LID 0x00 /* set = lid shut */ #define SW_TABLET_MODE 0x01 /* set = tablet mode */ #define SW_HEADPHONE_INSERT 0x02 /* set = inserted */ #define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" set = radio enabled */ #define SW_RADIO SW_RFKILL_ALL /* deprecated */ #define SW_MICROPHONE_INSERT 0x04 /* set = inserted */ #define SW_DOCK 0x05 /* set = plugged into dock */ #define SW_MAX 0x0f #define SW_CNT (SW_MAX+1) /* * Misc events */ #define MSC_SERIAL 0x00 #define MSC_PULSELED 0x01 #define MSC_GESTURE 0x02 #define MSC_RAW 0x03 #define MSC_SCAN 0x04 #define MSC_MAX 0x07 #define MSC_CNT (MSC_MAX+1) /* * LEDs */ #define LED_NUML 0x00 #define LED_CAPSL 0x01 #define LED_SCROLLL 0x02 #define LED_COMPOSE 0x03 #define LED_KANA 0x04 #define LED_SLEEP 0x05 #define LED_SUSPEND 0x06 #define LED_MUTE 0x07 #define LED_MISC 0x08 #define LED_MAIL 0x09 #define LED_CHARGING 0x0a #define LED_MAX 0x0f #define LED_CNT (LED_MAX+1) /* * Autorepeat values */ #define REP_DELAY 0x00 #define REP_PERIOD 0x01 #define REP_MAX 0x01 /* * Sounds */ #define SND_CLICK 0x00 #define SND_BELL 0x01 #define SND_TONE 0x02 #define SND_MAX 0x07 #define SND_CNT (SND_MAX+1) /* * IDs. */ #define ID_BUS 0 #define ID_VENDOR 1 #define ID_PRODUCT 2 #define ID_VERSION 3 #define BUS_PCI 0x01 #define BUS_ISAPNP 0x02 #define BUS_USB 0x03 #define BUS_HIL 0x04 #define BUS_BLUETOOTH 0x05 #define BUS_VIRTUAL 0x06 #define BUS_ISA 0x10 #define BUS_I8042 0x11 #define BUS_XTKBD 0x12 #define BUS_RS232 0x13 #define BUS_GAMEPORT 0x14 #define BUS_PARPORT 0x15 #define BUS_AMIGA 0x16 #define BUS_ADB 0x17 #define BUS_I2C 0x18 #define BUS_HOST 0x19 #define BUS_GSC 0x1A #define BUS_ATARI 0x1B /* * Values describing the status of a force-feedback effect */ #define FF_STATUS_STOPPED 0x00 #define FF_STATUS_PLAYING 0x01 #define FF_STATUS_MAX 0x01 /* * Structures used in ioctls to upload effects to a device * They are pieces of a bigger structure (called ff_effect) */ /* * All duration values are expressed in ms. Values above 32767 ms (0x7fff) * should not be used and have unspecified results. */ /** * struct ff_replay - defines scheduling of the force-feedback effect * @length: duration of the effect * @delay: delay before effect should start playing */ struct ff_replay { __u16 length; __u16 delay; }; /** * struct ff_trigger - defines what triggers the force-feedback effect * @button: number of the button triggering the effect * @interval: controls how soon the effect can be re-triggered */ struct ff_trigger { __u16 button; __u16 interval; }; /** * struct ff_envelope - generic force-feedback effect envelope * @attack_length: duration of the attack (ms) * @attack_level: level at the beginning of the attack * @fade_length: duration of fade (ms) * @fade_level: level at the end of fade * * The @attack_level and @fade_level are absolute values; when applying * envelope force-feedback core will convert to positive/negative * value based on polarity of the default level of the effect. * Valid range for the attack and fade levels is 0x0000 - 0x7fff */ struct ff_envelope { __u16 attack_length; __u16 attack_level; __u16 fade_length; __u16 fade_level; }; /** * struct ff_constant_effect - defines parameters of a constant force-feedback effect * @level: strength of the effect; may be negative * @envelope: envelope data */ struct ff_constant_effect { __s16 level; struct ff_envelope envelope; }; /** * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect * @start_level: beginning strength of the effect; may be negative * @end_level: final strength of the effect; may be negative * @envelope: envelope data */ struct ff_ramp_effect { __s16 start_level; __s16 end_level; struct ff_envelope envelope; }; /** * struct ff_condition_effect - defines a spring or friction force-feedback effect * @right_saturation: maximum level when joystick moved all way to the right * @left_saturation: same for the left side * @right_coeff: controls how fast the force grows when the joystick moves * to the right * @left_coeff: same for the left side * @deadband: size of the dead zone, where no force is produced * @center: position of the dead zone */ struct ff_condition_effect { __u16 right_saturation; __u16 left_saturation; __s16 right_coeff; __s16 left_coeff; __u16 deadband; __s16 center; }; /** * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect * @waveform: kind of the effect (wave) * @period: period of the wave (ms) * @magnitude: peak value * @offset: mean value of the wave (roughly) * @phase: 'horizontal' shift * @envelope: envelope data * @custom_len: number of samples (FF_CUSTOM only) * @custom_data: buffer of samples (FF_CUSTOM only) * * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined * for the time being as no driver supports it yet. * * Note: the data pointed by custom_data is copied by the driver. * You can therefore dispose of the memory after the upload/update. */ struct ff_periodic_effect { __u16 waveform; __u16 period; __s16 magnitude; __s16 offset; __u16 phase; struct ff_envelope envelope; __u32 custom_len; __s16 *custom_data; }; /** * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect * @strong_magnitude: magnitude of the heavy motor * @weak_magnitude: magnitude of the light one * * Some rumble pads have two motors of different weight. Strong_magnitude * represents the magnitude of the vibration generated by the heavy one. */ struct ff_rumble_effect { __u16 strong_magnitude; __u16 weak_magnitude; }; /** * struct ff_effect - defines force feedback effect * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) * @id: an unique id assigned to an effect * @direction: direction of the effect * @trigger: trigger conditions (struct ff_trigger) * @replay: scheduling of the effect (struct ff_replay) * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further * defining effect parameters * * This structure is sent through ioctl from the application to the driver. * To create a new effect application should set its @id to -1; the kernel * will return assigned @id which can later be used to update or delete * this effect. * * Direction of the effect is encoded as follows: * 0 deg -> 0x0000 (down) * 90 deg -> 0x4000 (left) * 180 deg -> 0x8000 (up) * 270 deg -> 0xC000 (right) */ struct ff_effect { __u16 type; __s16 id; __u16 direction; struct ff_trigger trigger; struct ff_replay replay; union { struct ff_constant_effect constant; struct ff_ramp_effect ramp; struct ff_periodic_effect periodic; struct ff_condition_effect condition[2]; /* One for each axis */ struct ff_rumble_effect rumble; } u; }; /* * Force feedback effect types */ #define FF_RUMBLE 0x50 #define FF_PERIODIC 0x51 #define FF_CONSTANT 0x52 #define FF_SPRING 0x53 #define FF_FRICTION 0x54 #define FF_DAMPER 0x55 #define FF_INERTIA 0x56 #define FF_RAMP 0x57 #define FF_EFFECT_MIN FF_RUMBLE #define FF_EFFECT_MAX FF_RAMP /* * Force feedback periodic effect types */ #define FF_SQUARE 0x58 #define FF_TRIANGLE 0x59 #define FF_SINE 0x5a #define FF_SAW_UP 0x5b #define FF_SAW_DOWN 0x5c #define FF_CUSTOM 0x5d #define FF_WAVEFORM_MIN FF_SQUARE #define FF_WAVEFORM_MAX FF_CUSTOM /* * Set ff device properties */ #define FF_GAIN 0x60 #define FF_AUTOCENTER 0x61 #define FF_MAX 0x7f #define FF_CNT (FF_MAX+1) #ifdef __KERNEL__ /* * In-kernel definitions. */ #include #include #include #include /** * struct input_dev - represents an input device * @name: name of the device * @phys: physical path to the device in the system hierarchy * @uniq: unique identification code for the device (if device has it) * @id: id of the device (struct input_id) * @evbit: bitmap of types of events supported by the device (EV_KEY, * EV_REL, etc.) * @keybit: bitmap of keys/buttons this device has * @relbit: bitmap of relative axes for the device * @absbit: bitmap of absolute axes for the device * @mscbit: bitmap of miscellaneous events supported by the device * @ledbit: bitmap of leds present on the device * @sndbit: bitmap of sound effects supported by the device * @ffbit: bitmap of force feedback effects supported by the device * @swbit: bitmap of switches present on the device * @keycodemax: size of keycode table * @keycodesize: size of elements in keycode table * @keycode: map of scancodes to keycodes for this device * @setkeycode: optional method to alter current keymap, used to implement * sparse keymaps. If not supplied default mechanism will be used * @getkeycode: optional method to retrieve current keymap. If not supplied * default mechanism will be used * @ff: force feedback structure associated with the device if device * supports force feedback effects * @repeat_key: stores key code of the last key pressed; used to implement * software autorepeat * @timer: timer for software autorepeat * @sync: set to 1 when there were no new events since last EV_SYNC * @abs: current values for reports from absolute axes * @rep: current values for autorepeat parameters (delay, rate) * @key: reflects current state of device's keys/buttons * @led: reflects current state of device's LEDs * @snd: reflects current state of sound effects * @sw: reflects current state of device's switches * @absmax: maximum values for events coming from absolute axes * @absmin: minimum values for events coming from absolute axes * @absfuzz: describes noisiness for axes * @absflat: size of the center flat position (used by joydev) * @open: this method is called when the very first user calls * input_open_device(). The driver must prepare the device * to start generating events (start polling thread, * request an IRQ, submit URB, etc.) * @close: this method is called when the very last user calls * input_close_device(). * @flush: purges the device. Most commonly used to get rid of force * feedback effects loaded into the device when disconnecting * from it * @event: event handler for events sent _to_ the device, like EV_LED * or EV_SND. The device is expected to carry out the requested * action (turn on a LED, play sound, etc.) The call is protected * by @event_lock and must not sleep * @grab: input handle that currently has the device grabbed (via * EVIOCGRAB ioctl). When a handle grabs a device it becomes sole * recipient for all input events coming from the device * @event_lock: this spinlock is is taken when input core receives * and processes a new event for the device (in input_event()). * Code that accesses and/or modifies parameters of a device * (such as keymap or absmin, absmax, absfuzz, etc.) after device * has been registered with input core must take this lock. * @mutex: serializes calls to open(), close() and flush() methods * @users: stores number of users (input handlers) that opened this * device. It is used by input_open_device() and input_close_device() * to make sure that dev->open() is only called when the first * user opens device and dev->close() is called when the very * last user closes the device * @going_away: marks devices that are in a middle of unregistering and * causes input_open_device*() fail with -ENODEV. * @dev: driver model's view of this device * @h_list: list of input handles associated with the device. When * accessing the list dev->mutex must be held * @node: used to place the device onto input_dev_list */ struct input_dev { const char *name; const char *phys; const char *uniq; struct input_id id; unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; unsigned long relbit[BITS_TO_LONGS(REL_CNT)]; unsigned long absbit[BITS_TO_LONGS(ABS_CNT)]; unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)]; unsigned long ledbit[BITS_TO_LONGS(LED_CNT)]; unsigned long sndbit[BITS_TO_LONGS(SND_CNT)]; unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; unsigned int keycodemax; unsigned int keycodesize; void *keycode; int (*setkeycode)(struct input_dev *dev, int scancode, int keycode); int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode); struct ff_device *ff; unsigned int repeat_key; struct timer_list timer; int sync; int abs[ABS_MAX + 1]; int rep[REP_MAX + 1]; unsigned long key[BITS_TO_LONGS(KEY_CNT)]; unsigned long led[BITS_TO_LONGS(LED_CNT)]; unsigned long snd[BITS_TO_LONGS(SND_CNT)]; unsigned long sw[BITS_TO_LONGS(SW_CNT)]; int absmax[ABS_MAX + 1]; int absmin[ABS_MAX + 1]; int absfuzz[ABS_MAX + 1]; int absflat[ABS_MAX + 1]; int (*open)(struct input_dev *dev); void (*close)(struct input_dev *dev); int (*flush)(struct input_dev *dev, struct file *file); int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); struct input_handle *grab; spinlock_t event_lock; struct mutex mutex; unsigned int users; int going_away; struct device dev; struct list_head h_list; struct list_head node; }; #define to_input_dev(d) container_of(d, struct input_dev, dev) /* * Verify that we are in sync with input_device_id mod_devicetable.h #defines */ #if EV_MAX != INPUT_DEVICE_ID_EV_MAX #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match" #endif #if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING #error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match" #endif #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match" #endif #if REL_MAX != INPUT_DEVICE_ID_REL_MAX #error "REL_MAX and INPUT_DEVICE_ID_REL_MAX do not match" #endif #if ABS_MAX != INPUT_DEVICE_ID_ABS_MAX #error "ABS_MAX and INPUT_DEVICE_ID_ABS_MAX do not match" #endif #if MSC_MAX != INPUT_DEVICE_ID_MSC_MAX #error "MSC_MAX and INPUT_DEVICE_ID_MSC_MAX do not match" #endif #if LED_MAX != INPUT_DEVICE_ID_LED_MAX #error "LED_MAX and INPUT_DEVICE_ID_LED_MAX do not match" #endif #if SND_MAX != INPUT_DEVICE_ID_SND_MAX #error "SND_MAX and INPUT_DEVICE_ID_SND_MAX do not match" #endif #if FF_MAX != INPUT_DEVICE_ID_FF_MAX #error "FF_MAX and INPUT_DEVICE_ID_FF_MAX do not match" #endif #if SW_MAX != INPUT_DEVICE_ID_SW_MAX #error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match" #endif #define INPUT_DEVICE_ID_MATCH_DEVICE \ (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \ (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION) struct input_handle; /** * struct input_handler - implements one of interfaces for input devices * @private: driver-specific data * @event: event handler. This method is being called by input core with * interrupts disabled and dev->event_lock spinlock held and so * it may not sleep * @connect: called when attaching a handler to an input device * @disconnect: disconnects a handler from input device * @start: starts handler for given handle. This function is called by * input core right after connect() method and also when a process * that "grabbed" a device releases it * @fops: file operations this driver implements * @minor: beginning of range of 32 minors for devices this driver * can provide * @name: name of the handler, to be shown in /proc/bus/input/handlers * @id_table: pointer to a table of input_device_ids this driver can * handle * @blacklist: pointer to a table of input_device_ids this driver should * ignore even if they match @id_table * @h_list: list of input handles associated with the handler * @node: for placing the driver onto input_handler_list * * Input handlers attach to input devices and create input handles. There * are likely several handlers attached to any given input device at the * same time. All of them will get their copy of input event generated by * the device. * * Note that input core serializes calls to connect() and disconnect() * methods. */ struct input_handler { void *private; void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id); void (*disconnect)(struct input_handle *handle); void (*start)(struct input_handle *handle); const struct file_operations *fops; int minor; const char *name; const struct input_device_id *id_table; const struct input_device_id *blacklist; struct list_head h_list; struct list_head node; }; /** * struct input_handle - links input device with an input handler * @private: handler-specific data * @open: counter showing whether the handle is 'open', i.e. should deliver * events from its device * @name: name given to the handle by handler that created it * @dev: input device the handle is attached to * @handler: handler that works with the device through this handle * @d_node: used to put the handle on device's list of attached handles * @h_node: used to put the handle on handler's list of handles from which * it gets events */ struct input_handle { void *private; int open; const char *name; struct input_dev *dev; struct input_handler *handler; struct list_head d_node; struct list_head h_node; }; struct input_dev *input_allocate_device(void); void input_free_device(struct input_dev *dev); static inline struct input_dev *input_get_device(struct input_dev *dev) { return dev ? to_input_dev(get_device(&dev->dev)) : NULL; } static inline void input_put_device(struct input_dev *dev) { if (dev) put_device(&dev->dev); } static inline void *input_get_drvdata(struct input_dev *dev) { return dev_get_drvdata(&dev->dev); } static inline void input_set_drvdata(struct input_dev *dev, void *data) { dev_set_drvdata(&dev->dev, data); } int __must_check input_register_device(struct input_dev *); void input_unregister_device(struct input_dev *); int __must_check input_register_handler(struct input_handler *); void input_unregister_handler(struct input_handler *); int input_register_handle(struct input_handle *); void input_unregister_handle(struct input_handle *); int input_grab_device(struct input_handle *); void input_release_device(struct input_handle *); int input_open_device(struct input_handle *); void input_close_device(struct input_handle *); int input_flush_device(struct input_handle* handle, struct file* file); void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value); static inline void input_report_key(struct input_dev *dev, unsigned int code, int value) { input_event(dev, EV_KEY, code, !!value); } static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value) { input_event(dev, EV_REL, code, value); } static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value) { input_event(dev, EV_ABS, code, value); } static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value) { input_event(dev, EV_FF_STATUS, code, value); } static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value) { input_event(dev, EV_SW, code, !!value); } static inline void input_sync(struct input_dev *dev) { input_event(dev, EV_SYN, SYN_REPORT, 0); } void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) { dev->absmin[axis] = min; dev->absmax[axis] = max; dev->absfuzz[axis] = fuzz; dev->absflat[axis] = flat; dev->absbit[BIT_WORD(axis)] |= BIT_MASK(axis); } int input_get_keycode(struct input_dev *dev, int scancode, int *keycode); int input_set_keycode(struct input_dev *dev, int scancode, int keycode); extern struct class input_class; /** * struct ff_device - force-feedback part of an input device * @upload: Called to upload an new effect into device * @erase: Called to erase an effect from device * @playback: Called to request device to start playing specified effect * @set_gain: Called to set specified gain * @set_autocenter: Called to auto-center device * @destroy: called by input core when parent input device is being * destroyed * @private: driver-specific data, will be freed automatically * @ffbit: bitmap of force feedback capabilities truly supported by * device (not emulated like ones in input_dev->ffbit) * @mutex: mutex for serializing access to the device * @max_effects: maximum number of effects supported by device * @effects: pointer to an array of effects currently loaded into device * @effect_owners: array of effect owners; when file handle owning * an effect gets closed the effect is automatically erased * * Every force-feedback device must implement upload() and playback() * methods; erase() is optional. set_gain() and set_autocenter() need * only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER * bits. */ struct ff_device { int (*upload)(struct input_dev *dev, struct ff_effect *effect, struct ff_effect *old); int (*erase)(struct input_dev *dev, int effect_id); int (*playback)(struct input_dev *dev, int effect_id, int value); void (*set_gain)(struct input_dev *dev, u16 gain); void (*set_autocenter)(struct input_dev *dev, u16 magnitude); void (*destroy)(struct ff_device *); void *private; unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; struct mutex mutex; int max_effects; struct ff_effect *effects; struct file *effect_owners[]; }; int input_ff_create(struct input_dev *dev, int max_effects); void input_ff_destroy(struct input_dev *dev); int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file); int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file); int input_ff_create_memless(struct input_dev *dev, void *data, int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); #endif #endif input-1.0/lirc.sh000077500000000000000000000005051161106157100140000ustar00rootroot00000000000000#!/bin/sh INPUT="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.0/lsinput.c000066400000000000000000000010541161106157100143520ustar00rootroot00000000000000#include #include #include #include #include "input.h" /* ------------------------------------------------------------------ */ static void list_devices(void) { int i,fd; for (i = 0; i < 32; i++) { /* try to open */ fd = device_open(i,1); if (-1 == fd) return; device_info(fd); close(fd); } return; } int main(int argc, char *argv[]) { list_devices(); exit(0); } /* --------------------------------------------------------------------- * Local variables: * c-basic-offset: 8 * End: */ input-1.0/lsinput.man000066400000000000000000000004421161106157100147030ustar00rootroot00000000000000.TH LSINPUT 8 "July 2005" "" "" .SH NAME lsinput \- list input devices .SH SYNOPSIS .B lsinput .SH DESCRIPTION .PP \fBlsinput\fR displays a list of all input devices of the kernel, along with some information about each device. .SH SEE ALSO .PP input\-events(8) .SH AUTHOR Gerd Knorr. input-1.0/mk/000077500000000000000000000000001161106157100131175ustar00rootroot00000000000000input-1.0/mk/.cvsignore000066400000000000000000000000061161106157100151130ustar00rootroot00000000000000*.dep input-1.0/mk/.gitignore000066400000000000000000000000061161106157100151030ustar00rootroot00000000000000*.dep input-1.0/mk/Autoconf.mk000066400000000000000000000110261161106157100152260ustar00rootroot00000000000000# # 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.0/mk/Compile.mk000066400000000000000000000042311161106157100150400ustar00rootroot00000000000000# # 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.0/mk/Maintainer.mk000066400000000000000000000015211161106157100155360ustar00rootroot00000000000000# 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)) release-dir ?= $(HOME)/projects/Releases release-pub ?= bigendian.kraxel.org:/public/vhosts/www.kraxel.org/releases/$(repository) tarball = $(release-dir)/$(repository)-$(VERSION).tar .PHONY: release release: git tag -m "release $(VERSION)" "$(VERSION)" git push --tags git archive --format=tar --prefix=$(repository)-$(VERSION)/ \ -o $(tarball) $(VERSION) gzip $(tarball) scp $(tarball).gz $(release-pub) input-1.0/mk/Variables.mk000066400000000000000000000024341161106157100153630ustar00rootroot00000000000000# 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.0/name.sh000077500000000000000000000002551161106157100137710ustar00rootroot00000000000000#!/bin/sh TYPE="$1" INPUT="linux-input.h" awk " /EV_VERSION/ { next }; /_MAX/ { next }; /#define $1_/ { printf(\"\t[ %-16s ] = \\\"%s\\\",\n\", \$2, \$2); } " < $INPUTinput-1.0/tcp.c000066400000000000000000000100521161106157100134400ustar00rootroot00000000000000#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.0/tcp.h000066400000000000000000000003641161106157100134520ustar00rootroot00000000000000#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);