From: <sk...@us...> - 2010-09-23 11:41:19
|
Revision: 2385 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2385&view=rev Author: skitt Date: 2010-09-23 11:41:12 +0000 (Thu, 23 Sep 2010) Log Message: ----------- Update inputattach to Dmitry Torokhov's version. Modified Paths: -------------- trunk/utils/inputattach.c Added Paths: ----------- trunk/utils/serio-ids.h Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2007-07-17 18:50:21 UTC (rev 2384) +++ trunk/utils/inputattach.c 2010-09-23 11:41:12 UTC (rev 2385) @@ -16,18 +16,18 @@ /* * 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 + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * * Should you need to contact me, the author, you can do so either by * e-mail - mail your message to <vo...@uc...>, or by paper mail: * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic @@ -46,29 +46,33 @@ #include <fcntl.h> #include <termios.h> #include <string.h> +#include <errno.h> #include <assert.h> #include <ctype.h> -int readchar(int fd, unsigned char *c, int timeout) +#include "serio-ids.h" + +static int readchar(int fd, unsigned char *c, int timeout) { struct timeval tv; fd_set set; - + tv.tv_sec = 0; tv.tv_usec = timeout * 1000; FD_ZERO(&set); FD_SET(fd, &set); - if (!select(fd+1, &set, NULL, NULL, &tv)) return -1; - if (read(fd, c, 1) != 1) return -1; + if (!select(fd + 1, &set, NULL, NULL, &tv)) + return -1; + if (read(fd, c, 1) != 1) + return -1; + return 0; } - - -void setline(int fd, int flags, int speed) +static void setline(int fd, int flags, int speed) { struct termios t; @@ -87,10 +91,11 @@ tcsetattr(fd, TCSANOW, &t); } -int logitech_command(int fd, char *c) +static int logitech_command(int fd, char *c) { int i; unsigned char d; + for (i = 0; c[i]; i++) { write(fd, c + i, 1); if (readchar(fd, &d, 1000)) @@ -101,27 +106,32 @@ return 0; } -int magellan_init(int fd, long *id, long *extra) +static int magellan_init(int fd, unsigned long *id, unsigned long *extra) { write(fd, "m3\rpBB\rz\r", 9); return 0; } -int warrior_init(int fd, long *id, long *extra) +static int warrior_init(int fd, unsigned long *id, unsigned long *extra) { - if (logitech_command(fd, "*S")) return -1; + if (logitech_command(fd, "*S")) + return -1; + setline(fd, CS8, B4800); return 0; } -int spaceball_waitchar(int fd, unsigned char c, unsigned char *d, int timeout) +static int spaceball_waitchar(int fd, unsigned char c, unsigned char *d, + int timeout) { unsigned char b = 0; while (!readchar(fd, &b, timeout)) { - if (b == 0x0a) continue; + if (b == 0x0a) + continue; *d++ = b; - if (b == c) break; + if (b == c) + break; } *d = 0; @@ -129,7 +139,7 @@ return -(b != c); } -int spaceball_waitcmd(int fd, char c, char *d) +static int spaceball_waitcmd(int fd, char c, char *d) { int i; @@ -143,7 +153,7 @@ return -1; } -int spaceball_cmd(int fd, char *c, char *d) +static int spaceball_cmd(int fd, char *c, char *d) { int i; @@ -161,9 +171,9 @@ #define SPACEBALL_2003C 4 #define SPACEBALL_3003C 7 #define SPACEBALL_4000FLX 8 -#define SPACEBALL_4000FLX_L 9 +#define SPACEBALL_4000FLX_L 9 -int spaceball_init(int fd, long *id, long *extra) +static int spaceball_init(int fd, unsigned long *id, unsigned long *extra) { char r[64]; @@ -172,13 +182,13 @@ return -1; if (spaceball_waitcmd(fd, '@', r)) - return -1; + return -1; if (strncmp("@1 Spaceball alive", r, 18)) return -1; if (spaceball_waitcmd(fd, '@', r)) - return -1; + return -1; if (spaceball_cmd(fd, "hm", r)) return -1; @@ -199,7 +209,7 @@ return -1; if (spaceball_waitcmd(fd, '"', r)) - return -1; + return -1; if (strstr(r, " L ")) *id = SPACEBALL_4000FLX_L; @@ -207,13 +217,13 @@ *id = SPACEBALL_4000FLX; if (spaceball_waitcmd(fd, '"', r)) - return -1; + return -1; if (spaceball_cmd(fd, "YS", r)) - return -1; + return -1; if (spaceball_cmd(fd, "M", r)) - return -1; + return -1; return 0; } @@ -226,70 +236,79 @@ return 0; } -int stinger_init(int fd, long *id, long *extra) +static int stinger_init(int fd, unsigned long *id, unsigned long *extra) { int i; unsigned char c; unsigned char *response = "\r\n0600520058C272"; if (write(fd, " E5E5", 5) != 5) /* Enable command */ - return -1; + return -1; for (i = 0; i < 16; i++) /* Check for Stinger */ - if (readchar(fd, &c, 200) || (c != response[i])) + if (readchar(fd, &c, 200) || c != response[i]) return -1; return 0; } -int mzp_init(int fd, long *id, long *extra) +static int mzp_init(int fd, unsigned long *id, unsigned long *extra) { - if (logitech_command(fd, "*X*q")) return -1; + if (logitech_command(fd, "*X*q")) + return -1; + setline(fd, CS8, B9600); return 0; } -int newton_init(int fd, long *id, long *extra) +static int newton_init(int fd, unsigned long *id, unsigned long *extra) { - int i; - unsigned char c; - unsigned char response[35] = - { 0x16, 0x10, 0x02, 0x64, 0x5f, 0x69, 0x64, 0x00, - 0x00, 0x00, 0x0c, 0x6b, 0x79, 0x62, 0x64, 0x61, - 0x70, 0x70, 0x6c, 0x00, 0x00, 0x00, 0x01, 0x6e, - 0x6f, 0x66, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x03, 0xdd, 0xe7 }; + int i; + unsigned char c; + unsigned char response[35] = { + 0x16, 0x10, 0x02, 0x64, 0x5f, 0x69, 0x64, 0x00, + 0x00, 0x00, 0x0c, 0x6b, 0x79, 0x62, 0x64, 0x61, + 0x70, 0x70, 0x6c, 0x00, 0x00, 0x00, 0x01, 0x6e, + 0x6f, 0x66, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x03, 0xdd, 0xe7 + }; - for (i = 0; i < 35; i++) - if (readchar(fd, &c, 400) || (c != response[i])) - return -1; + for (i = 0; i < sizeof(response); i++) + if (readchar(fd, &c, 400) || c != response[i]) + return -1; - return 0; + return 0; } -int twiddler_init(int fd, long *id, long *extra) +static int twiddler_init(int fd, unsigned long *id, unsigned long *extra) { unsigned char c[10]; int count, line; /* Turn DTR off, otherwise the Twiddler won't send any data. */ - if (ioctl(fd, TIOCMGET, &line)) return -1; + if (ioctl(fd, TIOCMGET, &line)) + return -1; line &= ~TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &line)) return -1; + if (ioctl(fd, TIOCMSET, &line)) + return -1; - /* Check whether the device on the serial line is the Twiddler. + /* + * Check whether the device on the serial line is the Twiddler. * * The Twiddler sends data packets of 5 bytes which have the following * properties: the MSB is 0 on the first and 1 on all other bytes, and * the high order nibble of the last byte is always 0x8. * * We read and check two of those 5 byte packets to be sure that we - * are indeed talking to a Twiddler. */ + * are indeed talking to a Twiddler. + */ /* Read at most 5 bytes until we find one with the MSB set to 0 */ for (count = 0; count < 5; count++) { - if (readchar(fd, c+0, 500)) return -1; - if ((c[0] & 0x80) == 0) break; + if (readchar(fd, c, 500)) + return -1; + if ((c[0] & 0x80) == 0) + break; } if (count == 5) { @@ -298,16 +317,16 @@ } /* Read remaining 4 bytes plus the full next data packet */ - for (count = 1; count < 10; count++) { - if (readchar(fd, c+count, 500)) return -1; - } + for (count = 1; count < 10; count++) + if (readchar(fd, c + count, 500)) + return -1; /* Check whether the bytes of both data packets obey the rules */ for (count = 1; count < 10; count++) { - if ((count % 5 == 0 && (c[count] & 0x80) != 0) - || (count % 5 == 4 && (c[count] & 0xF0) != 0x80) - || (count % 5 != 0 && (c[count] & 0x80) != 0x80)) { - /* Invalid byte in data packet */ + if ((count % 5 == 0 && (c[count] & 0x80) != 0x00) || + (count % 5 == 4 && (c[count] & 0xF0) != 0x80) || + (count % 5 != 0 && (c[count] & 0x80) != 0x80)) { + /* Invalid byte in data packet */ return -1; } } @@ -315,8 +334,36 @@ return 0; } -int dump_init(int fd, long *id, long *extra) +static int fujitsu_init(int fd, unsigned long *id, unsigned long *extra) { + unsigned char cmd, data; + + /* Wake up the touchscreen */ + cmd = 0xff; /* Dummy data */; + if (write(fd, &cmd, 1) != 1) + return -1; + + /* Wait to settle down */ + usleep(100 * 1000); /* 100 ms */ + + /* Reset the touchscreen */ + cmd = 0x81; /* Cold reset */ + if (write(fd, &cmd, 1) != 1) + return -1; + + /* Read ACK */ + if (readchar(fd, &data, 100) || (data & 0xbf) != 0x90) + return -1; + + /* Read status */ + if (readchar(fd, &data, 100) || data != 0x00) + return -1; + + return 0; +} + +static int dump_init(int fd, unsigned long *id, unsigned long *extra) +{ unsigned char c, o = 0; c = 0x80; @@ -337,136 +384,237 @@ } struct input_types { - char name[16]; - char name2[16]; + const char *name; + const char *name2; + const char *desc; int speed; int flags; unsigned long type; unsigned long id; unsigned long extra; int flush; - int (*init)(int fd, long *id, long *extra); + int (*init)(int fd, unsigned long *id, unsigned long *extra); }; -struct input_types input_types[] = { +static struct input_types input_types[] = { +{ "--sunkbd", "-skb", "Sun Type 4 and Type 5 keyboards", + B1200, CS8, + SERIO_SUNKBD, 0x00, 0x00, 1, NULL }, +{ "--lkkbd", "-lk", "DEC LK201 / LK401 keyboards", + B4800, CS8|CSTOPB, + SERIO_LKKBD, 0x00, 0x00, 1, NULL }, +{ "--vsxxx-aa", "-vs", + "DEC VSXXX-AA / VSXXX-GA mouse and VSXXX-A tablet", + B4800, CS8|CSTOPB|PARENB|PARODD, + SERIO_VSXXXAA, 0x00, 0x00, 1, NULL }, +{ "--spaceorb", "-orb", "SpaceOrb 360 / SpaceBall Avenger", + B9600, CS8, + SERIO_SPACEORB, 0x00, 0x00, 1, NULL }, +{ "--spaceball", "-sbl", "SpaceBall 2003 / 3003 / 4000 FLX", + B9600, CS8, + SERIO_SPACEBALL, 0x00, 0x00, 0, spaceball_init }, +{ "--magellan", "-mag", "Magellan / SpaceMouse", + B9600, CS8 | CSTOPB | CRTSCTS, + SERIO_MAGELLAN, 0x00, 0x00, 1, magellan_init }, +{ "--warrior", "-war", "WingMan Warrior", + B1200, CS7 | CSTOPB, + SERIO_WARRIOR, 0x00, 0x00, 1, warrior_init }, +{ "--stinger", "-sting", "Gravis Stinger", + B1200, CS8, + SERIO_STINGER, 0x00, 0x00, 1, stinger_init }, +{ "--mousesystems", "-msc", "3-button Mouse Systems mouse", + B1200, CS8, + SERIO_MSC, 0x00, 0x01, 1, NULL }, +{ "--sunmouse", "-sun", "3-button Sun mouse", + B1200, CS8, + SERIO_SUN, 0x00, 0x01, 1, NULL }, +{ "--microsoft", "-bare", "2-button Microsoft mouse", + B1200, CS7, + SERIO_MS, 0x00, 0x00, 1, NULL }, +{ "--mshack", "-ms", "3-button mouse in Microsoft mode", + B1200, CS7, + SERIO_MS, 0x00, 0x01, 1, NULL }, +{ "--mouseman", "-mman", "3-button Logitech / Genius mouse", + B1200, CS7, + SERIO_MP, 0x00, 0x01, 1, NULL }, +{ "--intellimouse", "-ms3", "Microsoft IntelliMouse", + B1200, CS7, + SERIO_MZ, 0x00, 0x11, 1, NULL }, +{ "--mmwheel", "-mmw", + "Logitech mouse with 4-5 buttons or a wheel", + B1200, CS7 | CSTOPB, + SERIO_MZP, 0x00, 0x13, 1, mzp_init }, +{ "--iforce", "-ifor", "I-Force joystick or wheel", + B38400, CS8, + SERIO_IFORCE, 0x00, 0x00, 0, NULL }, +{ "--newtonkbd", "-newt", "Newton keyboard", + B9600, CS8, + SERIO_NEWTON, 0x00, 0x00, 1, newton_init }, +{ "--h3600ts", "-ipaq", "Ipaq h3600 touchscreen", + B115200, CS8, + SERIO_H3600, 0x00, 0x00, 0, NULL }, +{ "--stowawaykbd", "-ipaqkbd", "Stowaway keyboard", + B115200, CS8, + SERIO_STOWAWAY, 0x00, 0x00, 1, NULL }, +{ "--ps2serkbd", "-ps2ser", "PS/2 via serial keyboard", + B1200, CS8, + SERIO_PS2SER, 0x00, 0x00, 1, NULL }, +{ "--twiddler", "-twid", "Handykey Twiddler chording keyboard", + B2400, CS8, + SERIO_TWIDKBD, 0x00, 0x00, 0, twiddler_init }, +{ "--twiddler-joy", "-twidjoy", "Handykey Twiddler used as a joystick", + B2400, CS8, + SERIO_TWIDJOY, 0x00, 0x00, 0, twiddler_init }, +{ "--elotouch", "-elo", "ELO touchscreen, 10-byte mode", + B9600, CS8 | CRTSCTS, + SERIO_ELO, 0x00, 0x00, 0, NULL }, +{ "--elo4002", "-elo6b", "ELO touchscreen, 6-byte mode", + B9600, CS8 | CRTSCTS, + SERIO_ELO, 0x01, 0x00, 0, NULL }, +{ "--elo271-140", "-elo4b", "ELO touchscreen, 4-byte mode", + B9600, CS8 | CRTSCTS, + SERIO_ELO, 0x02, 0x00, 0, NULL }, +{ "--elo261-280", "-elo3b", "ELO Touchscreen, 3-byte mode", + B9600, CS8 | CRTSCTS, + SERIO_ELO, 0x03, 0x00, 0, NULL }, +{ "--mtouch", "-mtouch", "MicroTouch (3M) touchscreen", + B9600, CS8 | CRTSCTS, + SERIO_MICROTOUCH, 0x00, 0x00, 0, NULL }, +{ "--touchright", "-tr", "Touchright serial touchscreen", + B9600, CS8 | CRTSCTS, + SERIO_TOUCHRIGHT, 0x00, 0x00, 0, NULL }, +{ "--touchwin", "-tw", "Touchwindow serial touchscreen", + B4800, CS8 | CRTSCTS, + SERIO_TOUCHWIN, 0x00, 0x00, 0, NULL }, +{ "--penmount", "-pm", "Penmount touchscreen", + B19200, CS8 | CRTSCTS, + SERIO_PENMOUNT, 0x00, 0x00, 0, NULL }, +{ "--fujitsu", "-fjt", "Fujitsu serial touchscreen", + B9600, CS8, + SERIO_FUJITSU, 0x00, 0x00, 1, fujitsu_init }, +{ "--dump", "-dump", "Just enable device", + B2400, CS8, + 0, 0x00, 0x00, 0, dump_init }, +{ NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, NULL } +}; -{ "--sunkbd", "-skb", B1200, CS8, SERIO_SUNKBD, 0, 0, 1, NULL }, -{ "--lkkbd", "-lk", B4800, CS8|CSTOPB, SERIO_LKKBD, 0, 0, 1, NULL }, -{ "--vsxxx-aa", "-vs", B4800, CS8|CSTOPB|PARENB|PARODD,SERIO_VSXXXAA, 0, 0, 1, NULL }, -{ "--spaceorb", "-orb", B9600, CS8, SERIO_SPACEORB, 0, 0, 1, NULL }, -{ "--spaceball", "-sbl", B9600, CS8, SERIO_SPACEBALL,0, 0, 0, spaceball_init }, -{ "--magellan", "-mag", B9600, CS8 | CSTOPB | CRTSCTS, SERIO_MAGELLAN, 0, 0, 1, magellan_init }, -{ "--warrior", "-war", B1200, CS7 | CSTOPB, SERIO_WARRIOR, 0, 0, 1, warrior_init }, -{ "--stinger", "-sting", B1200, CS8, SERIO_STINGER, 0, 0, 1, stinger_init }, -{ "--mousesystems", "-msc", B1200, CS8, SERIO_MSC, 0, 0x01, 1, NULL }, -{ "--sunmouse", "-sun", B1200, CS8, SERIO_SUN, 0, 0x01, 1, NULL }, -{ "--microsoft", "-bare", B1200, CS7, SERIO_MS, 0, 0, 1, NULL }, -{ "--mshack", "-ms", B1200, CS7, SERIO_MS, 0, 0x01, 1, NULL }, -{ "--mouseman", "-mman", B1200, CS7, SERIO_MP, 0, 0x01, 1, NULL }, -{ "--intellimouse", "-ms3", B1200, CS7, SERIO_MZ, 0, 0x11, 1, NULL }, -{ "--mmwheel", "-mmw", B1200, CS7 | CSTOPB, SERIO_MZP, 0, 0x13, 1, mzp_init }, -{ "--iforce", "-ifor", B38400, CS8, SERIO_IFORCE, 0, 0, 0, NULL }, -{ "--newtonkbd", "-newt", B9600, CS8, SERIO_NEWTON, 0, 0, 0, newton_init }, -{ "--h3600ts", "-ipaq", B115200, CS8, SERIO_H3600, 0, 0, 0, NULL }, -{ "--stowawaykbd", "-ipaqkbd", B115200, CS8, SERIO_STOWAWAY, 0, 0, 0, NULL }, -{ "--ps2serkbd", "-ps2ser", B1200, CS8, SERIO_PS2SER, 0, 0, 1, NULL }, -{ "--twiddler", "-twid", B2400, CS8, SERIO_TWIDKBD, 0, 0, 0, twiddler_init }, -{ "--twiddler-joy", "-twidjoy", B2400, CS8, SERIO_TWIDJOY, 0, 0, 0, twiddler_init }, -{ "--elotouch", "-elo", B9600, CS8 | CRTSCTS, SERIO_ELO, 0, 0, 0, NULL }, -{ "--elo4002", "-elo6b", B9600, CS8 | CRTSCTS, SERIO_ELO, 1, 0, 0, NULL }, -{ "--elo271-140", "-elo4b", B9600, CS8 | CRTSCTS, SERIO_ELO, 2, 0, 0, NULL }, -{ "--elo261-280", "-elo3b", B9600, CS8 | CRTSCTS, SERIO_ELO, 3, 0, 0, NULL }, -{ "--dump", "-dump", B2400, CS8, 0, 0, 0, 0, dump_init }, -{ "", "", 0, 0 } +static void show_help(void) +{ + struct input_types *type; -}; + puts(""); + puts("Usage: inputattach [--daemon] <mode> <device>"); + puts(""); + puts("Modes:"); + for (type = input_types; type->name; type++) + printf(" %-16s %-8s %s\n", + type->name, type->name2, type->desc); + + puts(""); +} + int main(int argc, char **argv) { unsigned long devt; int ldisc; - int type; - long id, extra; - int fd; + struct input_types *type = NULL; + const char *device = NULL; + int daemon_mode = 0; + int need_device = 0; + unsigned long id, extra; + int fd; + int i; char c; + int retval; - if (argc < 2 || argc > 3 || !strcmp("--help", argv[1])) { - puts(""); - puts("Usage: inputttach <mode> <device>"); - puts(""); - puts("Modes:"); - puts(" --sunkbd -skb Sun Type 4 and Type 5 keyboards"); - puts(" --lkkbd -lk DEC LK201 / LK401 keyboards"); - puts(" --vsxxx-aa -vs DEC VSXXX-AA / VSXXX-GA mouse and VSXXX-AB tablet"); - puts(" --spaceorb -orb SpaceOrb 360 / SpaceBall Avenger"); - puts(" --spaceball -sbl SpaceBall 2003 / 3003 / 4000 FLX"); - puts(" --magellan -mag Magellan / SpaceMouse"); - puts(" --warrior -war WingMan Warrior"); - puts(" --stinger -stng Gravis Stinger"); - puts(" --mousesystems -msc 3-button Mouse Systems mice"); - puts(" --sunmouse -sun 3-button Sun mice"); - puts(" --microsoft -bare 2-button Microsoft mice"); - puts(" --mshack -ms 3-button mice in Microsoft mode"); - puts(" --mouseman -mman 3-button Logitech and Genius mice"); - puts(" --intellimouse -ms3 Microsoft IntelliMouse"); - puts(" --mmwheel -mmw Logitech mice with 4-5 buttons or wheel"); - puts(" --iforce -ifor I-Force joysticks and wheels"); - puts(" --h3600ts -ipaq Ipaq h3600 touchscreen"); - puts(" --stowawaykbd -ipaqkbd Stowaway keyboard"); - puts(" --ps2serkbd -ps2ser PS/2 via serial keyboard"); - puts(" --twiddler -twid Handykey Twiddler chording keyboard"); - puts(" --twiddler-joy -twidjoy Handykey Twiddler used as a joystick"); - puts(""); - return 1; - } + for (i = 1; i < argc; i++) { + if (!strcasecmp(argv[i], "--help")) { + show_help(); + return EXIT_SUCCESS; + } else if (!strcasecmp(argv[i], "--daemon")) { + daemon_mode = 1; + } else if (need_device) { + device = argv[i]; + need_device = 0; + } else { + if (type && type->name) { + fprintf(stderr, + "inputattach: '%s' - " + "only one mode allowed\n", argv[i]); + return EXIT_FAILURE; + } + for (type = input_types; type->name; type++) { + if (!strcasecmp(argv[i], type->name) || + !strcasecmp(argv[i], type->name2)) { + break; + } + } + if (!type->name) { + fprintf(stderr, + "inputattach: invalid mode '%s'\n", + argv[i]); + return EXIT_FAILURE; + } + need_device = 1; + } + } - for (type = 0; input_types[type].speed; type++) { - if (!strncasecmp(argv[1], input_types[type].name, 16) || - !strncasecmp(argv[1], input_types[type].name2, 16)) - break; + if (!type || !type->name) { + fprintf(stderr, "inputattach: must specify mode\n"); + return EXIT_FAILURE; } - if (!input_types[type].speed) { - fprintf(stderr, "inputattach: invalid mode\n"); - return 1; + if (need_device) { + fprintf(stderr, "inputattach: must specify device\n"); + return EXIT_FAILURE; } - if ((fd = open(argv[2], O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) { - perror("inputattach"); + fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK); + if (fd < 0) { + fprintf(stderr, "inputattach: '%s' - %s\n", + device, strerror(errno)); return 1; } - setline(fd, input_types[type].flags, input_types[type].speed); + setline(fd, type->flags, type->speed); - if (input_types[type].flush) - while (!readchar(fd, &c, 100)); + if (type->flush) + while (!readchar(fd, &c, 100)) + /* empty */; - id = input_types[type].id; - extra = input_types[type].extra; + id = type->id; + extra = type->extra; - if (input_types[type].init && input_types[type].init(fd, &id, &extra)) { + if (type->init && type->init(fd, &id, &extra)) { fprintf(stderr, "inputattach: device initialization failed\n"); - return 1; + return EXIT_FAILURE; } ldisc = N_MOUSE; - if(ioctl(fd, TIOCSETD, &ldisc)) { - fprintf(stderr, "inputattach: can't set line discipline\n"); - return 1; + if (ioctl(fd, TIOCSETD, &ldisc)) { + fprintf(stderr, "inputattach: can't set line discipline\n"); + return EXIT_FAILURE; } - devt = input_types[type].type | (id << 8) | (extra << 16); + devt = type->type | (id << 8) | (extra << 16); - if(ioctl(fd, SPIOCSTYPE, &devt)) { + if (ioctl(fd, SPIOCSTYPE, &devt)) { fprintf(stderr, "inputattach: can't set device type\n"); - return 1; + return EXIT_FAILURE; } + retval = EXIT_SUCCESS; + if (daemon_mode && daemon(0, 0) < 0) { + perror("inputattach"); + retval = EXIT_FAILURE; + } + read(fd, NULL, 0); ldisc = 0; ioctl(fd, TIOCSETD, &ldisc); close(fd); - return 0; + return retval; } Added: trunk/utils/serio-ids.h =================================================================== --- trunk/utils/serio-ids.h (rev 0) +++ trunk/utils/serio-ids.h 2010-09-23 11:41:12 UTC (rev 2385) @@ -0,0 +1,111 @@ +#ifndef _SERIO_IDS_H +#define _SERIO_IDS_H + +#ifndef SERIO_RS232 +# define SERIO_RS232 0x02 +#endif + +/* + * Serio types + */ +#ifndef SERIO_UNKNOWN +# define SERIO_UNKNOWN 0x00 +#endif +#ifndef SERIO_MSC +# define SERIO_MSC 0x01 +#endif +#ifndef SERIO_SUN +# define SERIO_SUN 0x02 +#endif +#ifndef SERIO_MS +# define SERIO_MS 0x03 +#endif +#ifndef SERIO_MP +# define SERIO_MP 0x04 +#endif +#ifndef SERIO_MZ +# define SERIO_MZ 0x05 +#endif +#ifndef SERIO_MZP +# define SERIO_MZP 0x06 +#endif +#ifndef SERIO_MZPP +# define SERIO_MZPP 0x07 +#endif +#ifndef SERIO_VSXXXAA +# define SERIO_VSXXXAA 0x08 +#endif +#ifndef SERIO_SUNKBD +# define SERIO_SUNKBD 0x10 +#endif +#ifndef SERIO_WARRIOR +# define SERIO_WARRIOR 0x18 +#endif +#ifndef SERIO_SPACEORB +# define SERIO_SPACEORB 0x19 +#endif +#ifndef SERIO_MAGELLAN +# define SERIO_MAGELLAN 0x1a +#endif +#ifndef SERIO_SPACEBALL +# define SERIO_SPACEBALL 0x1b +#endif +#ifndef SERIO_GUNZE +# define SERIO_GUNZE 0x1c +#endif +#ifndef SERIO_IFORCE +# define SERIO_IFORCE 0x1d +#endif +#ifndef SERIO_STINGER +# define SERIO_STINGER 0x1e +#endif +#ifndef SERIO_NEWTON +# define SERIO_NEWTON 0x1f +#endif +#ifndef SERIO_STOWAWAY +# define SERIO_STOWAWAY 0x20 +#endif +#ifndef SERIO_H3600 +# define SERIO_H3600 0x21 +#endif +#ifndef SERIO_PS2SER +# define SERIO_PS2SER 0x22 +#endif +#ifndef SERIO_TWIDKBD +# define SERIO_TWIDKBD 0x23 +#endif +#ifndef SERIO_TWIDJOY +# define SERIO_TWIDJOY 0x24 +#endif +#ifndef SERIO_HIL +# define SERIO_HIL 0x25 +#endif +#ifndef SERIO_SNES232 +# define SERIO_SNES232 0x26 +#endif +#ifndef SERIO_SEMTECH +# define SERIO_SEMTECH 0x27 +#endif +#ifndef SERIO_LKKBD +# define SERIO_LKKBD 0x28 +#endif +#ifndef SERIO_ELO +# define SERIO_ELO 0x29 +#endif +#ifndef SERIO_MICROTOUCH +# define SERIO_MICROTOUCH 0x30 +#endif +#ifndef SERIO_PENMOUNT +# define SERIO_PENMOUNT 0x31 +#endif +#ifndef SERIO_TOUCHRIGHT +# define SERIO_TOUCHRIGHT 0x32 +#endif +#ifndef SERIO_TOUCHWIN +# define SERIO_TOUCHWIN 0x33 +#endif +#ifndef SERIO_FUJITSU +# define SERIO_FUJITSU 0x34 +#endif + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2010-09-23 11:58:04
|
Revision: 2393 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2393&view=rev Author: skitt Date: 2010-09-23 11:57:57 +0000 (Thu, 23 Sep 2010) Log Message: ----------- Handle both known versions of KEY_MAX when retrieving the button map; avoid segfaulting in any case! Modified Paths: -------------- trunk/utils/Makefile trunk/utils/jstest.c Added Paths: ----------- trunk/utils/axbtnmap.c trunk/utils/axbtnmap.h Modified: trunk/utils/Makefile =================================================================== --- trunk/utils/Makefile 2010-09-23 11:56:32 UTC (rev 2392) +++ trunk/utils/Makefile 2010-09-23 11:57:57 UTC (rev 2393) @@ -50,9 +50,17 @@ ffmvforce: ffmvforce.o $(CC) $^ -o $@ $(LDFLAGS) -g -lm `sdl-config --libs` -jscal: jscal.o +axbtnmap.o: axbtnmap.c axbtnmap.h + +jscal.o: jscal.c axbtnmap.h + +jscal: jscal.o axbtnmap.o $(CC) $(CFLAGS) $(CPPFLAGS) -lm $^ -o $@ +jstest.o: jstest.c axbtnmap.h + +jstest: jstest.o axbtnmap.o + gencodes: gencodes.c scancodes.h $(CC) $(CFLAGS) $(CPPFLAGS) gencodes.c -o gencodes Added: trunk/utils/axbtnmap.c =================================================================== --- trunk/utils/axbtnmap.c (rev 0) +++ trunk/utils/axbtnmap.c 2010-09-23 11:57:57 UTC (rev 2393) @@ -0,0 +1,89 @@ +/* + * Axis and button map support functions. + * Copyright © 2009 Stephen Kitt <st...@sk...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <errno.h> +#include <stdint.h> + +#include <sys/ioctl.h> +#include <sys/types.h> + +#include <linux/input.h> +#include <linux/joystick.h> + +#include "axbtnmap.h" + +/* The following values come from include/joystick.h in the kernel source. */ +#define JSIOCSBTNMAP_LARGE _IOW('j', 0x33, __u16[KEY_MAX_LARGE - BTN_MISC + 1]) +#define JSIOCSBTNMAP_SMALL _IOW('j', 0x33, __u16[KEY_MAX_SMALL - BTN_MISC + 1]) +#define JSIOCGBTNMAP_LARGE _IOR('j', 0x34, __u16[KEY_MAX_LARGE - BTN_MISC + 1]) +#define JSIOCGBTNMAP_SMALL _IOR('j', 0x34, __u16[KEY_MAX_SMALL - BTN_MISC + 1]) + +int determine_ioctl(int fd, int *ioctls, int *ioctl_used, void *argp) +{ + int i, retval = 0; + + /* Try each ioctl in turn. */ + for (i = 0; ioctls[i]; i++) { + if ((retval = ioctl(fd, ioctls[i], argp)) >= 0) { + /* The ioctl did something. */ + *ioctl_used = ioctls[i]; + return retval; + } else if (errno != -EINVAL) { + /* Some other error occurred. */ + return retval; + } + } + return retval; +} + +int getbtnmap(int fd, uint16_t *btnmap) +{ + static int jsiocgbtnmap = 0; + int ioctls[] = { JSIOCGBTNMAP, JSIOCGBTNMAP_LARGE, JSIOCGBTNMAP_SMALL, 0 }; + + if (jsiocgbtnmap != 0) { + /* We already know which ioctl to use. */ + return ioctl(fd, jsiocgbtnmap, btnmap); + } else { + return determine_ioctl(fd, ioctls, &jsiocgbtnmap, btnmap); + } +} + +int setbtnmap(int fd, uint16_t *btnmap) +{ + static int jsiocsbtnmap = 0; + int ioctls[] = { JSIOCSBTNMAP, JSIOCSBTNMAP_LARGE, JSIOCSBTNMAP_SMALL, 0 }; + + if (jsiocsbtnmap != 0) { + /* We already know which ioctl to use. */ + return ioctl(fd, jsiocsbtnmap, btnmap); + } else { + return determine_ioctl(fd, ioctls, &jsiocsbtnmap, btnmap); + } +} + +int getaxmap(int fd, uint8_t *axmap) +{ + return ioctl(fd, JSIOCGAXMAP, axmap); +} + +int setaxmap(int fd, uint8_t *axmap) +{ + return ioctl(fd, JSIOCSAXMAP, axmap); +} Added: trunk/utils/axbtnmap.h =================================================================== --- trunk/utils/axbtnmap.h (rev 0) +++ trunk/utils/axbtnmap.h 2010-09-23 11:57:57 UTC (rev 2393) @@ -0,0 +1,65 @@ +/* + * Axis and button map support functions. + * Copyright © 2009 Stephen Kitt <st...@sk...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __AXBTNMAP_H__ +#define __AXBTNMAP_H__ + +#include <stdint.h> +#include <linux/input.h> + +/* The following values come from include/input.h in the kernel + source; the small variant is used up to version 2.6.27, the large + one from 2.6.28 onwards. We need to handle both values because the + kernel doesn't; it only expects one of the values, and we need to + determine which one at run-time. */ +#define KEY_MAX_LARGE 0x2FF +#define KEY_MAX_SMALL 0x1FF + +/* Axis map size. */ +#define AXMAP_SIZE (ABS_MAX + 1) + +/* Button map size. */ +#define BTNMAP_SIZE (KEY_MAX_LARGE - BTN_MISC + 1) + +/* Retrieves the current axis map in the given array, which must + contain at least AXMAP_SIZE elements. Returns the result of the + ioctl(): negative in case of an error, 0 otherwise for kernels up + to 2.6.30, the length of the array actually copied for later + kernels. */ +int getaxmap(int fd, uint8_t *axmap); + +/* Uses the given array as the axis map. The array must contain at + least AXMAP_SIZE elements. Returns the result of the ioctl(): + negative in case of an error, 0 otherwise. */ +int setaxmap(int fd, uint8_t *axmap); + +/* Retrieves the current button map in the given array, which must + contain at least BTNMAP_SIZE elements. Returns the result of the + ioctl(): negative in case of an error, 0 otherwise for kernels up + to 2.6.30, the length of the array actually copied for later + kernels. */ +int getbtnmap(int fd, uint16_t *btnmap); + +/* Uses the given array as the button map. The array must contain at + least BTNMAP_SIZE elements. Returns the result of the ioctl(): + negative in case of an error, 0 otherwise. */ +int setbtnmap(int fd, uint16_t *btnmap); + +#endif + Modified: trunk/utils/jstest.c =================================================================== --- trunk/utils/jstest.c 2010-09-23 11:56:32 UTC (rev 2392) +++ trunk/utils/jstest.c 2010-09-23 11:57:57 UTC (rev 2393) @@ -49,6 +49,8 @@ #include <linux/input.h> #include <linux/joystick.h> +#include "axbtnmap.h" + char *axis_names[ABS_MAX + 1] = { "X", "Y", "Z", "Rx", "Ry", "Rz", "Throttle", "Rudder", "Wheel", "Gas", "Brake", "?", "?", "?", "?", "?", @@ -74,8 +76,9 @@ unsigned char buttons = 2; int version = 0x000800; char name[NAME_LENGTH] = "Unknown"; - uint16_t btnmap[KEY_MAX - BTN_MISC + 1]; - uint8_t axmap[ABS_MAX + 1]; + uint16_t btnmap[BTNMAP_SIZE]; + uint8_t axmap[AXMAP_SIZE]; + int btnmapok = 1; if (argc < 2 || argc > 3 || !strcmp("--help", argv[1])) { puts(""); @@ -99,15 +102,23 @@ ioctl(fd, JSIOCGAXES, &axes); ioctl(fd, JSIOCGBUTTONS, &buttons); ioctl(fd, JSIOCGNAME(NAME_LENGTH), name); - ioctl(fd, JSIOCGAXMAP, axmap); - ioctl(fd, JSIOCGBTNMAP, btnmap); + getaxmap(fd, axmap); + getbtnmap(fd, btnmap); printf("Driver version is %d.%d.%d.\n", version >> 16, (version >> 8) & 0xff, version & 0xff); - if (buttons > 0 && btnmap[0] < BTN_MISC) { + /* Determine whether the button map is usable. */ + for (i = 0; btnmapok && i < buttons; i++) { + if (btnmap[i] < BTN_MISC || btnmap[i] > KEY_MAX) { + btnmapok = 0; + break; + } + } + if (!btnmapok) { /* btnmap out of range for names. Don't print any. */ + puts("jstest is not fully compatible with your kernel. Unable to retrieve button map!"); printf("Joystick (%s) has %d axes ", name, axes); printf("and %d buttons.\n", buttons); } else { @@ -117,8 +128,9 @@ puts(")"); printf("and %d buttons (", buttons); - for (i = 0; i < buttons; i++) + for (i = 0; i < buttons; i++) { printf("%s%s", i > 0 ? ", " : "", button_names[btnmap[i] - BTN_MISC]); + } puts(")."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2010-09-23 12:01:00
|
Revision: 2394 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2394&view=rev Author: skitt Date: 2010-09-23 12:00:54 +0000 (Thu, 23 Sep 2010) Log Message: ----------- ioctl() return values are negative if an error occurs. A positive value can be returned legitimately. This patch is required for jscal to work with kernels starting with 2.6.32; the axis and button map ioctls return the size of the buffer used when everything goes well. Modified Paths: -------------- trunk/utils/evtest.c trunk/utils/ffcfstress.c trunk/utils/fftest.c trunk/utils/inputattach.c trunk/utils/jscal.c Modified: trunk/utils/evtest.c =================================================================== --- trunk/utils/evtest.c 2010-09-23 11:57:57 UTC (rev 2393) +++ trunk/utils/evtest.c 2010-09-23 12:00:54 UTC (rev 2394) @@ -317,7 +317,7 @@ return 1; } - if (ioctl(fd, EVIOCGVERSION, &version)) { + if (ioctl(fd, EVIOCGVERSION, &version) < 0) { perror("evtest: can't get version"); return 1; } Modified: trunk/utils/ffcfstress.c =================================================================== --- trunk/utils/ffcfstress.c 2010-09-23 11:57:57 UTC (rev 2393) +++ trunk/utils/ffcfstress.c 2010-09-23 12:00:54 UTC (rev 2394) @@ -193,7 +193,7 @@ effect.u.constant.envelope.fade_level=0; /* Upload effect */ - if (ioctl(device_handle,EVIOCSFF,&effect)==-1) { + if (ioctl(device_handle,EVIOCSFF,&effect)<0) { fprintf(stderr,"ERROR: uploading effect failed (%s) [%s:%d]\n", strerror(errno),__FILE__,__LINE__); exit(1); @@ -219,7 +219,7 @@ /* Delete effect */ if (stop_and_play && effect.id!=-1) { - if (ioctl(device_handle,EVIOCRMFF,effect.id)==-1) { + if (ioctl(device_handle,EVIOCRMFF,effect.id)<0) { fprintf(stderr,"ERROR: removing effect failed (%s) [%s:%d]\n", strerror(errno),__FILE__,__LINE__); exit(1); @@ -236,7 +236,7 @@ effect.u.constant.envelope.fade_level=(short)(force*32767.0); /* only to be safe */ /* Upload effect */ - if (ioctl(device_handle,EVIOCSFF,&effect)==-1) { + if (ioctl(device_handle,EVIOCSFF,&effect)<0) { perror("upload effect"); /* We do not exit here. Indeed, too frequent updates may be * refused, but that is not a fatal error */ Modified: trunk/utils/fftest.c =================================================================== --- trunk/utils/fftest.c 2010-09-23 11:57:57 UTC (rev 2393) +++ trunk/utils/fftest.c 2010-09-23 12:00:54 UTC (rev 2394) @@ -86,7 +86,7 @@ printf("Device %s opened\n", device_file_name); /* Query device */ - if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(unsigned long) * 4), features) == -1) { + if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(unsigned long) * 4), features) < 0) { perror("Ioctl query"); exit(1); } @@ -107,7 +107,7 @@ printf("\nNumber of simultaneous effects: "); - if (ioctl(fd, EVIOCGEFFECTS, &n_effects) == -1) { + if (ioctl(fd, EVIOCGEFFECTS, &n_effects) < 0) { perror("Ioctl number of effects"); } @@ -131,7 +131,7 @@ effects[0].replay.length = 20000; /* 20 seconds */ effects[0].replay.delay = 0; - if (ioctl(fd, EVIOCSFF, &effects[0]) == -1) { + if (ioctl(fd, EVIOCSFF, &effects[0]) < 0) { perror("Upload effects[0]"); } @@ -149,7 +149,7 @@ effects[1].replay.length = 20000; /* 20 seconds */ effects[1].replay.delay = 0; - if (ioctl(fd, EVIOCSFF, &effects[1]) == -1) { + if (ioctl(fd, EVIOCSFF, &effects[1]) < 0) { perror("Upload effects[1]"); } @@ -168,7 +168,7 @@ effects[2].replay.length = 20000; /* 20 seconds */ effects[2].replay.delay = 0; - if (ioctl(fd, EVIOCSFF, &effects[2]) == -1) { + if (ioctl(fd, EVIOCSFF, &effects[2]) < 0) { perror("Upload effects[2]"); } @@ -187,7 +187,7 @@ effects[3].replay.length = 20000; /* 20 seconds */ effects[3].replay.delay = 0; - if (ioctl(fd, EVIOCSFF, &effects[3]) == -1) { + if (ioctl(fd, EVIOCSFF, &effects[3]) < 0) { perror("Upload effects[3]"); } @@ -199,7 +199,7 @@ effects[4].replay.length = 5000; effects[4].replay.delay = 1000; - if (ioctl(fd, EVIOCSFF, &effects[4]) == -1) { + if (ioctl(fd, EVIOCSFF, &effects[4]) < 0) { perror("Upload effects[4]"); } @@ -211,7 +211,7 @@ effects[5].replay.length = 5000; effects[5].replay.delay = 0; - if (ioctl(fd, EVIOCSFF, &effects[5]) == -1) { + if (ioctl(fd, EVIOCSFF, &effects[5]) < 0) { perror("Upload effects[5]"); } Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2010-09-23 11:57:57 UTC (rev 2393) +++ trunk/utils/inputattach.c 2010-09-23 12:00:54 UTC (rev 2394) @@ -281,10 +281,10 @@ int count, line; /* Turn DTR off, otherwise the Twiddler won't send any data. */ - if (ioctl(fd, TIOCMGET, &line)) + if (ioctl(fd, TIOCMGET, &line) < 0) return -1; line &= ~TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &line)) + if (ioctl(fd, TIOCMSET, &line) < 0) return -1; /* @@ -648,14 +648,14 @@ } ldisc = N_MOUSE; - if (ioctl(fd, TIOCSETD, &ldisc)) { + if (ioctl(fd, TIOCSETD, &ldisc) < 0) { fprintf(stderr, "inputattach: can't set line discipline\n"); return EXIT_FAILURE; } devt = type->type | (id << 8) | (extra << 16); - if (ioctl(fd, SPIOCSTYPE, &devt)) { + if (ioctl(fd, SPIOCSTYPE, &devt) < 0) { fprintf(stderr, "inputattach: can't set device type\n"); return EXIT_FAILURE; } Modified: trunk/utils/jscal.c =================================================================== --- trunk/utils/jscal.c 2010-09-23 11:57:57 UTC (rev 2393) +++ trunk/utils/jscal.c 2010-09-23 12:00:54 UTC (rev 2394) @@ -179,15 +179,15 @@ { int i,j; - if (ioctl(fd, JSIOCGAXES, &axes)) { + if (ioctl(fd, JSIOCGAXES, &axes) < 0) { perror("jscal: error getting axes"); exit(1); } - if (ioctl(fd, JSIOCGBUTTONS, &buttons)) { + if (ioctl(fd, JSIOCGBUTTONS, &buttons) < 0) { perror("jscal: error getting buttons"); exit(1); } - if (ioctl(fd, JSIOCGCORR, &corr)) { + if (ioctl(fd, JSIOCGCORR, &corr) < 0) { perror("jscal: error getting correction"); exit(1); } @@ -218,7 +218,7 @@ corr[i].prec = 0; } - if (ioctl(fd, JSIOCSCORR, &corr)) { + if (ioctl(fd, JSIOCSCORR, &corr) < 0) { perror("jscal: error setting correction"); exit(1); } @@ -324,7 +324,7 @@ putchar('\n'); - if (ioctl(fd, JSIOCSCORR, &corr)) { + if (ioctl(fd, JSIOCSCORR, &corr) < 0) { perror("jscal: error setting correction"); exit(1); } @@ -342,19 +342,19 @@ { int i; - if (ioctl(fd, JSIOCGAXES, &axes)) { + if (ioctl(fd, JSIOCGAXES, &axes) < 0) { perror("jscal: error getting axes"); exit(1); } - if (ioctl(fd, JSIOCGBUTTONS, &buttons)) { + if (ioctl(fd, JSIOCGBUTTONS, &buttons) < 0) { perror("jscal: error getting buttons"); exit(1); } - if (ioctl(fd, JSIOCGAXMAP, &axmap)) { + if (ioctl(fd, JSIOCGAXMAP, &axmap) < 0) { perror("jscal: error getting axis map"); exit(1); } - if (ioctl(fd, JSIOCGBTNMAP, &buttonmap)) { + if (ioctl(fd, JSIOCGBTNMAP, &buttonmap) < 0) { buttons=0; } @@ -376,7 +376,7 @@ void get_axmap2(void) { - if (ioctl(fd, JSIOCGAXMAP, &axmap2)) { + if (ioctl(fd, JSIOCGAXMAP, &axmap2) < 0) { perror("jscal: error getting axis map"); exit(1); } @@ -400,7 +400,7 @@ ax[i]=axmes[(axmap[i])]; } //Read again current callibration settings - if (ioctl(fd, JSIOCGCORR, &corr)) { + if (ioctl(fd, JSIOCGCORR, &corr) < 0) { perror("jscal: error getting correction"); exit(1); } @@ -408,7 +408,7 @@ for (i = 0; i < axes; i++) { corr_tmp[i]=corr[(ax[i])]; } - if (ioctl(fd, JSIOCSCORR, &corr_tmp)) { + if (ioctl(fd, JSIOCSCORR, &corr_tmp) < 0) { perror("jscal: error setting correction"); exit(1); } @@ -419,15 +419,15 @@ { int i,j; - if (ioctl(fd, JSIOCGAXES, &axes)) { + if (ioctl(fd, JSIOCGAXES, &axes) < 0) { perror("jscal: error getting axes"); exit(1); } - if (ioctl(fd, JSIOCGBUTTONS, &buttons)) { + if (ioctl(fd, JSIOCGBUTTONS, &buttons) < 0) { perror("jscal: error getting buttons"); exit(1); } - if (ioctl(fd, JSIOCGCORR, &corr)) { + if (ioctl(fd, JSIOCGCORR, &corr) < 0) { perror("jscal: error getting correction"); exit(1); } @@ -451,11 +451,11 @@ int axis_mapping = 0; int btn_mapping = 0; - if (ioctl(fd, JSIOCGAXES, &axes)) { + if (ioctl(fd, JSIOCGAXES, &axes) < 0) { perror("jscal: error getting axes"); exit(1); } - if (ioctl(fd, JSIOCGBUTTONS, &buttons)) { + if (ioctl(fd, JSIOCGBUTTONS, &buttons) < 0) { perror("jscal: error getting buttons"); exit(1); } @@ -536,7 +536,7 @@ get_axmap2(); // Apply the new axis map - if (ioctl(fd, JSIOCSAXMAP, &axmap)) { + if (ioctl(fd, JSIOCSAXMAP, &axmap) < 0) { perror("jscal: error setting axis map"); exit(1); } @@ -545,7 +545,7 @@ correct_axes(); if (btns_on_cl!=0){ - if (ioctl(fd, JSIOCSBTNMAP, &buttonmap)) { + if (ioctl(fd, JSIOCSBTNMAP, &buttonmap) < 0) { perror("jscal: error setting button map"); exit(1); } @@ -557,7 +557,7 @@ int i,j; int t = 0; - if (ioctl(fd, JSIOCGAXES, &axes)) { + if (ioctl(fd, JSIOCGAXES, &axes) < 0) { perror("jscal: error getting axes"); exit(1); } @@ -618,7 +618,7 @@ exit(1); } - if (ioctl(fd, JSIOCSCORR, &corr)) { + if (ioctl(fd, JSIOCSCORR, &corr) < 0) { perror("jscal: error setting correction"); exit(1); } @@ -629,12 +629,12 @@ int i; struct js_event ev; - if (ioctl(fd, JSIOCGAXES, &axes)) { + if (ioctl(fd, JSIOCGAXES, &axes) < 0) { perror("jscal: error getting axes"); exit(1); } - if (ioctl(fd, JSIOCGBUTTONS, &buttons)) { + if (ioctl(fd, JSIOCGBUTTONS, &buttons) < 0) { perror("jscal: error getting buttons"); exit(1); } @@ -735,7 +735,7 @@ exit(1); } - if (ioctl(fd, JSIOCGVERSION, &version)) { + if (ioctl(fd, JSIOCGVERSION, &version) < 0) { perror("jscal: error getting version"); exit(1); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2010-09-23 12:02:08
|
Revision: 2395 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2395&view=rev Author: skitt Date: 2010-09-23 12:02:02 +0000 (Thu, 23 Sep 2010) Log Message: ----------- Fix SDL-related warnings. Modified Paths: -------------- trunk/utils/Makefile trunk/utils/ffmvforce.c Modified: trunk/utils/Makefile =================================================================== --- trunk/utils/Makefile 2010-09-23 12:00:54 UTC (rev 2394) +++ trunk/utils/Makefile 2010-09-23 12:02:02 UTC (rev 2395) @@ -41,8 +41,7 @@ $(RM) *.o *.swp $(PROGRAMS) *.orig *.rej map *~ ffcfstress: ffcfstress.c - $(CC) -O2 -fno-implement-inlines -funsigned-char \ - -lm ffcfstress.c -o ffcfstress + $(CC) -O2 -funsigned-char -lm ffcfstress.c -o ffcfstress ffmvforce.o: ffmvforce.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $^ -o $@ `sdl-config --cflags` Modified: trunk/utils/ffmvforce.c =================================================================== --- trunk/utils/ffmvforce.c 2010-09-23 12:00:54 UTC (rev 2394) +++ trunk/utils/ffmvforce.c 2010-09-23 12:02:02 UTC (rev 2395) @@ -147,7 +147,7 @@ fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError()); exit(1); } - on_exit(SDL_Quit, NULL); + atexit(SDL_Quit); screen = SDL_SetVideoMode(WIN_W, WIN_H, 0, SDL_SWSURFACE); if (screen == NULL) { fprintf(stderr, "Could not set video mode: %s\n", SDL_GetError()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2010-11-04 06:15:59
|
Revision: 2398 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2398&view=rev Author: skitt Date: 2010-11-04 06:15:52 +0000 (Thu, 04 Nov 2010) Log Message: ----------- Dmitry Torokhov has merged into his "next" tree a patch to support ps2 multiplexers on TQM85xx boards. Attached is a patch that adds necessary support to inputattach. Signed-off-by: Dmitry Eremin-Solenikov <dba...@gm...> Modified Paths: -------------- trunk/utils/inputattach.c trunk/utils/serio-ids.h Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2010-09-27 05:14:20 UTC (rev 2397) +++ trunk/utils/inputattach.c 2010-11-04 06:15:52 UTC (rev 2398) @@ -536,6 +536,9 @@ { "--fujitsu", "-fjt", "Fujitsu serial touchscreen", B9600, CS8, SERIO_FUJITSU, 0x00, 0x00, 1, fujitsu_init }, +{ "--ps2mult", "-ps2m", "PS/2 serial multiplexer", + B57600, CS8, + SERIO_PS2MULT, 0x00, 0x00, 1, NULL }, { "--dump", "-dump", "Just enable device", B2400, CS8, 0, 0x00, 0x00, 0, dump_init }, Modified: trunk/utils/serio-ids.h =================================================================== --- trunk/utils/serio-ids.h 2010-09-27 05:14:20 UTC (rev 2397) +++ trunk/utils/serio-ids.h 2010-11-04 06:15:52 UTC (rev 2398) @@ -122,5 +122,8 @@ #ifndef SERIO_W8001 # define SERIO_W8001 0x39 #endif +#ifndef SERIO_PSMULT +# define SERIO_PS2MULT 0x3c +#endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2011-03-09 16:54:37
|
Revision: 2406 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2406&view=rev Author: skitt Date: 2011-03-09 16:54:30 +0000 (Wed, 09 Mar 2011) Log Message: ----------- Add jscal-store/restore, and provide an installation target in the Makefile. Modified Paths: -------------- trunk/utils/Makefile Added Paths: ----------- trunk/utils/extract trunk/utils/filter trunk/utils/ident trunk/utils/jscal-restore.in trunk/utils/jscal-store.in Modified: trunk/utils/Makefile =================================================================== --- trunk/utils/Makefile 2011-03-06 21:07:05 UTC (rev 2405) +++ trunk/utils/Makefile 2011-03-09 16:54:30 UTC (rev 2406) @@ -33,8 +33,10 @@ CFLAGS = -g -O2 -Wall -I../linux/include PROGRAMS = evtest inputattach jstest jscal fftest ffmvforce ffset \ - ffcfstress # acceltest + ffcfstress jscal-restore jscal-store # acceltest +PREFIX ?= /usr/local + compile: $(PROGRAMS) clean: @@ -65,3 +67,16 @@ acceltest: acceltest.c $(CC) $(CFLAGS) $(CPPFLAGS) $^ -lm -o $@ + +jscal-restore: jscal-restore.in + sed "s^@@PREFIX@@^$(PREFIX)^g" < $^ > $@ + +jscal-store: jscal-store.in + sed "s^@@PREFIX@@^$(PREFIX)^g" < $^ > $@ + +install: compile + install $(PROGRAMS) $(DESTDIR)$(PREFIX)/bin + install -d $(DESTDIR)$(PREFIX)/share/joystick + install extract filter ident $(DESTDIR)$(PREFIX)/share/joystick + +.PHONY: compile clean install Added: trunk/utils/extract =================================================================== --- trunk/utils/extract (rev 0) +++ trunk/utils/extract 2011-03-09 16:54:30 UTC (rev 2406) @@ -0,0 +1,56 @@ +#!/usr/bin/awk -f + +# Extracts the settings for a given joystick from the joystick +# parameter file, matching the contents of the kernel, name, serial, +# vendor and product variables (typically specified on the command +# line), repectively kernel device, joystick name, joystick serial +# number, USB vendor code, USB product code. +# The exit code is 0 if a section was found, 1 otherwise. If multiple +# sections match, only the first is kept. + +BEGIN { + FS = "\""; + seckernel = ""; + secname = ""; + secserial = ""; + secvendor = ""; + secproduct = ""; +} + +/^DEVICE=/ { + seckernel = $2; +} + +/^NAME=/ { + secname = $2; +} + +/^SERIAL=/ { + secserial = $2; +} + +/^VENDOR=/ { + secvendor = $2; +} + +/^PRODUCT/ { + secproduct = $2; +} + +/(^js)|(^$)/ { + # Command or empty line, ends the match criteria for a given + # section + if ((kernel == "" || seckernel == kernel) && + (name == "" || secname == name) && + (serial == "" || secserial == serial) && + (vendor == "" || secvendor == vendor) && + (product == "" || secproduct == product)) { + # The section matches, output the command or exit if we've + # reached the end of the section + if ($0 ~ /^js/) { + print $0; + } else { + exit 0; + } + } +} Property changes on: trunk/utils/extract ___________________________________________________________________ Added: svn:executable + * Added: trunk/utils/filter =================================================================== --- trunk/utils/filter (rev 0) +++ trunk/utils/filter 2011-03-09 16:54:30 UTC (rev 2406) @@ -0,0 +1,79 @@ +#!/usr/bin/awk -f + +# Filters the joystick parameter file, keeping everything but sections +# matching the contents of the kernel, name, serial, vendor and +# product variables (typically specified on the command line), +# repectively kernel device, joystick name, joystick serial number, +# USB vendor code, USB product code. + +BEGIN { + FS = "\""; + seckernel = ""; + secname = ""; + secserial = ""; + secvendor = ""; + secproduct = ""; + secoutput = 0; +} + +/^DEVICE=/ { + seckernel = $2; +} + +/^NAME=/ { + secname = $2; +} + +/^SERIAL=/ { + secserial = $2; +} + +/^VENDOR=/ { + secvendor = $2; +} + +/^PRODUCT/ { + secproduct = $2; +} + +/(^js)|(^$)/ { + # Command or empty line, ends the match criteria for a given + # section + if ((kernel == "" || seckernel == kernel) && + (name == "" || secname == name) && + (serial == "" || secserial == serial) && + (vendor == "" || secvendor == vendor) && + (product == "" || secproduct == product)) { + # The section matches, skip it + } else { + # The section doesn't match, output it + if (secoutput == 0) { + if (seckernel != "") { + print "DEVICE=\"" seckernel "\""; + } + if (secname != "") { + print "NAME=\"" secname "\""; + } + if (secserial != "") { + print "SERIAL=\"" secserial "\""; + } + if (secvendor != "") { + print "VENDOR=\"" secvendor "\""; + } + if (secproduct != "") { + print "PRODUCT=\"" secproduct "\""; + } + secoutput = 1; + } + print $0; + if ($0 ~ /$^/) { + # New section, clear the section information + secoutput = 0; + seckernel = ""; + secname = ""; + secserial = ""; + secvendor = ""; + secproduct = ""; + } + } +} Property changes on: trunk/utils/filter ___________________________________________________________________ Added: svn:executable + * Added: trunk/utils/ident =================================================================== --- trunk/utils/ident (rev 0) +++ trunk/utils/ident 2011-03-09 16:54:30 UTC (rev 2406) @@ -0,0 +1,70 @@ +#!/usr/bin/awk -f + +BEGIN { + FS = "\""; + kernel = ""; + name = ""; + serial = ""; + vendor = ""; + product = ""; + seckernel = ""; + secname = ""; + secserial = ""; + secvendor = ""; + secproduct = ""; +} + +/KERNEL==/ { + kernel = $2; +} + +/KERNELS==/ { + seckernel = $2; +} + +/ATTRS{name}/ { + secname = $2; +} + +/ATTRS{serial}/ { + secserial = $2; +} + +/ATTRS{idVendor}/ { + secvendor = $2; +} + +/ATTRS{idProduct}/ { + secproduct = $2; +} + +/$^/ { + # New section, check the values remembered from the previous + # If the section defined a name, and we don't have one, and the + # section described an input device, store the name and serial + if (match(seckernel, "input") != 0 && secname != "" && name == "") { + name = secname; + serial = secserial; + } + # If the section defined a vendor (for USB devices), and we don't + # have one, store the vendor and product + if (secvendor != "" && vendor == "") { + vendor = secvendor; + product = secproduct; + } + + # Clear all section values before processing next section + seckernel = ""; + secname = ""; + secserial = ""; + secvendor = ""; + secproduct = ""; +} + +END { + print "DEVICE=\"" kernel "\""; + print "NAME=\"" name "\""; + print "SERIAL=\"" serial "\""; + print "VENDOR=\"" vendor "\""; + print "PRODUCT=\"" product "\""; +} Property changes on: trunk/utils/ident ___________________________________________________________________ Added: svn:executable + * Added: trunk/utils/jscal-restore.in =================================================================== --- trunk/utils/jscal-restore.in (rev 0) +++ trunk/utils/jscal-restore.in 2011-03-09 16:54:30 UTC (rev 2406) @@ -0,0 +1,33 @@ +#!/bin/sh + +if [ ! -x /sbin/udevadm ]; then + echo Restoring joystick configuration requires udev! >&2 +fi + +ident=$(mktemp) +/sbin/udevadm info -a -n $1 | @@PREFIX@@/share/joystick/ident > $ident +. $ident +rm -f $ident + +STORE=/var/lib/joystick/joystick.state + +# Retrieve the applicable commands +commands=$(mktemp) +if [ -f $STORE ]; then + if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then + # Use the device name only + @@PREFIX@@/share/joystick/extract kernel="$DEVICE" < $STORE > $commands + else + @@PREFIX@@/share/joystick/extract name="$NAME" serial="$SERIAL" vendor="$VENDOR" product="$PRODUCT" < $STORE > $commands + fi +fi + +# Run the commands if any +if [ -f $commands ] && [ ! -z "$(cat $commands)" ]; then + while read command; do + $command $1 + done < $commands +fi + +# Delete the generated file +rm -f $commands Property changes on: trunk/utils/jscal-restore.in ___________________________________________________________________ Added: svn:executable + * Added: trunk/utils/jscal-store.in =================================================================== --- trunk/utils/jscal-store.in (rev 0) +++ trunk/utils/jscal-store.in 2011-03-09 16:54:30 UTC (rev 2406) @@ -0,0 +1,63 @@ +#!/bin/sh + +# Stores the current calibration settings for the given joystick +# (materialized by its device). The calibration settings are stored +# using the joystick's name and serial number if available, and its +# vendor and product codes if it's a USB device. If none of these can +# be determined, the settings are stored against the device name. + +if [ -z "$1" ]; then + echo "Usage: $0 {device}" + echo "Stores the device's calibration for future use." + exit 1 +fi + +if [ ! -x /sbin/udevadm ]; then + echo Storing joystick configuration requires udev! >&2 +fi + +ident=$(mktemp) +/sbin/udevadm info -a -n $1 | @@PREFIX@@/share/joystick/ident > $ident +. $ident +rm $ident + +STORE=/var/lib/joystick/joystick.state + +# Filter the existing file +if [ -f $STORE ]; then + if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then + echo "No product name or vendor available, calibration will be stored for the" + echo "given device name ($DEVICE) only!" + @@PREFIX@@/share/joystick/filter kernel="$DEVICE" < $STORE > $STORE.new + else + @@PREFIX@@/share/joystick/filter name="$NAME" serial="$SERIAL" vendor="$VENDOR" product="$PRODUCT" < $STORE > $STORE.new + fi +fi + +# Append the new calibration information +if [ -f $STORE.new ] && [ ! -z "$(cat $STORE.new)" ]; then + echo >> $STORE.new +fi +if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then + echo "DEVICE=\"$DEVICE\"" >> $STORE.new +fi +if [ ! -z "$NAME" ]; then + echo "NAME=\"$NAME\"" >> $STORE.new +fi +if [ ! -z "$SERIAL" ]; then + echo "SERIAL=\"$SERIAL\"" >> $STORE.new +fi +if [ ! -z "$VENDOR" ]; then + echo "VENDOR=\"$VENDOR\"" >> $STORE.new +fi +if [ ! -z "$PRODUCT" ]; then + echo "PRODUCT=\"$PRODUCT\"" >> $STORE.new +fi +jscal -p $1 | cut -d' ' -f-3 >> $STORE.new +jscal -q $1 | cut -d' ' -f-3 >> $STORE.new + +if [ -f $STORE ]; then + mv $STORE $STORE.old +fi +mv $STORE.new $STORE +rm -f $STORE.old Property changes on: trunk/utils/jscal-store.in ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2011-04-02 12:45:26
|
Revision: 2412 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2412&view=rev Author: skitt Date: 2011-04-02 12:45:20 +0000 (Sat, 02 Apr 2011) Log Message: ----------- Update FSF address and remove obsolete contact info. Modified Paths: -------------- trunk/utils/Makefile trunk/utils/evtest.c trunk/utils/ffcfstress.c trunk/utils/ffmvforce.c trunk/utils/ffset.c trunk/utils/fftest.c trunk/utils/inputattach.c trunk/utils/jscal.c trunk/utils/jstest.c trunk/utils/scancodes.h Modified: trunk/utils/Makefile =================================================================== --- trunk/utils/Makefile 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/Makefile 2011-04-02 12:45:20 UTC (rev 2412) @@ -3,10 +3,9 @@ # # Makefile for Linux input utilities # -# (c) 1998-2000 Vojtech Pavlik +# © 1998-2000 Vojtech Pavlik (sponsored by SuSE) +# © 2008-2011 Stephen Kitt <st...@sk...> # -# Sponsored by SuSE -# # 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 @@ -19,13 +18,10 @@ # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA. # -# Should you need to contact me, the author, you can do so either by -# e-mail - mail your message to <vo...@uc...>, or by paper mail: -# Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic # -# # Edit the options below to suit your needs # Modified: trunk/utils/evtest.c =================================================================== --- trunk/utils/evtest.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/evtest.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -19,11 +19,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Should you need to contact me, the author, you can do so either by - * e-mail - mail your message to <vo...@uc...>, or by paper mail: - * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. */ #include <stdint.h> Modified: trunk/utils/ffcfstress.c =================================================================== --- trunk/utils/ffcfstress.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/ffcfstress.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -17,7 +17,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. */ #include <linux/input.h> Modified: trunk/utils/ffmvforce.c =================================================================== --- trunk/utils/ffmvforce.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/ffmvforce.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -19,7 +19,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. * * You can contact the author by email at this address: * Johann Deneux <de...@if...> Modified: trunk/utils/ffset.c =================================================================== --- trunk/utils/ffset.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/ffset.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -16,7 +16,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. * * You can contact the author by email at this address: * Johann Deneux <de...@if...> Modified: trunk/utils/fftest.c =================================================================== --- trunk/utils/fftest.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/fftest.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -18,7 +18,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. * * You can contact the author by email at this address: * Johann Deneux <de...@if...> Modified: trunk/utils/inputattach.c =================================================================== --- trunk/utils/inputattach.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/inputattach.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -28,11 +28,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Should you need to contact me, the author, you can do so either by - * e-mail - mail your message to <vo...@uc...>, or by paper mail: - * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. */ #include <ctype.h> Modified: trunk/utils/jscal.c =================================================================== --- trunk/utils/jscal.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/jscal.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -23,11 +23,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Should you need to contact me, the author, you can do so either by - * e-mail - mail your message to <vo...@uc...>, or by paper mail: - * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. */ #include <sys/ioctl.h> Modified: trunk/utils/jstest.c =================================================================== --- trunk/utils/jstest.c 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/jstest.c 2011-04-02 12:45:20 UTC (rev 2412) @@ -27,11 +27,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Should you need to contact me, the author, you can do so either by - * e-mail - mail your message to <vo...@uc...>, or by paper mail: - * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. */ #include <sys/ioctl.h> Modified: trunk/utils/scancodes.h =================================================================== --- trunk/utils/scancodes.h 2011-03-30 22:15:29 UTC (rev 2411) +++ trunk/utils/scancodes.h 2011-04-02 12:45:20 UTC (rev 2412) @@ -17,11 +17,8 @@ * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Should you need to contact me, the author, you can do so either by - * e-mail - mail your message to <vo...@uc...>, or by paper mail: - * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2011-04-03 17:24:38
|
Revision: 2413 http://linuxconsole.svn.sourceforge.net/linuxconsole/?rev=2413&view=rev Author: skitt Date: 2011-04-03 17:24:32 +0000 (Sun, 03 Apr 2011) Log Message: ----------- Drop acceltest.c, it tests framebuffer functions which are no longer available. Modified Paths: -------------- trunk/utils/Makefile Removed Paths: ------------- trunk/utils/acceltest.c Modified: trunk/utils/Makefile =================================================================== --- trunk/utils/Makefile 2011-04-02 12:45:20 UTC (rev 2412) +++ trunk/utils/Makefile 2011-04-03 17:24:32 UTC (rev 2413) @@ -29,7 +29,7 @@ CFLAGS = -g -O2 -Wall -I../linux/include PROGRAMS = evtest inputattach jstest jscal fftest ffmvforce ffset \ - ffcfstress jscal-restore jscal-store # acceltest + ffcfstress jscal-restore jscal-store PREFIX ?= /usr/local @@ -61,9 +61,6 @@ gencodes: gencodes.c scancodes.h $(CC) $(CFLAGS) $(CPPFLAGS) gencodes.c -o gencodes -acceltest: acceltest.c - $(CC) $(CFLAGS) $(CPPFLAGS) $^ -lm -o $@ - jscal-restore: jscal-restore.in sed "s^@@PREFIX@@^$(PREFIX)^g" < $^ > $@ Deleted: trunk/utils/acceltest.c =================================================================== --- trunk/utils/acceltest.c 2011-04-02 12:45:20 UTC (rev 2412) +++ trunk/utils/acceltest.c 2011-04-03 17:24:32 UTC (rev 2413) @@ -1,170 +0,0 @@ -/* $Header$ */ -/* - * Copyright (C) 2001 Romain Dolbeau <do...@ir...> - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive for - * more details. - * - */ - -#include <stdio.h> - -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -extern char *optarg; -extern int optind, opterr, optopt; - -#include <errno.h> -int errno; - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sys/ioctl.h> -#include <setjmp.h> -#include <sys/mman.h> -#include <asm/page.h> -#include <asm/byteorder.h> - -#include <linux/fb.h> -#include <linux/fbvid.h> - - - -int -main(int argc, char **argv) -{ - char fbdevice[256]; - int fbnum = 0, opnu = 0, sx = 128, sy = 128, wi = 64, he = 64, color = 0xFFFFFFFF, nsx, nsy, count = 0; - unsigned char *fb_mem = NULL; - int fb_mem_offset = 0, fbd, r; - char *tmpoptarg; - struct fb_var_screeninfo fb_var; - struct fb_fix_screeninfo fb_fix; - struct fb_fillrect fbfr; - struct fb_copyarea fbca; - - while ((opnu = getopt(argc, argv, "f:x:y:w:h:c:?")) != EOF) - { - switch(opnu) - { - case 'f': - tmpoptarg = optarg; - if (!(strncmp(tmpoptarg, "/dev/", 5))) - tmpoptarg += 5; - if (!(strncmp(tmpoptarg, "fb", 2))) - tmpoptarg += 2; - fbnum = atoi(tmpoptarg); - break; - case 'x': - sx = atoi(optarg); - break; - case 'y': - sy = atoi(optarg); - break; - case 'w': - wi = atoi(optarg); - break; - case 'h': - he = atoi(optarg); - break; - case 'c': - color = atoi(optarg); - break; - case '?': - printf("Usage: %s [-f <fb_device>] [-x <initial_X>] [-y <initial_Y>] [-w <width>] [-h <height>] [-c <colour>]\n", argv[0]); - return(0); - default: - fprintf(stderr, "Warning: Unknown option \"%c\", try %s -?\n", opnu, argv[0]); - exit(1); - } - } - - fprintf(stderr, "Opening /dev/fb%d\n", fbnum); - - sprintf(fbdevice, "/dev/fb%d", fbnum); - fbd = open(fbdevice, O_RDWR); - - if (fbd < 0) - { - fprintf(stderr, "Couldn't open /dev/fb%d; errno: %d (%s)\n", fbnum, errno, strerror(errno)); - exit(1); - } - r = ioctl(fbd, FBIOGET_VSCREENINFO, &fb_var); - if (r < 0) - { - fprintf(stderr, "IOCTL FBIOGET_VSCREENINFO error: %d errno: %d (%s)\n", r, errno, strerror(errno)); - exit(1); - } - r = ioctl(fbd, FBIOGET_FSCREENINFO, &fb_fix); - if (r < 0) - { - fprintf(stderr, "IOCTL FBIOGET_FSCREENINFO error: %d errno: %d (%s)\n", r, errno, strerror(errno)); - exit(1); - } - /* map all FB memory */ - fb_mem_offset = (unsigned long)(fb_fix.smem_start) & (~PAGE_MASK); - fb_mem = mmap(NULL,fb_fix.smem_len+fb_mem_offset,PROT_WRITE,MAP_SHARED,fbd,0); - if (!fb_mem) - { - fprintf(stderr, "MMap of /dev/fb%d failed\n", fbnum); - exit(1); - } - if (((sx + wi) > fb_var.xres) || ((sy + he) > fb_var.yres)) - { - fprintf(stderr, "Rectangle too big for given offset (%dx%d+%d+%d, fb is %dx%d)", - he, wi, sx, sy, - fb_var.xres, fb_var.xres); - exit(1); - } - fprintf(stderr, "Filling rect with color 0x%x\n", color); - fbfr.dx = sx; - fbfr.dy = sy; - fbfr.width = wi; - fbfr.height = he; - fbfr.color = color; - fbfr.rop = ROP_COPY; - r = ioctl(fbd, FBIOPUT_FILLRECT, &fbfr); - if (r < 0) - { - fprintf(stderr, "IOCTL FBIOPUT_FILLRECT error: %d errno: %d (%s)\n", r, errno, strerror(errno)); - exit(1); - } - if ((sx == 0) || (sy == 0)) - { - fprintf(stderr, "Can't CopyArea, stop\n"); - return(0); - } - nsx = sx; nsy = sy; - fbca.width = wi + 1; - fbca.height = he + 1; - while (((nsx + wi) < fb_var.xres) || - ((nsy + he) < fb_var.yres)) - { - count++; - if ((nsx + wi) < fb_var.xres) - { - sx = nsx; - nsx++; - } - if ((nsy + he) < fb_var.yres) - { - sy = nsy; - nsy++; - } - fbca.sx = sx - 1; - fbca.sy = sy - 1; - fbca.dx = nsx; - fbca.dy = nsy; - r = ioctl(fbd, FBIOPUT_COPYAREA, &fbca); - if (r < 0) - { - fprintf(stderr, "IOCTL FBIOPUT_FILLRECT #%d error: %d errno: %d (%s)\n", - count, r, errno, strerror(errno)); - exit(1); - } - } - return(0); -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |