inputattach: update to latest version from dtor's repo.
http://mirror.leaseweb.com/kernel/people/dtor/inputattach.c
This commit is contained in:
parent
a65e0d90cc
commit
b7df155dcb
3
gpm.spec
3
gpm.spec
@ -8,6 +8,7 @@ URL: http://www.nico.schottelius.org/software/gpm/
|
|||||||
Source: http://www.nico.schottelius.org/software/gpm/archives/%{name}-%{version}.tar.lzma
|
Source: http://www.nico.schottelius.org/software/gpm/archives/%{name}-%{version}.tar.lzma
|
||||||
Source1: gpm.service
|
Source1: gpm.service
|
||||||
Source2: inputattach.c
|
Source2: inputattach.c
|
||||||
|
Source3: serio-ids.h
|
||||||
Patch1: gpm-1.20.6-multilib.patch
|
Patch1: gpm-1.20.6-multilib.patch
|
||||||
Patch2: gpm-1.20.1-lib-silent.patch
|
Patch2: gpm-1.20.1-lib-silent.patch
|
||||||
Patch3: gpm-1.20.3-gcc4.3.patch
|
Patch3: gpm-1.20.3-gcc4.3.patch
|
||||||
@ -79,7 +80,7 @@ autoreconf
|
|||||||
%build
|
%build
|
||||||
%configure
|
%configure
|
||||||
make %{?_smp_mflags}
|
make %{?_smp_mflags}
|
||||||
%__cc $RPM_OPT_FLAGS -o inputattach %{SOURCE2}
|
%__cc $RPM_OPT_FLAGS -o inputattach %{SOURCE2} %{SOURCE3}
|
||||||
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
|
433
inputattach.c
433
inputattach.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: inputattach.c,v 1.2 2007/04/02 14:18:54 tjanouse Exp $
|
* $Id: inputattach.c,v 1.24 2006/02/08 12:19:31 vojtech Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999-2000 Vojtech Pavlik
|
* Copyright (c) 1999-2000 Vojtech Pavlik
|
||||||
*
|
*
|
||||||
@ -46,10 +46,13 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.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;
|
struct timeval tv;
|
||||||
fd_set set;
|
fd_set set;
|
||||||
@ -60,15 +63,16 @@ int readchar(int fd, unsigned char *c, int timeout)
|
|||||||
FD_ZERO(&set);
|
FD_ZERO(&set);
|
||||||
FD_SET(fd, &set);
|
FD_SET(fd, &set);
|
||||||
|
|
||||||
if (!select(fd+1, &set, NULL, NULL, &tv)) return -1;
|
if (!select(fd + 1, &set, NULL, NULL, &tv))
|
||||||
if (read(fd, c, 1) != 1) return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (read(fd, c, 1) != 1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setline(int fd, int flags, int speed)
|
||||||
|
|
||||||
void setline(int fd, int flags, int speed)
|
|
||||||
{
|
{
|
||||||
struct termios t;
|
struct termios t;
|
||||||
|
|
||||||
@ -87,10 +91,11 @@ void setline(int fd, int flags, int speed)
|
|||||||
tcsetattr(fd, TCSANOW, &t);
|
tcsetattr(fd, TCSANOW, &t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int logitech_command(int fd, char *c)
|
static int logitech_command(int fd, char *c)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char d;
|
unsigned char d;
|
||||||
|
|
||||||
for (i = 0; c[i]; i++) {
|
for (i = 0; c[i]; i++) {
|
||||||
write(fd, c + i, 1);
|
write(fd, c + i, 1);
|
||||||
if (readchar(fd, &d, 1000))
|
if (readchar(fd, &d, 1000))
|
||||||
@ -101,27 +106,32 @@ int logitech_command(int fd, char *c)
|
|||||||
return 0;
|
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);
|
write(fd, "m3\rpBB\rz\r", 9);
|
||||||
return 0;
|
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);
|
setline(fd, CS8, B4800);
|
||||||
return 0;
|
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;
|
unsigned char b = 0;
|
||||||
|
|
||||||
while (!readchar(fd, &b, timeout)) {
|
while (!readchar(fd, &b, timeout)) {
|
||||||
if (b == 0x0a) continue;
|
if (b == 0x0a)
|
||||||
|
continue;
|
||||||
*d++ = b;
|
*d++ = b;
|
||||||
if (b == c) break;
|
if (b == c)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*d = 0;
|
*d = 0;
|
||||||
@ -129,7 +139,7 @@ int spaceball_waitchar(int fd, unsigned char c, unsigned char *d, int timeout)
|
|||||||
return -(b != c);
|
return -(b != c);
|
||||||
}
|
}
|
||||||
|
|
||||||
int spaceball_waitcmd(int fd, char c, char *d)
|
static int spaceball_waitcmd(int fd, char c, char *d)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -143,7 +153,7 @@ int spaceball_waitcmd(int fd, char c, char *d)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spaceball_cmd(int fd, char *c, char *d)
|
static int spaceball_cmd(int fd, char *c, char *d)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -161,9 +171,9 @@ int spaceball_cmd(int fd, char *c, char *d)
|
|||||||
#define SPACEBALL_2003C 4
|
#define SPACEBALL_2003C 4
|
||||||
#define SPACEBALL_3003C 7
|
#define SPACEBALL_3003C 7
|
||||||
#define SPACEBALL_4000FLX 8
|
#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];
|
char r[64];
|
||||||
|
|
||||||
@ -210,10 +220,10 @@ int spaceball_init(int fd, long *id, long *extra)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (spaceball_cmd(fd, "YS", r))
|
if (spaceball_cmd(fd, "YS", r))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (spaceball_cmd(fd, "M", r))
|
if (spaceball_cmd(fd, "M", r))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -226,7 +236,7 @@ int spaceball_init(int fd, long *id, long *extra)
|
|||||||
return 0;
|
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;
|
int i;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
@ -236,60 +246,69 @@ int stinger_init(int fd, long *id, long *extra)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) /* Check for Stinger */
|
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 -1;
|
||||||
|
|
||||||
return 0;
|
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);
|
setline(fd, CS8, B9600);
|
||||||
return 0;
|
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;
|
int i;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
unsigned char response[35] =
|
unsigned char response[35] = {
|
||||||
{ 0x16, 0x10, 0x02, 0x64, 0x5f, 0x69, 0x64, 0x00,
|
0x16, 0x10, 0x02, 0x64, 0x5f, 0x69, 0x64, 0x00,
|
||||||
0x00, 0x00, 0x0c, 0x6b, 0x79, 0x62, 0x64, 0x61,
|
0x00, 0x00, 0x0c, 0x6b, 0x79, 0x62, 0x64, 0x61,
|
||||||
0x70, 0x70, 0x6c, 0x00, 0x00, 0x00, 0x01, 0x6e,
|
0x70, 0x70, 0x6c, 0x00, 0x00, 0x00, 0x01, 0x6e,
|
||||||
0x6f, 0x66, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10,
|
0x6f, 0x66, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10,
|
||||||
0x03, 0xdd, 0xe7 };
|
0x03, 0xdd, 0xe7
|
||||||
|
};
|
||||||
|
|
||||||
for (i = 0; i < 35; i++)
|
for (i = 0; i < sizeof(response); i++)
|
||||||
if (readchar(fd, &c, 400) || (c != response[i]))
|
if (readchar(fd, &c, 400) || c != response[i])
|
||||||
return -1;
|
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];
|
unsigned char c[10];
|
||||||
int count, line;
|
int count, line;
|
||||||
|
|
||||||
/* Turn DTR off, otherwise the Twiddler won't send any data. */
|
/* 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;
|
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
|
* 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
|
* 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.
|
* 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
|
* 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 */
|
/* Read at most 5 bytes until we find one with the MSB set to 0 */
|
||||||
for (count = 0; count < 5; count++) {
|
for (count = 0; count < 5; count++) {
|
||||||
if (readchar(fd, c+0, 500)) return -1;
|
if (readchar(fd, c, 500))
|
||||||
if ((c[0] & 0x80) == 0) break;
|
return -1;
|
||||||
|
if ((c[0] & 0x80) == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 5) {
|
if (count == 5) {
|
||||||
@ -298,16 +317,16 @@ int twiddler_init(int fd, long *id, long *extra)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read remaining 4 bytes plus the full next data packet */
|
/* Read remaining 4 bytes plus the full next data packet */
|
||||||
for (count = 1; count < 10; count++) {
|
for (count = 1; count < 10; count++)
|
||||||
if (readchar(fd, c+count, 500)) return -1;
|
if (readchar(fd, c + count, 500))
|
||||||
}
|
return -1;
|
||||||
|
|
||||||
/* Check whether the bytes of both data packets obey the rules */
|
/* Check whether the bytes of both data packets obey the rules */
|
||||||
for (count = 1; count < 10; count++) {
|
for (count = 1; count < 10; count++) {
|
||||||
if ((count % 5 == 0 && (c[count] & 0x80) != 0)
|
if ((count % 5 == 0 && (c[count] & 0x80) != 0x00) ||
|
||||||
|| (count % 5 == 4 && (c[count] & 0xF0) != 0x80)
|
(count % 5 == 4 && (c[count] & 0xF0) != 0x80) ||
|
||||||
|| (count % 5 != 0 && (c[count] & 0x80) != 0x80)) {
|
(count % 5 != 0 && (c[count] & 0x80) != 0x80)) {
|
||||||
/* Invalid byte in data packet */
|
/* Invalid byte in data packet */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +334,35 @@ int twiddler_init(int fd, long *id, long *extra)
|
|||||||
return 0;
|
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;
|
unsigned char c, o = 0;
|
||||||
|
|
||||||
@ -337,133 +384,231 @@ int dump_init(int fd, long *id, long *extra)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct input_types {
|
struct input_types {
|
||||||
char name[16];
|
const char *name;
|
||||||
char name2[16];
|
const char *name2;
|
||||||
|
const char *desc;
|
||||||
int speed;
|
int speed;
|
||||||
int flags;
|
int flags;
|
||||||
unsigned long type;
|
unsigned long type;
|
||||||
unsigned long id;
|
unsigned long id;
|
||||||
unsigned long extra;
|
unsigned long extra;
|
||||||
int flush;
|
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",
|
||||||
{ "--sunkbd", "-skb", B1200, CS8, SERIO_SUNKBD, 0, 0, 1, NULL },
|
B1200, CS8,
|
||||||
{ "--lkkbd", "-lk", B4800, CS8|CSTOPB, SERIO_LKKBD, 0, 0, 1, NULL },
|
SERIO_SUNKBD, 0x00, 0x00, 1, NULL },
|
||||||
{ "--vsxxx-aa", "-vs", B4800, CS8|CSTOPB|PARENB|PARODD,SERIO_VSXXXAA, 0, 0, 1, NULL },
|
{ "--lkkbd", "-lk", "DEC LK201 / LK401 keyboards",
|
||||||
{ "--spaceorb", "-orb", B9600, CS8, SERIO_SPACEORB, 0, 0, 1, NULL },
|
B4800, CS8|CSTOPB,
|
||||||
{ "--spaceball", "-sbl", B9600, CS8, SERIO_SPACEBALL,0, 0, 0, spaceball_init },
|
SERIO_LKKBD, 0x00, 0x00, 1, NULL },
|
||||||
{ "--magellan", "-mag", B9600, CS8 | CSTOPB | CRTSCTS, SERIO_MAGELLAN, 0, 0, 1, magellan_init },
|
{ "--vsxxx-aa", "-vs",
|
||||||
{ "--warrior", "-war", B1200, CS7 | CSTOPB, SERIO_WARRIOR, 0, 0, 1, warrior_init },
|
"DEC VSXXX-AA / VSXXX-GA mouse and VSXXX-A tablet",
|
||||||
{ "--stinger", "-sting", B1200, CS8, SERIO_STINGER, 0, 0, 1, stinger_init },
|
B4800, CS8|CSTOPB|PARENB|PARODD,
|
||||||
{ "--mousesystems", "-msc", B1200, CS8, SERIO_MSC, 0, 0x01, 1, NULL },
|
SERIO_VSXXXAA, 0x00, 0x00, 1, NULL },
|
||||||
{ "--sunmouse", "-sun", B1200, CS8, SERIO_SUN, 0, 0x01, 1, NULL },
|
{ "--spaceorb", "-orb", "SpaceOrb 360 / SpaceBall Avenger",
|
||||||
{ "--microsoft", "-bare", B1200, CS7, SERIO_MS, 0, 0, 1, NULL },
|
B9600, CS8,
|
||||||
{ "--mshack", "-ms", B1200, CS7, SERIO_MS, 0, 0x01, 1, NULL },
|
SERIO_SPACEORB, 0x00, 0x00, 1, NULL },
|
||||||
{ "--mouseman", "-mman", B1200, CS7, SERIO_MP, 0, 0x01, 1, NULL },
|
{ "--spaceball", "-sbl", "SpaceBall 2003 / 3003 / 4000 FLX",
|
||||||
{ "--intellimouse", "-ms3", B1200, CS7, SERIO_MZ, 0, 0x11, 1, NULL },
|
B9600, CS8,
|
||||||
{ "--mmwheel", "-mmw", B1200, CS7 | CSTOPB, SERIO_MZP, 0, 0x13, 1, mzp_init },
|
SERIO_SPACEBALL, 0x00, 0x00, 0, spaceball_init },
|
||||||
{ "--iforce", "-ifor", B38400, CS8, SERIO_IFORCE, 0, 0, 0, NULL },
|
{ "--magellan", "-mag", "Magellan / SpaceMouse",
|
||||||
{ "--newtonkbd", "-newt", B9600, CS8, SERIO_NEWTON, 0, 0, 0, newton_init },
|
B9600, CS8 | CSTOPB | CRTSCTS,
|
||||||
{ "--h3600ts", "-ipaq", B115200, CS8, SERIO_H3600, 0, 0, 0, NULL },
|
SERIO_MAGELLAN, 0x00, 0x00, 1, magellan_init },
|
||||||
{ "--stowawaykbd", "-ipaqkbd", B115200, CS8, SERIO_STOWAWAY, 0, 0, 0, NULL },
|
{ "--warrior", "-war", "WingMan Warrior",
|
||||||
{ "--ps2serkbd", "-ps2ser", B1200, CS8, SERIO_PS2SER, 0, 0, 1, NULL },
|
B1200, CS7 | CSTOPB,
|
||||||
{ "--twiddler", "-twid", B2400, CS8, SERIO_TWIDKBD, 0, 0, 0, twiddler_init },
|
SERIO_WARRIOR, 0x00, 0x00, 1, warrior_init },
|
||||||
{ "--twiddler-joy", "-twidjoy", B2400, CS8, SERIO_TWIDJOY, 0, 0, 0, twiddler_init },
|
{ "--stinger", "-sting", "Gravis Stinger",
|
||||||
{ "--elotouch", "-elo", B9600, CS8 | CRTSCTS, SERIO_ELO, 0, 0, 0, NULL },
|
B1200, CS8,
|
||||||
{ "--elo4002", "-elo6b", B9600, CS8 | CRTSCTS, SERIO_ELO, 1, 0, 0, NULL },
|
SERIO_STINGER, 0x00, 0x00, 1, stinger_init },
|
||||||
{ "--elo271-140", "-elo4b", B9600, CS8 | CRTSCTS, SERIO_ELO, 2, 0, 0, NULL },
|
{ "--mousesystems", "-msc", "3-button Mouse Systems mouse",
|
||||||
{ "--elo261-280", "-elo3b", B9600, CS8 | CRTSCTS, SERIO_ELO, 3, 0, 0, NULL },
|
B1200, CS8,
|
||||||
{ "--dump", "-dump", B2400, CS8, 0, 0, 0, 0, dump_init },
|
SERIO_MSC, 0x00, 0x01, 1, NULL },
|
||||||
{ "", "", 0, 0 }
|
{ "--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 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
unsigned long devt;
|
unsigned long devt;
|
||||||
int ldisc;
|
int ldisc;
|
||||||
int type;
|
struct input_types *type = NULL;
|
||||||
long id, extra;
|
const char *device = NULL;
|
||||||
int fd;
|
int daemon_mode = 0;
|
||||||
|
int need_device = 0;
|
||||||
|
unsigned long id, extra;
|
||||||
|
int fd;
|
||||||
|
int i;
|
||||||
char c;
|
char c;
|
||||||
|
int retval;
|
||||||
|
|
||||||
if (argc < 2 || argc > 4 || (argc == 4 && strcmp(argv[3], "--daemon")) || !strcmp("--help", argv[1])) {
|
for (i = 1; i < argc; i++) {
|
||||||
puts("");
|
if (!strcasecmp(argv[i], "--help")) {
|
||||||
puts("Usage: inputttach <mode> <device>");
|
show_help();
|
||||||
puts("");
|
return EXIT_SUCCESS;
|
||||||
puts("Modes:");
|
} else if (!strcasecmp(argv[i], "--daemon")) {
|
||||||
puts(" --sunkbd -skb Sun Type 4 and Type 5 keyboards");
|
daemon_mode = 1;
|
||||||
puts(" --lkkbd -lk DEC LK201 / LK401 keyboards");
|
} else if (need_device) {
|
||||||
puts(" --vsxxx-aa -vs DEC VSXXX-AA / VSXXX-GA mouse and VSXXX-AB tablet");
|
device = argv[i];
|
||||||
puts(" --spaceorb -orb SpaceOrb 360 / SpaceBall Avenger");
|
need_device = 0;
|
||||||
puts(" --spaceball -sbl SpaceBall 2003 / 3003 / 4000 FLX");
|
} else {
|
||||||
puts(" --magellan -mag Magellan / SpaceMouse");
|
if (type && type->name) {
|
||||||
puts(" --warrior -war WingMan Warrior");
|
fprintf(stderr,
|
||||||
puts(" --stinger -stng Gravis Stinger");
|
"inputattach: '%s' - "
|
||||||
puts(" --mousesystems -msc 3-button Mouse Systems mice");
|
"only one mode allowed\n", argv[i]);
|
||||||
puts(" --sunmouse -sun 3-button Sun mice");
|
return EXIT_FAILURE;
|
||||||
puts(" --microsoft -bare 2-button Microsoft mice");
|
}
|
||||||
puts(" --mshack -ms 3-button mice in Microsoft mode");
|
for (type = input_types; type->name; type++) {
|
||||||
puts(" --mouseman -mman 3-button Logitech and Genius mice");
|
if (!strcasecmp(argv[i], type->name) ||
|
||||||
puts(" --intellimouse -ms3 Microsoft IntelliMouse");
|
!strcasecmp(argv[i], type->name2)) {
|
||||||
puts(" --mmwheel -mmw Logitech mice with 4-5 buttons or wheel");
|
break;
|
||||||
puts(" --iforce -ifor I-Force joysticks and wheels");
|
}
|
||||||
puts(" --h3600ts -ipaq Ipaq h3600 touchscreen");
|
}
|
||||||
puts(" --stowawaykbd -ipaqkbd Stowaway keyboard");
|
if (!type->name) {
|
||||||
puts(" --ps2serkbd -ps2ser PS/2 via serial keyboard");
|
fprintf(stderr,
|
||||||
puts(" --twiddler -twid Handykey Twiddler chording keyboard");
|
"inputattach: invalid mode '%s'\n",
|
||||||
puts(" --twiddler-joy -twidjoy Handykey Twiddler used as a joystick");
|
argv[i]);
|
||||||
puts("");
|
return EXIT_FAILURE;
|
||||||
return 1;
|
}
|
||||||
|
need_device = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!type || !type->name) {
|
||||||
|
fprintf(stderr, "inputattach: must specify mode\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (type = 0; input_types[type].speed; type++) {
|
if (need_device) {
|
||||||
if (!strncasecmp(argv[1], input_types[type].name, 16) ||
|
fprintf(stderr, "inputattach: must specify device\n");
|
||||||
!strncasecmp(argv[1], input_types[type].name2, 16))
|
return EXIT_FAILURE;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!input_types[type].speed) {
|
fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||||
fprintf(stderr, "inputattach: invalid mode\n");
|
if (fd < 0) {
|
||||||
|
fprintf(stderr, "inputattach: '%s' - %s\n",
|
||||||
|
device, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd = open(argv[2], O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) {
|
setline(fd, type->flags, type->speed);
|
||||||
perror("inputattach");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
setline(fd, input_types[type].flags, input_types[type].speed);
|
if (type->flush)
|
||||||
|
while (!readchar(fd, &c, 100))
|
||||||
|
/* empty */;
|
||||||
|
|
||||||
if (input_types[type].flush)
|
id = type->id;
|
||||||
while (!readchar(fd, &c, 100));
|
extra = type->extra;
|
||||||
|
|
||||||
id = input_types[type].id;
|
if (type->init && type->init(fd, &id, &extra)) {
|
||||||
extra = input_types[type].extra;
|
|
||||||
|
|
||||||
if (input_types[type].init && input_types[type].init(fd, &id, &extra)) {
|
|
||||||
fprintf(stderr, "inputattach: device initialization failed\n");
|
fprintf(stderr, "inputattach: device initialization failed\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldisc = N_MOUSE;
|
ldisc = N_MOUSE;
|
||||||
if(ioctl(fd, TIOCSETD, &ldisc)) {
|
if (ioctl(fd, TIOCSETD, &ldisc)) {
|
||||||
fprintf(stderr, "inputattach: can't set line discipline\n");
|
fprintf(stderr, "inputattach: can't set line discipline\n");
|
||||||
return 1;
|
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");
|
fprintf(stderr, "inputattach: can't set device type\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 4 && !strcmp(argv[3],"--daemon"))
|
retval = EXIT_SUCCESS;
|
||||||
daemon(0,0);
|
if (daemon_mode && daemon(0, 0) < 0) {
|
||||||
|
perror("inputattach");
|
||||||
|
retval = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
read(fd, NULL, 0);
|
read(fd, NULL, 0);
|
||||||
|
|
||||||
@ -471,5 +616,5 @@ int main(int argc, char **argv)
|
|||||||
ioctl(fd, TIOCSETD, &ldisc);
|
ioctl(fd, TIOCSETD, &ldisc);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
111
serio-ids.h
Normal file
111
serio-ids.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user