diff --git a/gpm-close-fds.patch b/gpm-close-fds.patch new file mode 100644 index 0000000..5055bc2 --- /dev/null +++ b/gpm-close-fds.patch @@ -0,0 +1,16 @@ +--- src/daemon/startup.c.close-fds 2008-06-13 10:08:19.000000000 +0200 ++++ src/daemon/startup.c 2008-12-02 10:11:12.000000000 +0100 +@@ -135,6 +135,13 @@ void startup(int argc, char **argv) + check_uniqueness(); + gpm_report(GPM_PR_INFO,GPM_MESS_STARTED); + ++ // close extra fds ++ if (option.run_status == GPM_RUN_STARTUP ) { ++ close(0); ++ close(1); ++ close(2); ++ } ++ + //return mouse_table[1].fd; /* the second is handled in the main() */ + + /****************** OLD CODE from gpn.c END ***********************/ diff --git a/gpm-conf.patch b/gpm-conf.patch index 0b239a5..e6dba03 100644 --- a/gpm-conf.patch +++ b/gpm-conf.patch @@ -11,33 +11,7 @@ Index: README directory, test it out and then edit it to suit your feels. * You'd like to name the gpm info file inside /usr/info/dir. Just insert -Index: doc/README.silitek -=================================================================== ---- doc/README.silitek.orig 2010-09-08 13:26:13.916055341 +0200 -+++ doc/README.silitek 2010-09-08 13:26:14.084036415 +0200 -@@ -14,11 +14,11 @@ This IR commander can be used with two t - - Both types of mouse driver uses the system wide configuration file - -- /etc/gpm-silitek.conf -+ /etc/gpm/silitek.conf - - which defines the return values of any key not being mouse button - or mouse stick. For this keys the drag mouse button works as a --modifier: pressed once, the last column in /etc/gpm-silitek.conf -+modifier: pressed once, the last column in /etc/gpm/silitek.conf - is used. To switch back to the normal return values, the drag mouse - button has to be pressed again. It is allowed to use escaped - sequences as return values. Characters other than printable can -@@ -169,7 +169,7 @@ EOF - -------------------------------------------------------------------- - - the Multimedia keys on IR Keyboard SK-7100 are usable (for ncurses --based programs see below). After editing /etc/gpm-silitek.conf -+based programs see below). After editing /etc/gpm/silitek.conf - to get the similar named keys to work similar, both the IR Keyboard - SK-7100 and the IR commander SM-1000 are usable in parallel. - + Index: doc/README.synaptics =================================================================== --- doc/README.synaptics.orig 2009-02-09 10:58:53.000000000 +0100 @@ -118,6 +92,7 @@ Index: doc/doc.gpm.in $(HOME)/.gpm-root The user configuration file. /dev/vcs* Virtual Console Screens .fi + Index: doc/gpm.info =================================================================== --- doc/gpm.info.orig 2009-02-09 10:59:44.000000000 +0100 @@ -131,19 +106,7 @@ Index: doc/gpm.info configuration information. This option is intended for those system administrators who fear security could be broken by this daemon. Things should be sufficiently secure, but if you find a -Index: src/headers/silitek.h -=================================================================== ---- src/headers/silitek.h.orig 2010-09-08 13:26:14.000045878 +0200 -+++ src/headers/silitek.h 2010-09-08 13:26:14.224020642 +0200 -@@ -27,7 +27,7 @@ extern void silitek_keys(unsigned char * - extern void silitek_keys_ps2(unsigned char *data, int *drag); - extern int silitek_ghost_ps2(unsigned char *data); - extern int fd_silitek; --#define SILI_SYSTEM_FILE SYSCONFDIR "/gpm-silitek.conf" -+#define SILI_SYSTEM_FILE SYSCONFDIR "/silitek.conf" - #define SILISTRLEN 32 - #define SILISTRSCN "key %32s %32s %32s" - extern void silitek_mapping(void); + Index: src/headers/twiddler.h =================================================================== --- src/headers/twiddler.h.orig 2009-02-09 10:58:53.000000000 +0100 @@ -171,6 +134,7 @@ Index: src/prog/gpm-root.y #define DEFAULT_FORE 7 #define DEFAULT_BACK 0 + Index: src/synaptics.c =================================================================== --- src/synaptics.c.orig 2009-02-09 10:58:53.000000000 +0100 diff --git a/gpm-gcc4.3.patch b/gpm-gcc4.3.patch new file mode 100644 index 0000000..5d7f275 --- /dev/null +++ b/gpm-gcc4.3.patch @@ -0,0 +1,10 @@ +--- src/daemon/open_console.c.gcc4.3 2008-05-28 11:12:34.000000000 +0200 ++++ src/daemon/open_console.c 2008-05-28 11:12:40.000000000 +0200 +@@ -21,7 +21,6 @@ + + #include /* open and co. */ + #include /* stat() */ +-#include /* ioctl */ + + /* Linux specific (to be outsourced in gpm2 */ + #include /* for serial console check */ diff --git a/gpm-lib-silent.patch b/gpm-lib-silent.patch new file mode 100644 index 0000000..f345d7d --- /dev/null +++ b/gpm-lib-silent.patch @@ -0,0 +1,19 @@ +--- src/lib/report-lib.c.lib-silent 2002-12-24 23:57:16.000000000 +0100 ++++ src/lib/report-lib.c 2006-01-18 17:55:38.000000000 +0100 +@@ -24,8 +24,16 @@ + + #include "headers/message.h" + ++static int gpm_silent() { ++ if ( getenv( "GPM_VERBOSE" ) == NULL ) return 1; ++ return 0; ++} ++ + void gpm_report(int line, char *file, int stat, char *text, ... ) + { ++ if ( gpm_silent() && stat != GPM_STAT_OOPS ) ++ return; ++ + char *string = NULL; + int log_level; + va_list ap; diff --git a/gpm-libtool.patch b/gpm-libtool.patch new file mode 100644 index 0000000..e69a298 --- /dev/null +++ b/gpm-libtool.patch @@ -0,0 +1,11 @@ +--- configure.ac.libtool 2009-02-11 08:12:00.000000000 +0100 ++++ configure.ac 2009-02-11 08:12:08.000000000 +0100 +@@ -42,7 +42,7 @@ release="`cat $srcdir/.gitversion`" + # + + AC_PROG_CC +-AC_PROG_RANLIB ++AC_PROG_LIBTOOL + AC_PROG_INSTALL + AC_PROG_YACC + AC_PROG_LN_S diff --git a/gpm-multilib.patch b/gpm-multilib.patch new file mode 100644 index 0000000..567f4d0 --- /dev/null +++ b/gpm-multilib.patch @@ -0,0 +1,32 @@ +Index: contrib/Makefile.in +=================================================================== +--- contrib/Makefile.in.orig 2008-06-19 07:48:48.000000000 +0200 ++++ contrib/Makefile.in 2011-01-27 12:31:18.404745581 +0100 +@@ -9,10 +9,10 @@ top_builddir = .. + + include $(top_builddir)/Makefile.include + +-all: $(srcdir)/$(ELISP) ++all: $(filter-out %.elc,$(srcdir)/$(ELISP)) + + install: all +- if [ -n "$(ELISP)" ]; then for i in `echo $(ELISP)`; do \ ++ if [ -n "$(filter-out %.elc,$(ELISP))" ]; then for i in `echo $(filter-out %.elc,$(ELISP))`; do \ + $(INSTALL_DATA) $(srcdir)/$$i $(lispdir)/`basename $$i` ;\ + done; fi + +@@ -20,7 +20,7 @@ install: all + $(EMACS) -batch -l $(srcdir)/emacs/exec.el -exec '(byte-compile-file "$<")' + + uninstall: +- if [ -n "$(ELISP)" ]; then for i in `echo $(ELISP)`; do \ ++ if [ -n "$(filter-out %.elc,$(ELISP))" ]; then for i in `echo $(filter-out %.elc,$(ELISP))`; do \ + rm -f $(lispdir)/$$i ;\ + done; fi + +@@ -28,4 +28,4 @@ dist: + $(CP) -r $(srcdir) $(top_builddir)/gpm-$(release)/ + + clean distclean: +- $(RM) -f $(srcdir)/emacs/*.elc Makefile ++ $(RM) $(srcdir)/emacs/*.elc Makefile diff --git a/gpm-ps2_command_bytes.patch b/gpm-ps2_command_bytes.patch deleted file mode 100644 index 7d43430..0000000 --- a/gpm-ps2_command_bytes.patch +++ /dev/null @@ -1,35 +0,0 @@ -Index: src/headers/gpmInt.h -=================================================================== ---- src/headers/gpmInt.h.orig 2010-09-08 13:25:25.777479285 +0200 -+++ src/headers/gpmInt.h 2010-09-08 13:25:31.112878123 +0200 -@@ -50,21 +50,27 @@ - - /*** mouse commands ***/ - --#define GPM_AUX_SEND_ID 0xF2 -+#define GPM_AUX_SEND_ID 0xF2 /* Get ID: ACK + 1 byte ID */ - #define GPM_AUX_ID_ERROR -1 - #define GPM_AUX_ID_PS2 0 - #define GPM_AUX_ID_IMPS2 3 - - /* these are shameless stolen from /usr/src/linux/include/linux/pc_keyb.h */ - --#define GPM_AUX_SET_RES 0xE8 /* Set resolution */ - #define GPM_AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */ - #define GPM_AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */ --#define GPM_AUX_GET_SCALE 0xE9 /* Get scaling factor */ -+#define GPM_AUX_SET_RES 0xE8 /* Set resolution */ -+#define GPM_AUX_GET_SCALE 0xE9 /* Get scaling factor: ACK + 3 byte status pack */ - #define GPM_AUX_SET_STREAM 0xEA /* Set stream mode */ -+#define GPM_AUX_GET_DATA 0xEB /* Read data: ACK + 3 byte movement pack */ -+#define GPM_AUX_RESET_WRAP 0xEC /* From wrap mode to previous */ -+#define GPM_AUX_SET_WRAP 0xEE /* Set wrap mode */ -+#define GPM_AUX_SET_REMOTE 0xF0 /* Set remote mode */ - #define GPM_AUX_SET_SAMPLE 0xF3 /* Set sample rate */ - #define GPM_AUX_ENABLE_DEV 0xF4 /* Enable aux device */ - #define GPM_AUX_DISABLE_DEV 0xF5 /* Disable aux device */ -+#define GPM_AUX_DEFAULTS 0xF6 /* Reset to defaults */ -+#define GPM_AUX_RESEND 0xFE /* Resend last pack */ - #define GPM_AUX_RESET 0xFF /* Reset aux device */ - #define GPM_AUX_ACK 0xFA /* Command byte ACK. */ - diff --git a/gpm-ps2_read.patch b/gpm-ps2_read.patch deleted file mode 100644 index ebc0a31..0000000 --- a/gpm-ps2_read.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: src/daemon/getmousedata.c -=================================================================== ---- src/daemon/getmousedata.c.orig 2009-02-09 10:58:53.000000000 +0100 -+++ src/daemon/getmousedata.c 2010-09-07 19:18:52.107824882 +0200 -@@ -70,7 +70,7 @@ char *getMouseData(int fd, Gpm_Type *typ - - if((i=(which_mouse->m_type)->packetlen-howmany)) /* still to get */ - do { -- j = read(fd,edata-i,i); /* edata is pointer just after data */ -+ j = read(fd,edata-i,howmany); /* edata is pointer just after data */ - if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep && j > 0) - write(fifofd, edata-i, j); - i -= j; diff --git a/gpm-ps2_reconnection.patch b/gpm-ps2_reconnection.patch deleted file mode 100644 index 941cc8d..0000000 --- a/gpm-ps2_reconnection.patch +++ /dev/null @@ -1,459 +0,0 @@ -Index: src/mice.c -=================================================================== ---- src/mice.c.orig 2009-02-09 10:58:53.000000000 +0100 -+++ src/mice.c 2010-09-08 18:38:24.516205731 +0200 -@@ -2372,116 +2372,116 @@ Gpm_Type mice[]={ - - {"mman", "The \"MouseMan\" and similar devices (3/4 bytes per packet).", - "Mouseman", M_mman, I_serial, CS7 | STD_FLG, /* first */ -- {0x40, 0x40, 0x40, 0x00}, 3, 1, 1, 0, 0}, -+ {0x40, 0x40, 0x40, 0x00}, 3, 1, 1, 0, 0, 0}, - {"ms", "The original ms protocol, with a middle-button extension.", - "", M_ms, I_serial, CS7 | STD_FLG, -- {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, -+ {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0, 0}, - {"acecad", "Acecad tablet absolute mode(Sumagrapics MM-Series mode)", - "", M_summa, I_summa, STD_FLG, -- {0x80, 0x80, 0x00, 0x00}, 7, 1, 0, 1, 0}, -+ {0x80, 0x80, 0x00, 0x00}, 7, 1, 0, 1, 0, 0}, - {"bare", "Unadorned ms protocol. Needed with some 2-buttons mice.", - "Microsoft", M_bare, I_serial, CS7 | STD_FLG, -- {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, -+ {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0, 0}, - {"bm", "Micro$oft busmice and compatible devices.", - "BusMouse", M_bm, I_empty, STD_FLG, /* bm is sun */ -- {0xf8, 0x80, 0x00, 0x00}, 3, 3, 0, 0, 0}, -+ {0xf8, 0x80, 0x00, 0x00}, 3, 3, 0, 0, 0, 0}, - {"brw", "Fellowes Browser - 4 buttons (and a wheel) (dual protocol?)", - "", M_brw, I_pnp, CS7 | STD_FLG, -- {0xc0, 0x40, 0xc0, 0x00}, 4, 1, 0, 0, 0}, -+ {0xc0, 0x40, 0xc0, 0x00}, 4, 1, 0, 0, 0, 0}, - {"cal", "Calcomp UltraSlate", - "", M_calus, I_calus, CS8 | CSTOPB | STD_FLG, -- {0x80, 0x80, 0x80, 0x00}, 6, 6, 0, 1, 0}, -+ {0x80, 0x80, 0x80, 0x00}, 6, 6, 0, 1, 0, 0}, - {"calr", "Calcomp UltraSlate - relative mode", - "", M_calus_rel, I_calus, CS8 | CSTOPB | STD_FLG, -- {0x80, 0x80, 0x80, 0x00}, 6, 6, 0, 0, 0}, -+ {0x80, 0x80, 0x80, 0x00}, 6, 6, 0, 0, 0, 0}, - {"etouch", "EloTouch touch-screens (only button-1 events, by now)", - "", M_etouch, I_etouch, STD_FLG, -- {0xFF, 0x55, 0xFF, 0x54}, 7, 1, 0, 1, NULL}, -+ {0xFF, 0x55, 0xFF, 0x54}, 7, 1, 0, 1, NULL, 0}, - #ifdef HAVE_LINUX_INPUT_H - {"evdev", "Linux Event Device", - "", M_evdev, I_empty, STD_FLG, -- {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 0, NULL}, -+ {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 0, NULL, 0}, - #endif /* HAVE_LINUX_INPUT_H */ - {"exps2", "IntelliMouse Explorer (ps2) - 3 buttons, wheel unused", - "ExplorerPS/2", M_imps2, I_exps2, STD_FLG, -- {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, -+ {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0, 0}, - #ifdef HAVE_LINUX_JOYSTICK_H - {"js", "Joystick mouse emulation", - "Joystick", M_js, NULL, 0, -- {0xFC, 0x00, 0x00, 0x00}, 12, 12, 0, 0, 0}, -+ {0xFC, 0x00, 0x00, 0x00}, 12, 12, 0, 0, 0, 0}, - #endif - {"genitizer", "\"Genitizer\" tablet, in relative mode.", - "", M_geni, I_serial, CS8|PARENB|PARODD, -- {0x80, 0x80, 0x00, 0x00}, 3, 1, 0, 0, 0}, -+ {0x80, 0x80, 0x00, 0x00}, 3, 1, 0, 0, 0, 0}, - {"gunze", "Gunze touch-screens (only button-1 events, by now)", - "", M_gunze, I_gunze, STD_FLG, -- {0xF9, 0x50, 0xF0, 0x30}, 11, 1, 0, 1, NULL}, -+ {0xF9, 0x50, 0xF0, 0x30}, 11, 1, 0, 1, NULL, 0}, - {"imps2","Microsoft Intellimouse (ps2)-autodetect 2/3 buttons,wheel unused", - "", M_imps2, I_imps2, STD_FLG, -- {0xC0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, R_imps2}, -+ {0xC0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, R_imps2, 1}, - {"logi", "Used in some Logitech devices (only serial).", - "Logitech", M_logi, I_logi, CS8 | CSTOPB | STD_FLG, -- {0xe0, 0x80, 0x80, 0x00}, 3, 3, 0, 0, 0}, -+ {0xe0, 0x80, 0x80, 0x00}, 3, 3, 0, 0, 0, 0}, - {"logim", "Turn logitech into Mouse-Systems-Compatible.", - "", M_logimsc, I_serial, CS8 | CSTOPB | STD_FLG, -- {0xf8, 0x80, 0x00, 0x00}, 5, 1, 0, 0, 0}, -+ {0xf8, 0x80, 0x00, 0x00}, 5, 1, 0, 0, 0, 0}, - {"mm", "MM series. Probably an old protocol...", - "MMSeries", M_mm, I_serial, CS8 | PARENB|PARODD | STD_FLG, -- {0xe0, 0x80, 0x80, 0x00}, 3, 1, 0, 0, 0}, -+ {0xe0, 0x80, 0x80, 0x00}, 3, 1, 0, 0, 0, 0}, - {"ms3", "Microsoft Intellimouse (serial) - 3 buttons, wheel unused", - "", M_ms3, I_pnp, CS7 | STD_FLG, -- {0xc0, 0x40, 0xc0, 0x00}, 4, 1, 0, 0, R_ms3}, -+ {0xc0, 0x40, 0xc0, 0x00}, 4, 1, 0, 0, R_ms3, 0}, - {"ms+", "Like 'ms', but allows dragging with the middle button.", - "", M_ms_plus, I_serial, CS7 | STD_FLG, -- {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, -+ {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0, 0}, - {"ms+lr", "'ms+', but you can reset m by pressing lr (see man page).", - "", M_ms_plus_lr, I_serial, CS7 | STD_FLG, -- {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, -+ {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0, 0}, - {"msc", "Mouse-Systems-Compatible (5bytes). Most 3-button mice.", - "MouseSystems", M_msc, I_serial, CS8 | CSTOPB | STD_FLG, -- {0xf8, 0x80, 0x00, 0x00}, 5, 1, 0, 0, R_msc}, -+ {0xf8, 0x80, 0x00, 0x00}, 5, 1, 0, 0, R_msc, 0}, - {"mtouch", "MicroTouch touch-screens (only button-1 events, by now)", - "", M_mtouch, I_mtouch, STD_FLG, -- {0x80, 0x80, 0x80, 0x00}, 5, 1, 0, 1, NULL}, -+ {0x80, 0x80, 0x80, 0x00}, 5, 1, 0, 1, NULL, 0}, - {"ncr", "Ncr3125pen, found on some laptops", - "", M_ncr, NULL, STD_FLG, -- {0x08, 0x08, 0x00, 0x00}, 7, 7, 0, 1, 0}, -+ {0x08, 0x08, 0x00, 0x00}, 7, 7, 0, 1, 0, 0}, - {"netmouse","Genius NetMouse (ps2) - 2 buttons and 2 buttons 'up'/'down'.", - "", M_netmouse, I_netmouse, CS7 | STD_FLG, -- {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, -+ {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0, 1}, - {"pnp", "Plug and pray. New mice may not run with '-t ms'.", - "", M_bare, I_pnp, CS7 | STD_FLG, -- {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, -+ {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0, 0}, - {"ps2", "Busmice of the ps/2 series. Most busmice, actually.", - "PS/2", M_ps2, I_ps2, STD_FLG, -- {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, R_ps2}, -+ {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, R_ps2, 1}, - {"sun", "'msc' protocol, but only 3 bytes per packet.", - "", M_sun, I_serial, CS8 | CSTOPB | STD_FLG, -- {0xf8, 0x80, 0x00, 0x00}, 3, 1, 0, 0, R_sun}, -+ {0xf8, 0x80, 0x00, 0x00}, 3, 1, 0, 0, R_sun, 0}, - {"summa", "Summagraphics or Genius tablet absolute mode(MM-Series)", - "", M_summa, I_summa, STD_FLG, -- {0x80, 0x80, 0x00, 0x00}, 5, 1, 0, 1, R_summa}, -+ {0x80, 0x80, 0x00, 0x00}, 5, 1, 0, 1, R_summa, 0}, - {"syn", "The \"Synaptics\" serial TouchPad.", - "synaptics", M_synaptics_serial, I_serial, CS7 | STD_FLG, -- {0x40, 0x40, 0x40, 0x00}, 6, 6, 1, 0, 0}, -+ {0x40, 0x40, 0x40, 0x00}, 6, 6, 1, 0, 0, 0}, - {"synps2", "The \"Synaptics\" PS/2 TouchPad", - "synaptics_ps2", M_synaptics_ps2, I_synps2, STD_FLG, -- {0x80, 0x80, 0x00, 0x00}, 6, 1, 1, 0, 0}, -+ {0x80, 0x80, 0x00, 0x00}, 6, 1, 1, 0, 0, 1}, - {"twid", "Twidddler keyboard", - "", M_twid, I_twid, CS8 | STD_FLG, -- {0x80, 0x00, 0x80, 0x80}, 5, 1, 0, 0, 0}, -+ {0x80, 0x00, 0x80, 0x80}, 5, 1, 0, 0, 0, 0}, - {"vsxxxaa", "The DEC VSXXX-AA/GA serial mouse on DEC workstations.", - "", M_vsxxx_aa, I_serial, CS8 | PARENB | PARODD | STD_FLG, -- {0xe0, 0x80, 0x80, 0x00}, 3, 1, 0, 0, 0}, -+ {0xe0, 0x80, 0x80, 0x00}, 3, 1, 0, 0, 0, 0}, - {"wacom","Wacom Protocol IV Tablets: Pen+Mouse, relative+absolute mode", - "", M_wacom, I_wacom, STD_FLG, -- {0x80, 0x80, 0x80, 0x00}, 7, 1, 0, 0, 0}, -+ {0x80, 0x80, 0x80, 0x00}, 7, 1, 0, 0, 0, 0}, - {"wp", "Genius WizardPad tablet", - "wizardpad", M_wp, I_wp, STD_FLG, -- {0xFA, 0x42, 0x00, 0x00}, 10, 1, 0, 1, 0}, -+ {0xFA, 0x42, 0x00, 0x00}, 10, 1, 0, 1, 0, 0}, - {"", "", - "", NULL, NULL, 0, -- {0x00, 0x00, 0x00, 0x00}, 0, 0, 0, 0, 0} -+ {0x00, 0x00, 0x00, 0x00}, 0, 0, 0, 0, 0, 0} - }; - - /*------------------------------------------------------------------------*/ -Index: src/daemon/getmousedata.c -=================================================================== ---- src/daemon/getmousedata.c.orig 2010-09-08 18:11:41.925698527 +0200 -+++ src/daemon/getmousedata.c 2010-09-08 18:39:50.210572313 +0200 -@@ -33,25 +33,58 @@ - * fetch the actual device data from the mouse device, dependent on - * what Gpm_Type is being passed. - *-------------------------------------------------------------------*/ --char *getMouseData(int fd, Gpm_Type *type, int kd_mode) -+char *getMouseData(int fd, Gpm_Type *type, int kd_mode, -+ unsigned char *save_byte , int *is_save_byte, int *restart) - { - static unsigned char data[32]; /* quite a big margin :) */ - char *edata=data+type->packetlen; - int howmany=type->howmany; -+ int preread; - int i,j; - - /*....................................... read and identify one byte */ - - if (read(fd, data, howmany)!=howmany) { -- if (opt_test) exit(0); -- gpm_report(GPM_PR_ERR,GPM_MESS_READ_FIRST, strerror(errno)); -- return NULL; -+ preread = 0; -+ if (*is_save_byte) { -+ /* one byte is saved, howmany must be 1 otherwise this -+ byte hasn't been saved */ -+ data[0] = *save_byte; -+ *is_save_byte = 0; -+ preread = 1; -+ } else { -+ if ((preread = read(fd, data, howmany))!=howmany) { -+ if (opt_test) exit(0); -+ gpm_report(GPM_PR_ERR,GPM_MESS_READ_FIRST, strerror(errno)); -+ return NULL; -+ } -+ } -+ } -+ -+ /* try to find sequence AA 00 which is generated by kernel-2.4.9 or higher -+ when PS/2 mouse was replugged */ -+ if (((which_mouse->m_type)->isPS2 == 1) && (data[0] == 0xaa)) { -+ if (preread == 1) { -+ // read second byte -+ if (read(fd, &(data[1]),1) == 1) -+ preread += 1; -+ } -+ if ((preread >= 2) && (data[1] == 0x0)) { -+ gpm_report(GPM_PR_DEBUG,GPM_MESS_REPLUGGED); -+ *restart = 1; -+ return NULL; -+ } - } - - if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep) - write(fifofd, data, howmany); - - if ((data[0]&((which_mouse->m_type)->proto)[0]) != ((which_mouse->m_type)->proto)[1]) { -+ if (preread > howmany) { -+ /* second byte was involuntary preread in test for PS/2 replugging */ -+ *save_byte = data[1]; -+ *is_save_byte = 1; -+ } - if ((which_mouse->m_type)->getextra == 1) { - data[1]=GPM_EXTRA_MAGIC_1; data[2]=GPM_EXTRA_MAGIC_2; - gpm_report(GPM_PR_DEBUG,GPM_EXTRA_DATA,data[0]); -@@ -68,13 +101,20 @@ char *getMouseData(int fd, Gpm_Type *typ - * tried ps2 with the original selection package, which called usleep() - */ - -- if((i=(which_mouse->m_type)->packetlen-howmany)) /* still to get */ -+ if((i=(which_mouse->m_type)->packetlen-preread) > 0) { /* still to get */ - do { - j = read(fd,edata-i,howmany); /* edata is pointer just after data */ - if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep && j > 0) - write(fifofd, edata-i, j); - i -= j; - } while (i && j); -+ } else { -+ if (preread > (which_mouse->m_type)->packetlen) { -+ /* second byte was involuntary preread in test for PS/2 replugging */ -+ *save_byte = data[1]; -+ *is_save_byte = 1; -+ } -+ } - - if (i) { - gpm_report(GPM_PR_ERR,GPM_MESS_READ_REST, strerror(errno)); -Index: src/daemon/gpm.c -=================================================================== ---- src/daemon/gpm.c.orig 2009-02-09 10:58:53.000000000 +0100 -+++ src/daemon/gpm.c 2010-09-08 18:38:23.256288409 +0200 -@@ -73,7 +73,8 @@ struct mouse_features mouse_table[3] = { - DEF_TIME, DEF_CLUSTER, DEF_THREE, DEF_GLIDEPOINT_TAP, - (char *)NULL /* extra */, - (Gpm_Type *)NULL, -- -1 -+ -1, -+ 0, 0 /* save byte, is_save_byte */ - } - }; - struct mouse_features *which_mouse; -Index: src/daemon/old_main.c -=================================================================== ---- src/daemon/old_main.c.orig 2009-02-09 10:58:53.000000000 +0100 -+++ src/daemon/old_main.c 2010-09-08 19:34:22.279958939 +0200 -@@ -37,6 +37,38 @@ - #define max(a,b) ((a)>(b) ? (a) : (b)) - #endif - -+static inline void initMouse(int i, int *fd, int *maxfd) -+{ -+ which_mouse=mouse_table+i; /* used to access options */ -+ -+ if (!(which_mouse->opt_dev)) -+ gpm_report(GPM_PR_OOPS,GPM_MESS_NEED_MDEV); -+ -+ if(!strcmp((which_mouse->opt_dev),"-")) -+ *fd=0; /* use stdin */ -+ else if( (*fd=open((which_mouse->opt_dev),O_RDWR | O_NDELAY)) < 0) -+ gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN,(which_mouse->opt_dev)); -+ -+ /* and then reset the flag */ -+ fcntl(*fd,F_SETFL,fcntl(*fd,F_GETFL) & ~O_NDELAY); -+ -+ /* create argc and argv for this device */ -+ mouse_argv[i] = build_argv((which_mouse->opt_type), -+ (which_mouse->opt_options), -+ &mouse_argc[i], ','); -+ -+ /* init the device, and use the return value as new mouse type */ -+ if ((which_mouse->m_type)->init) -+ (which_mouse->m_type)=((which_mouse->m_type)->init)(*fd, (which_mouse->m_type)->flags, -+ (which_mouse->m_type), -+ mouse_argc[i], mouse_argv[i]); -+ -+ if (!(which_mouse->m_type)) gpm_report(GPM_PR_OOPS,GPM_MESS_MOUSE_INIT); -+ -+ which_mouse->fd=*fd; -+ *maxfd=max(*fd, *maxfd); -+} -+ - - int old_main() - { -@@ -48,30 +80,8 @@ int old_main() - int pending; - Gpm_Event event; - -- for (i = 1; i <= 1+opt_double; i++) { -- which_mouse=mouse_table+i; /* used to access options */ -- -- if (!(which_mouse->opt_dev)) gpm_report(GPM_PR_OOPS,GPM_MESS_NEED_MDEV); -- -- if(!strcmp((which_mouse->opt_dev),"-")) fd=0; /* use stdin */ -- else if( (fd=open((which_mouse->opt_dev),O_RDWR | O_NDELAY)) < 0) -- gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN,(which_mouse->opt_dev)); -- -- /* and then reset the flag */ -- fcntl(fd,F_SETFL,fcntl(fd,F_GETFL) & ~O_NDELAY); -- -- /* create argc and argv for this device */ -- mouse_argv[i] = build_argv((which_mouse->opt_type), (which_mouse->opt_options), &mouse_argc[i], ','); -- -- /* init the device, and use the return value as new mouse type */ -- if ((which_mouse->m_type)->init) -- (which_mouse->m_type)=((which_mouse->m_type)->init)(fd, (which_mouse->m_type)->flags, (which_mouse->m_type), mouse_argc[i], -- mouse_argv[i]); -- if (!(which_mouse->m_type)) gpm_report(GPM_PR_OOPS,GPM_MESS_MOUSE_INIT); -- -- which_mouse->fd=fd; -- maxfd=max(fd, maxfd); -- } -+ for (i = 1; i <= 1+opt_double; i++) -+ initMouse(i, &fd, &maxfd); - - /*....................................... catch interesting signals */ - -@@ -184,10 +194,14 @@ int old_main() - */ - - for (i=1; i <= 1+opt_double; i++) { -+ int rc; - which_mouse=mouse_table+i; /* used to access options */ - if (FD_ISSET(which_mouse->fd,&selSet)) { - FD_CLR(which_mouse->fd,&selSet); pending--; -- if (processMouse(which_mouse->fd, &event, (which_mouse->m_type), kd_mode)) -+ rc = processMouse(which_mouse->fd, &event, (which_mouse->m_type), -+ kd_mode, &(which_mouse->save_byte), -+ &(which_mouse->is_save_byte)); -+ if (rc > 0) { - /* pass it to the client, if any - * or to the default handler, if any - * or to the selection handler -@@ -196,7 +210,15 @@ int old_main() - (cinfo[event.vc] && do_client(cinfo[event.vc], &event)) - || (cinfo[0] && do_client(cinfo[0], &event)) - || do_selection(&event); -+ } else if (rc == -1) { -+ /* try to reinitialise the mouse */ -+ FD_CLR(which_mouse->fd, &selSet); -+ close(which_mouse->fd); -+ initMouse(i, &fd, &maxfd); -+ FD_CLR(which_mouse->fd, &selSet); -+ which_mouse->is_save_byte=0; - } -+ } - } - - /*..................... got connection, process it */ -Index: src/daemon/processmouse.c -=================================================================== ---- src/daemon/processmouse.c.orig 2009-02-09 10:58:53.000000000 +0100 -+++ src/daemon/processmouse.c 2010-09-08 18:11:42.105686598 +0200 -@@ -40,7 +40,8 @@ - (t2.tv_usec-t1.tv_usec)/1000) - - --int processMouse(int fd, Gpm_Event *event, Gpm_Type *type, int kd_mode) -+int processMouse(int fd, Gpm_Event *event, Gpm_Type *type, int kd_mode, -+ unsigned char *save_byte, int *is_save_byte) - { - char *data; - static int fine_dx, -@@ -55,6 +56,7 @@ int processMouse(int fd, Gpm_Event *even - static struct timeval tv1={0,0}, tv2; /* tv1==0: first click is single */ - static struct timeval timeout={0,0}; - fd_set fdSet; -+ int restart; - - oldT = event->type; - -@@ -78,9 +80,12 @@ int processMouse(int fd, Gpm_Event *even - FD_SET(fd,&fdSet); - - do { /* cluster loop */ -- if(((data=getMouseData(fd, (which_mouse->m_type), kd_mode)) == NULL) -+ restart = 0; -+ if(((data=getMouseData(fd, (which_mouse->m_type), kd_mode, -+ save_byte,is_save_byte,&restart)) == NULL) - || ((*((which_mouse->m_type)->fun))(&nEvent,data)==-1) ) { -- -+ -+ if (restart) return -1; - if (!i) { - return 0; - } else { -Index: src/headers/daemon.h -=================================================================== ---- src/headers/daemon.h.orig 2009-02-09 10:58:53.000000000 +0100 -+++ src/headers/daemon.h 2010-09-08 19:26:01.901761337 +0200 -@@ -76,6 +76,7 @@ typedef struct Gpm_Type { - - /* repeat this event into fd */ - int (*repeat_fun)(Gpm_Event *state, int fd); -+ int isPS2; /* 1 for PS/2 mouses, 0 otherwise */ - } Gpm_Type; - - /* this structure is used to hide the dual-mouse stuff */ -@@ -96,6 +97,8 @@ struct mouse_features { - char *opt_options; /* extra textual configuration */ - Gpm_Type *m_type; - int fd; -+ unsigned char save_byte; -+ int is_save_byte; - }; - - /************************************************************************* -@@ -197,7 +200,9 @@ int do_selection(Gpm_Event *event); - - void get_console_size(Gpm_Event *ePtr); - int get_data(Gpm_Connect *where, int whence); --char *getMouseData(int fd, Gpm_Type *type, int kd_mode); -+char *getMouseData(int fd, Gpm_Type *type, int kd_mode, -+ unsigned char *save_byte , int *is_save_byte, -+ int *restart); - int getsym(const unsigned char *p0, unsigned char *res); - - void gpm_exited(void); -@@ -207,7 +212,8 @@ int open_console(const int mode); - int old_main(); - - int processConn(int fd); --int processMouse(int fd, Gpm_Event *event, Gpm_Type *type, int kd_mode); -+int processMouse(int fd, Gpm_Event *event, Gpm_Type *type, int kd_mode, -+ unsigned char *save_byte, int *is_save_byte); - int processRequest(Gpm_Cinfo *ci, int vc); - int processSpecial(Gpm_Event *event); - -Index: src/headers/message.h -=================================================================== ---- src/headers/message.h.orig 2009-02-09 10:58:53.000000000 +0100 -+++ src/headers/message.h 2010-09-08 18:38:24.516205731 +0200 -@@ -65,6 +65,7 @@ - #define GPM_MESS_VERSION "gpm " PACKAGE_VERSION - #define GPM_MESS_STARTED "Started gpm successfully. Entered daemon mode." - #define GPM_MESS_KILLED "Killed gpm(%d)." -+#define GPM_MESS_REPLUGGED "Mouse was replugged" - #define GPM_MESS_SKIP_DATA "Skipping a data packet (?)" - #define GPM_MESS_DATA_4 "Data %02x %02x %02x (%02x)" - #define GPM_MESS_NO_MAGIC "No magic" diff --git a/gpm-quiet_libgpm.patch b/gpm-quiet_libgpm.patch deleted file mode 100644 index 1adac12..0000000 --- a/gpm-quiet_libgpm.patch +++ /dev/null @@ -1,20 +0,0 @@ -Index: src/lib/report-lib.c -=================================================================== ---- src/lib/report-lib.c.orig 2010-09-08 13:35:23.166173284 +0200 -+++ src/lib/report-lib.c 2010-09-08 13:36:23.207409061 +0200 -@@ -26,6 +26,7 @@ - - void gpm_report(int line, char *file, int stat, char *text, ... ) - { -+#ifndef QUIET_LIBGPM - char *string = NULL; - int log_level; - va_list ap; -@@ -57,5 +58,7 @@ void gpm_report(int line, char *file, in - - va_end(ap); - -+#endif /* QUIET_LIBGPM */ -+ - if(stat == GPM_STAT_OOPS) exit(1); /* may a lib function call exit ???? */ - } diff --git a/gpm-silitek.patch b/gpm-silitek.patch deleted file mode 100644 index e6a6317..0000000 --- a/gpm-silitek.patch +++ /dev/null @@ -1,1121 +0,0 @@ -Index: conf/gpm-silitek.conf -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ conf/gpm-silitek.conf 2010-09-08 18:11:42.205679972 +0200 -@@ -0,0 +1,45 @@ -+# Standard key mapping for Silitek SM-1000 -+# on Linux virtual console (TERM=linux) -+key 1 1 1 -+key 2 2 2 -+key 3 3 3 -+key 4 4 4 -+key 5 5 5 -+key 6 6 6 -+key 7 7 7 -+key 8 8 8 -+key 9 9 9 -+key 0 0 0 -+key * * * -+key # # # -+# Ctrl+Q -+key > \021 \021 -+# Ctrl+S -+key || \023 \023 -+# Crtl+C -+key [] \003 \003 -+# End -+key >>| \033[4~ \033[4~ -+# Home -+key |<< \033[1~ \033[1~ -+# Delete -+key Mute \033[3~ \033[3~ -+# Cursor up -+key Vol+ \033[A \033[A -+# Cursor down -+key Vol- \033[B \033[B -+# Insert -+key Display \033[2~ \033[2~ -+# Page up -+key PgUp \033[5~ \033[5~ -+Page down -+key PgDn \033[6~ \033[6~ -+# Cursor left -+key Back \033[D \033[D -+# Cursor right -+key Forward \033[C \033[C -+# F1 upto F4 -+key CD \033[[A \033[[A -+key ShowWiz \033[[B \033[[B -+key WWW \033[[C \033[[C -+key Close \033[[D \033[[D -Index: doc/README.silitek -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ doc/README.silitek 2010-09-08 18:14:39.237907111 +0200 -@@ -0,0 +1,188 @@ -+This README describes the support for the Silitek SM-1000 IR commander -+(also called Netshooter). -+ -+This IR commander can be used with two types of mouse driver: -+ -+ * Type `silicom' supports the IR receiver which is shipped the -+ SM-1000 and plugged into a serial connector. -+ -+ * Type `silips2' supports the IR receiver which is shipped -+ with the Silitek IR keyboard SK-7100 (also called Airboard). -+ The mouse connector of this IR receiver should be plugged -+ into the PS/2 mouse connector (not to a serial connector). -+ You may need an adapter (9 pin serial to PS/2) to do this. -+ -+Both types of mouse driver uses the system wide configuration file -+ -+ /etc/gpm-silitek.conf -+ -+which defines the return values of any key not being mouse button -+or mouse stick. For this keys the drag mouse button works as a -+modifier: pressed once, the last column in /etc/gpm-silitek.conf -+is used. To switch back to the normal return values, the drag mouse -+button has to be pressed again. It is allowed to use escaped -+sequences as return values. Characters other than printable can -+be coded by using the backslash, e.g. `\033' for the octal number -+of the special character ESC (Escape) of `\x0D' for the hexadecimal -+number of the special character CR (Carriage Return), for more -+codings see the manual page ascii(7). -+ -+The default key mapping for the SM-1000 IR commander is on the -+virtual console is: -+ -+ SM-1000 Key normal drag active -+ ------------------------------------- -+ key 1 1 1 -+ key 2 2 2 -+ key 3 3 3 -+ key 4 4 4 -+ key 5 5 5 -+ key 6 6 6 -+ key 7 7 7 -+ key 8 8 8 -+ key 9 9 9 -+ key 0 0 0 -+ key * * * -+ key # # # -+ key > Ctrl Q Ctrl Q -+ key || Ctrl S Ctrl S -+ key [] Crtl C Crtl C -+ key >>| End End -+ key |<< Home Home -+ key Mute Delete Delete -+ key Vol+ Cursor Up Cursor Up -+ key Vol- Cursor Down Cursor Down -+ key Display Insert Insert -+ key PgUp Page Up Page Up -+ key PgDn Page Down Page Down -+ key Back Cursor Left Cursor Left -+ key Forward Cursor Right Cursor Right -+ key CD F1 F1 -+ key ShowWiz F2 F2 -+ key WWW F3 F3 -+ key Close F4 F4 -+ -+Usage with the IR receiver of the Silitek Keyboard SK-7100: -+ -+In comparison of the IR receiver of shipped with the SM-1000 -+this IR receiver has the advantage that both mouse interface -+of the IR keyboard and the IR Netshooter can be used in parallel. -+One advantage more is that only one IR receiver is required to -+use both the IR keyboard and the IR Netshooter. Next point is -+that the IR receiver of the IR keyboard seems to more insensitive -+for other IR commanders like those from TV sets. -+ -+The Multimedia keys of the IR keyboard SK-7100 can be configured -+by using setkeycodes(8) and loadkeys(8) to be usable in parallel -+to those of the IR commander SM-1000. -+ -+Notice: The key 7 of the IR commander SM-1000 generates the keyboard -+scancode for KP_ENTER if the SK-7100 keyboard is used in parallel. -+This happens even if the mouse type `silicom' is used in conjunction -+with the IR receiver of the SM-1000. This because if both IR receiver -+are used, the SM-1000 and the SK-7100, both receives signals from the -+SM-1000. Therefore this key should be disabled (note that the SK-7100 -+does not have a KP_ENTER): -+ -+-------------------------------------------------------------------- -+loadkeys <<-EOF -+keycode 96 = F39 -+string F39 = "" -+EOF -+-------------------------------------------------------------------- -+ -+With `showkeys -s' on the virtual console and `xev' under X11 the -+the other Multimedia keys of the SK-7100 causes the following -+scancodes/keycodes: -+ -+ SK-7100 Key console X11 -+ -------------------------- -+ Close e017 151 -+ CD e025 165 -+ Video e018 152 -+ WWW e032 178 -+ U/P e01e 158 -+ |<< e010 144 -+ || e012 146 -+ > e022 162 -+ [] e024 164 -+ >>| e019 153 -+ Vol- e02e 174 -+ Vol+ e030 176 -+ Mute e020 160 -+ Display e026 166 -+ -+If we map for e.g. the keys -+ -+ Video Switch to vc 8 where the Video Recoder Program runs (Console_8) -+ |<< Cursor Left (keycode 105) -+ >>| Cursor Right (keycode 106) -+ Display Win Menu key (keycode 127) -+ -+(Compares this with `dumpkeys | less' on a virtual console). -+ -+With the following command sequence (called in a script during boot): -+ -+-------------------------------------------------------------------- -+setkeycodes \ -+ e017 85 \ -+ e025 89 \ -+ e018 90 \ -+ e032 91 \ -+ e01e 92 \ -+ e010 105 \ -+ e012 94 \ -+ e022 95 \ -+ e024 120 \ -+ e019 106 \ -+ e02e 122 \ -+ e030 123 \ -+ e020 124 \ -+ e026 127 -+loadkeys <<-EOF -+ keycode 85 = F50 -+ keycode 89 = F51 -+ keycode 90 = Console_8 -+ keycode 91 = F53 -+ keycode 92 = F54 -+ keycode 94 = F56 -+ keycode 95 = F57 -+ keycode 120 = F58 -+ keycode 122 = F60 -+ keycode 123 = F61 -+ keycode 124 = F62 -+ keycode 127 = F63 -+ keycode 96 = F39 -+ string F50 = "\033[[Z" -+ string F51 = "\033[[Y" -+ string F53 = "\033[[W" -+ string F54 = "\033[[U" -+ string F56 = "\033[[H" -+ string F57 = "\033[[T" -+ string F58 = "\033[[F" -+ string F60 = "\033[[L" -+ string F61 = "\033[[M" -+ string F62 = "\033[[X" -+ string F63 = "\033[[R" -+ string F39 = "" -+EOF -+-------------------------------------------------------------------- -+ -+the Multimedia keys on IR Keyboard SK-7100 are usable (for ncurses -+based programs see below). After editing /etc/gpm-silitek.conf -+to get the similar named keys to work similar, both the IR Keyboard -+SK-7100 and the IR commander SM-1000 are usable in parallel. -+ -+For ncurses based programs the added keys have to be extended -+by dumping the current terminfo entry for the virtual consoles -+for TERM=linux: -+ -+ infocmp -1 linux > linux.tic -+ -+and editing the file linux.tic which means adding the function -+keys kf50, kf51, kf52, kf53, kf54, kf56, kf57, kf58, kf60, kf61, -+kf62, kf63, and kf39. After that the command -+ -+ tic linux.tic -+ -+installs the edited terminfo entry for TERM=linux. -Index: src/Makefile.in -=================================================================== ---- src/Makefile.in.orig 2010-09-08 18:11:41.885701179 +0200 -+++ src/Makefile.in 2010-09-08 18:14:37.778004511 +0200 -@@ -13,7 +13,7 @@ include $(top_builddir)/Makefile.include - - # Main portion: regular build rules - --GSRC = mice.c twiddler.c synaptics.c \ -+GSRC = mice.c twiddler.c synaptics.c silitek.c \ - daemon/add_mouse.c daemon/init_mice.c daemon/reset_mice.c \ - daemon/build_argv.c daemon/disable_paste.c daemon/do_client.c \ - daemon/do_selection.c daemon/get_console_size.c daemon/get_data.c \ -@@ -35,7 +35,7 @@ LOBJ = $(LSRC:.c=.o) tools.o @CURSES_OBJ - - PICS = $(LOBJ:.o=.lo) - --HDRS = gpm.h gpmInt.h twiddler.h synaptics.h message.h -+HDRS = gpm.h gpmInt.h twiddler.h synaptics.h silitek.h message.h - - PSRC = prog/mev.c prog/hltest.c prog/mouse-test.c prog/disable-paste.c \ - prog/display-buttons.c prog/display-coords.c prog/get-versions.c -@@ -152,7 +152,7 @@ prog/gpm-root: prog/gpm-root.c lib/libgp - $(CC) -I. @CPPFLAGS@ $(CPPFLAGS) @CFLAGS@ $(CFLAGS) -c -o $@.o $< - $(CC) @LDFLAGS@ $(LDFLAGS) -o $@ $@.o @LIBS@ $(LIBS) lib/libgpm.so.@abi_lev@ - --prog/mouse-test: prog/mouse-test.o mice.o twiddler.o synaptics.o prog/open_console.o -+prog/mouse-test: prog/mouse-test.o mice.o twiddler.o synaptics.o silitek.o prog/open_console.o - $(CC) @LDFLAGS@ $(LDFLAGS) -o $@ $^ @LIBS@ $(LIBS) -lm - - $(PROG): lib/libgpm.so.@abi_lev@ -Index: src/headers/message.h -=================================================================== ---- src/headers/message.h.orig 2010-09-08 18:11:42.173682092 +0200 -+++ src/headers/message.h 2010-09-08 18:14:37.518021855 +0200 -@@ -196,6 +196,10 @@ - #define GPM_MESS_FIRST_DEV "Use -m device -t protocol [-o options]!" - #define GPM_MESS_ELO_CALIBRATE "%s: etouch: calibration file %s absent or invalid, using defaults" - -+#define GPM_MESS_SILIPS2_ENABLE "silips2: enable error" -+#define GPM_MESS_SILIPS2_DISABLE "silips2: disable error" -+#define GPM_MESS_SILIPS2_RESET "silips2: reset error" -+ - /* warnings */ - #define GPM_MESS_REQUEST_ON "Request on vc %i > %i" - #define GPM_MESS_FAILED_CONNECT "Failed gpm connect attempt by uid %d for vc %s" -Index: src/headers/silitek.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ src/headers/silitek.h 2010-09-08 18:14:39.409895637 +0200 -@@ -0,0 +1,33 @@ -+/* -+ * silitek.h - support for the Silitek SM-1000 (Netshooter) with its IR -+ * receiver plugged serial connector and also with the IR -+ * receiver of the Silitek SK-7100 keyboard (Airboard) -+ * PS2 mouse connector. -+ * -+ * Copyright 2002 Werner Fink -+ * -+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -+ * -+ */ -+extern int silitek_get_check(unsigned char *data); -+extern int silitek_get_check_ps2(unsigned char *data); -+extern void silitek_keys(unsigned char *data, int *drag); -+extern void silitek_keys_ps2(unsigned char *data, int *drag); -+extern int silitek_ghost_ps2(unsigned char *data); -+extern int fd_silitek; -+#define SILI_SYSTEM_FILE SYSCONFDIR "/gpm-silitek.conf" -+#define SILISTRLEN 32 -+#define SILISTRSCN "key %32s %32s %32s" -+extern void silitek_mapping(void); -Index: src/mice.c -=================================================================== ---- src/mice.c.orig 2010-09-08 18:11:41.941697467 +0200 -+++ src/mice.c 2010-09-08 18:11:42.401666981 +0200 -@@ -75,6 +75,7 @@ - #include "headers/daemon.h" - #include "headers/twiddler.h" - #include "headers/synaptics.h" -+#include "headers/silitek.h" - #include "headers/message.h" - - -@@ -685,6 +686,86 @@ static int M_imps2(Gpm_Event *state, un - - } - -+#define GPM_B_BOTH (GPM_B_LEFT|GPM_B_RIGHT) -+static int M_silitek_ps2(Gpm_Event *state, unsigned char *data) -+{ -+ static int drag = 0; -+ -+ if (!silitek_get_check_ps2(data)) -+ return -1; -+ -+ /* -+ * Map some ghost mouse PS2 events caused by the other -+ * keys. Maybe there is a better initialization for the chip -+ * of the SK-7100 IR receiver which would avoid those events. -+ */ -+ (void)silitek_ghost_ps2(data); -+ -+ /* All none PS2 events */ -+ if (data[0] & 0xc0) -+ { -+ silitek_keys_ps2(data, &drag); -+ return -1; /* Do not highlight, but success */ -+ } -+ -+ state->buttons = ((data[0]&0x01)<<2)|(data[0]&0x02)|((data[0]&0x04)>>2); -+ -+ /* Drag is just a modifier for none mouse keys */ -+ if (state->buttons&GPM_B_LEFT) -+ drag = ((!drag) ? 1 : 0); -+ else -+ drag = 0; -+ -+ if(data[1]) state->dx = (data[0] & 0x10) ? data[1] - 0xFF : data[1]; -+ if(data[2]) state->dy = -((data[0] & 0x20) ? data[2] - 0xFF : data[2]); -+ -+ return 0; -+} -+ -+static int M_silitek(Gpm_Event *state, unsigned char *data) -+{ -+ static int drag = 0; -+ -+ if (!silitek_get_check(data)) -+ return -1; -+ -+ /* All none mouse events */ -+ if (!(data[0] & 0x40)) -+ { -+ silitek_keys(data, &drag); -+ return -1; /* Do not highlight, but success */ -+ } -+ -+ /* -+ * Sanity check: SM-1000 mouse events do not use this bit -+ * but Keyboard SK-7100 PgUp/PgDn/`x' -+ * (0xfe5da5/0xfd5da5/0x7c845d) -+ */ -+ if ((data[1] & 0x40) || (data[2] & 0x40)) -+ return -1; -+ -+ switch(data[0]) -+ { -+ case 0xfe: state->buttons = GPM_B_LEFT; break; -+ case 0xfd: state->buttons = GPM_B_RIGHT; break; -+ case 0x7f: state->buttons = GPM_B_BOTH; break; -+ case 0x7c: state->buttons = 0; break; -+ default: return -1; /* Do not highlight */ -+ break; -+ } -+ -+ /* Drag is just a modifier for none mouse keys */ -+ if (state->buttons&GPM_B_LEFT) -+ drag = ((!drag) ? 1 : 0); -+ else -+ drag = 0; -+ -+ state->dx = (data[1] & 0x20) ? ((data[1] & 0x1f) - 0x20) : (data[1] & 0x1f); -+ state->dy = (data[2] & 0x20) ? ((data[2] & 0x1f) - 0x20) : (data[2] & 0x1f); -+ -+ return 0; -+} -+ - static int M_netmouse(Gpm_Event *state, unsigned char *data) - { - /* Avoid these beasts if you can. They connect to normal PS/2 port, -@@ -763,7 +844,6 @@ static Gpm_Type *I_netmouse(int fd, unsi - return type; - } - --#define GPM_B_BOTH (GPM_B_LEFT|GPM_B_RIGHT) - static int M_mman(Gpm_Event *state, unsigned char *data) - { - /* -@@ -1928,7 +2008,7 @@ static int read_mouse_id(int fd) - * - * Returns 0 if OK, or >0 if 1 or more errors occurred. - */ --static int write_to_mouse(int fd, unsigned char *data, size_t len) -+static int write_to_mouse(int fd, const unsigned char *data, size_t len) - { - int i; - int error = 0; -@@ -1945,6 +2025,89 @@ static int write_to_mouse(int fd, unsign - return(error); - } - -+static Gpm_Type *I_silitek(int fd, unsigned short flags, struct Gpm_Type *type, int argc, char **argv) -+{ -+ struct termios tty; -+ int speed = B1200; -+ fd_silitek = fd; -+ -+ tcgetattr(fd, &tty); -+ cfmakeraw(&tty); -+ cfsetspeed(&tty, speed); -+ tty.c_cc[VMIN] = 1; -+ tty.c_cc[VTIME] = 0; -+ tty.c_cflag |= CS8; -+#if 0 -+ tty.c_cflag &= ~(CRTSCTS|CSTOPB|PARODD); -+ tty.c_cflag |= flags; -+#endif -+ tcsetattr(fd, TCSAFLUSH, &tty); -+ silitek_mapping(); -+ -+ return type; -+} -+ -+static Gpm_Type *I_silitek_ps2(int fd, unsigned short flags, struct Gpm_Type *type, int argc, char **argv) -+{ -+ const unsigned char off[] = {GPM_AUX_DISABLE_DEV, }; -+ const unsigned char buf[] = {GPM_AUX_SET_RES, 3, -+ GPM_AUX_SET_SCALE11, -+ GPM_AUX_SET_SAMPLE, 200, -+ GPM_AUX_ENABLE_DEV, }; -+ int n, c, err, id; -+ -+ fd_silitek = fd; -+ -+ (void)write_to_mouse(fd, off, sizeof(off)); -+ -+ err=1; -+ for (n = 0; n < 3 && err; n++) -+ { -+ err=0; -+ c = GPM_AUX_RESET; -+ write(fd, &c, 1); -+ read(fd, &c, 1); -+ if (c != GPM_AUX_ACK) err++; -+ read(fd, &c, 1); -+ if (c != 0xAA) err++; -+ read(fd, &c, 1); -+ if (c != 0x00) err++; -+ if (err) usleep(50000); -+ } -+ -+ (void)write_to_mouse(fd, buf, sizeof(buf)); -+ usleep(50000); -+ -+ if ((id = read_mouse_id(fd)) == GPM_AUX_ID_ERROR) -+ { -+ if (write_to_mouse(fd, off, sizeof(off))) -+ gpm_report(GPM_PR_ERR,GPM_MESS_SILIPS2_DISABLE); -+ -+ err=1; -+ for (n = 0; n < 3 && err; n++) -+ { -+ err=0; -+ c = GPM_AUX_RESET; -+ write(fd, &c, 1); -+ read(fd, &c, 1); -+ if (c != GPM_AUX_ACK) err++; -+ read(fd, &c, 1); -+ if (c != 0xAA) err++; -+ read(fd, &c, 1); -+ if (c != 0x00) err++; -+ if (err) -+ usleep(50000); -+ } -+ if (err > 0) -+ gpm_report(GPM_PR_ERR,GPM_MESS_SILIPS2_RESET); -+ if (write_to_mouse(fd, buf, sizeof(buf))) -+ gpm_report(GPM_PR_ERR,GPM_MESS_SILIPS2_ENABLE); -+ id = 0x00; -+ } -+ silitek_mapping(); -+ -+ return type; -+} - - /* intellimouse, ps2 version: Ben Pfaff and Colin Plumb */ - /* Autodetect: Steve Bennett */ -@@ -2455,6 +2618,12 @@ Gpm_Type mice[]={ - {"ps2", "Busmice of the ps/2 series. Most busmice, actually.", - "PS/2", M_ps2, I_ps2, STD_FLG, - {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, R_ps2, 1}, -+ {"silips2","Silitek SM-1000 Netshooter plugged into ps/2 mouse connector.", -+ "SiliPS/2", M_silitek_ps2, I_silitek_ps2, STD_FLG, -+ {0x00, 0x00, 0x00, 0x00}, 1, 1, 0, 0, 0, 1}, -+ {"silicom","Silitek SM-1000 Netshooter plugged into serial connector.", -+ "SiliCom", M_silitek, I_silitek, STD_FLG, -+ {0x20, 0x20, 0x00, 0x00}, 1, 1, 0, 0, 0, 0}, - {"sun", "'msc' protocol, but only 3 bytes per packet.", - "", M_sun, I_serial, CS8 | CSTOPB | STD_FLG, - {0xf8, 0x80, 0x00, 0x00}, 3, 1, 0, 0, R_sun, 0}, -Index: src/silitek.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ src/silitek.c 2010-09-08 18:28:24.235054869 +0200 -@@ -0,0 +1,570 @@ -+/* -+ * silitek.c - support for the Silitek SM-1000 (Netshooter) with its IR -+ * receiver plugged serial connector and also with the IR -+ * receiver of the Silitek SK-7100 keyboard (Airboard) -+ * PS2 mouse connector. -+ * -+ * Copyright 2002 Werner Fink -+ * -+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -+ * -+ */ -+ -+/* -+ * Serial settings used herein: raw but I/O with baud rate 1200 and 8bit (YES!) -+ * For testing, e.g.: stty -a < /dev/ttyS1 -+ * To set this, e.g.: stty raw 1200 cs8 < /dev/ttyS1 -+ * For reading keycodes use, e.g.: -+ * od [-j (1|2)] -v -t x1 --width=3 < /dev/ttyS1 -+ * compare with I_silitek() in mice.c. -+ * Which provides following keycodes received by the IR receiver -+ * included in the SM-1000 shipment for the SM-1000 its self: -+ * -+ * First byte: 0xbf (Key down, 8 bit striped this is 0x3f) -+ * 0x31 (Key hold down) -+ * 0x2a (Key up) -+ * 0x7c (Mouse event: move, any button up) -+ * 0x7f (Mouse event: move, l+r-mouse button down) -+ * 0xfd (Mouse event: move, r-mouse button down) -+ * 0xfe (Mouse event: move, l-mouse button down) -+ * Which provides: Any if (byte0 & 0x20) == 0x20 (for GPM protocol check) -+ * Key if (byte0 & 0x40) == 0x00 -+ * Mouse if (byte0 & 0x40) == 0x40 -+ * Second and third byte (unsigned char, aka 8bits): -+ * 1: 0xc1 0xfe -+ * 2: 0xc2 0xfd -+ * 3: 0x43 0x7c -+ * 4: 0xc4 0xfb -+ * 5: 0x45 0x7a -+ * 6: 0x46 0x79 -+ * 7: 0xc7 0xf8 -+ * 8: 0xc8 0xf7 -+ * 9: 0x49 0x76 -+ * 0: 0x4a 0x75 -+ * *: 0xcb 0xf4 -+ * #: 0x4c 0x73 -+ * >: 0xcd 0xf2 -+ * ||: 0xce 0xf1 -+ * []: 0x4f 0x70 -+ * >>|: 0xd0 0xef -+ * |<<: 0x51 0x6e -+ * Mute: 0x52 0x6d -+ * Vol+: 0xd3 0xec -+ * Vol-: 0x54 0x6b -+ * Display: 0xd5 0xea -+ * PgUp: 0xd6 0xe9 -+ * PgDn: 0x57 0x68 -+ * Back: 0x58 0x67 -+ * Forward: 0xd9 0xe6 -+ * CD: 0xda 0xe5 -+ * ShowWiz: 0x5b 0x64 -+ * WWW: 0xdc 0xe3 -+ * Close: 0x5d 0x62 -+ * Which provides: byte1 & 0x20 == 0x00, byte1 & 0x40 == 0x40 -+ * (byte1 & 0x7f) & (byte2 & 0x7f) == 0x40 -+ * (byte1 & 0x7f) | (byte2 & 0x7f) == 0x7f -+ * (byte1 & 0x1f) == keycode -+ * -+ * No mouse move but mouse button: -+ * 0x80 0x80 -+ * Mouse move but no button: -+ * right (byte1 & 0x20) == 0x20 -+ * left (byte2 & 0x20) == 0x20 -+ * value (byte1 & 0x1f), (byte2 & 0x1f) -+ * Mouse move and button: -+ * OR combinations from above. -+ * In both bytes, byte1 and byte2, the 0x40 bit seeems not to be used. -+ * -+ * PS2 settings used herin: Standard PS2 mouse. -+ * For reading keycodes use, e.g.: -+ * od [-j (1|2)] -v -t x1 --width=3 < /dev/psaux -+ * compare with I_silitek_ps2() in mice.c. -+ * Which provides following keycodes received by the IR receiver -+ * included in the SK-7100 shipment for the SM-1000 keys: -+ * -+ * First byte: 0xe7 (Key down) -+ * 0xd7 (Key hold down) -+ * 0xf7 (Key up) -+ * byte0 & 0xc0 == 0x00 (PS2 mouse event) -+ * Which provides: Key if (byte0 & 0xc0) == 0xc0 -+ * Mouse if (byte0 & 0xc0) == 0x00 (PS2 mouse) -+ * In other words: No GPM protocol check. -+ * Second and third byte (unsigned char, aka 8bits): -+ * 1: 0x01 0xfe -+ * 2: 0x02 0xfd -+ * 3: 0x03 0xfc -+ * 4: 0x04 0xfb -+ * 5: 0x05 0xfa -+ * 6: 0x06 0xf9 -+ * 7: 0x07 0xf8 -+ * 8: 0x08 0xf7 -+ * 9: 0x09 0xf6 -+ * 0: 0x0a 0xf5 -+ * *: 0x0b 0xf4 -+ * #: 0x0c 0xf3 -+ * >: 0x0d 0xf2 -+ * ||: 0x0e 0xf1 -+ * []: 0x0f 0xf0 -+ * >>|: 0x10 0xef -+ * |<<: 0x11 0xee -+ * Mute: 0x12 0xed -+ * Vol+: 0x13 0xec -+ * Vol-: 0x14 0xeb -+ * Display: 0x15 0xea -+ * PgUp: 0x16 0xe9 -+ * PgDn: 0x17 0xe8 -+ * Back: 0x18 0xe7 -+ * Forward: 0x19 0xe6 -+ * CD: 0x1a 0xe5 -+ * ShowWiz: 0x1b 0xe4 -+ * WWW: 0x1c 0xe3 -+ * Close: 0x1d 0xe2 -+ * Which provides: byte1 & byte2 == 0x00 -+ * byte1 | byte2 == 0xff -+ * byte1 == keycode -+ * -+ * Mouse is standard PS2 mouse -+ */ -+ -+/* -+ * TODO -+ * Serial part: Find device settings which avoids changing IR sequences of other -+ * vendors like from Sony TV commanders. This because to filter -+ * them out. -+ * PS2 part: Better device settings which avoids the `ghost' mouse events -+ * caused by the other keys. -+ * -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "headers/gpm.h" -+#include "headers/daemon.h" -+#include "headers/silitek.h" -+#include "headers/gpmInt.h" -+#include "headers/message.h" -+ -+int fd_silitek = -1; -+ -+struct silitek_key_struct { -+ char *key; -+ char item[32]; -+ char drag[32]; -+} static K_silitek[] = { -+ /* TERM=linux */ -+ { NULL, "", "" }, -+ {"1", "1", "1" }, -+ {"2", "2", "2" }, -+ {"3", "3", "3" }, -+ {"4", "4", "4" }, -+ {"5", "5", "5" }, -+ {"6", "6", "6" }, -+ {"7", "7", "7" }, -+ {"8", "8", "8" }, -+ {"9", "9", "9" }, -+ {"0", "0", "0" }, -+ {"*", "*", "*" }, -+ {"#", "#", "#" }, -+ {">", "\021", "\021" }, /* Ctrl+Q */ -+ {"||", "\023", "\023" }, /* Ctrl+S */ -+ {"[]", "\003", "\003" }, /* Ctrl+C */ -+ {">>|", "\033[4~", "\033[4~"}, /* End */ -+ {"|<<", "\033[1~", "\033[1~"}, /* Home */ -+ {"Mute", "\033[3~", "\033[3~"}, /* Delete */ -+ {"Vol+", "\033[A", "\033[A" }, /* Cursor up */ -+ {"Vol-", "\033[B", "\033[B" }, /* Cursor down */ -+ {"Display", "\033[2~", "\033[2~"}, /* Insert */ -+ {"PgUp", "\033[5~", "\033[5~"}, /* Page up */ -+ {"PgDn", "\033[6~", "\033[6~"}, /* Page down */ -+ {"Back", "\033[D", "\033[D" }, /* Cursor left */ -+ {"Forward", "\033[C", "\033[C" }, /* Cursor right */ -+ {"CD", "\033[[A", "\033[[A"}, /* F1 */ -+ {"ShowWiz", "\033[[B", "\033[[B"}, /* F2 */ -+ {"WWW", "\033[[C", "\033[[C"}, /* F3 */ -+ {"Close", "\033[[D", "\033[[D"}, /* F4 */ -+ { NULL, "", "" } -+}; -+#define SILITEK_KEYS (sizeof(K_silitek)/sizeof(struct silitek_key_struct)) -+ -+static inline int silitek_wait(int timeout) -+{ -+ fd_set Set; -+ struct timeval tv = {0, timeout}; -+ int ret = 0; -+ -+ do { -+ FD_ZERO(&Set); -+ FD_SET(fd_silitek, &Set); -+ ret = select(fd_silitek+1, &Set, NULL, NULL, &tv); -+ -+ } while (ret < 0 && (errno == EINTR || errno == EAGAIN)); -+ -+ if (ret < 0 || !(FD_ISSET(fd_silitek, &Set))) -+ return 0; -+ return 1; -+} -+ -+static inline int silitek_read(unsigned char *data, int timeout) -+{ -+ ssize_t r = 0; -+ do { -+ if (!silitek_wait(timeout)) -+ break; -+ r = read(fd_silitek, data, 1); -+ -+ } while (r < 0 && (errno == EINTR || errno == EAGAIN)); -+ -+ if(r != 1) -+ return 0; -+ return 1; -+} -+ -+int silitek_get_check(unsigned char *data) -+{ -+ if ((data[0] != 0xbf) && /* key down */ -+ (data[0] != 0x31) && /* key hold down */ -+ (data[0] != 0x2a) && /* key up */ -+ (data[0] != 0x7c) && /* mouse event and/or button up */ -+ (data[0] != 0x7f) && /* mouse event and l+r-mouse button down */ -+ (data[0] != 0xfd) && /* mouse event and r-mouse button down */ -+ (data[0] != 0xfe)) /* mouse event and l-mouse button down */ -+ return 0; -+ if (!silitek_read(&data[1], 50000)) -+ return 0; -+ if (!silitek_read(&data[2], 50000)) -+ return 0; -+#if 0 -+ /* -+ * Sony IR -+ * various, it seems that the bit rate is to high to get stable -+ * bytes in correct order. Or the protocol of such a TV commander -+ * is more complicated than those of the SM-1000 because the IR -+ * receivers of the SM-1000 seems not read this fully correct. -+ */ -+ if (data[0] == 0xfe) { -+ if (data[1] == 0x14 && data[2] == 0x8c) -+ return 0; -+ if (data[1] == 0x94 && (data[2] == 0x8c || data[2] == 0x8d)) -+ return 0; -+ } -+#endif -+ return 1; -+} -+ -+void silitek_keys(unsigned char *data, int *drag) -+{ -+ int ret = 0, unblank = 4, cfd; -+ int but = (data[1] & 0x7f); -+ int chk = (data[2] & 0x7f); -+ int timediff = 0; -+ char *item; -+ -+ if ((but & 0x20) || (but & 0x40) != 0x40) -+ return; -+ if ((but&chk) != 0x40 || (but|chk) != 0x7f) -+ return; -+ but &= 0x1f; -+ chk &= 0x1f; -+ -+ if ((but|chk) != 0x1f) -+ return; -+ if (but < 1 || but > SILITEK_KEYS) -+ return; -+ -+#define GET_TIME(tv) (gettimeofday(&tv, (struct timezone *)NULL)) -+#define DIF_TIME(t1,t2) ((t2.tv_sec-t1.tv_sec)*1000 + (t2.tv_usec-t1.tv_usec)/1000) -+ -+ switch(data[0]) { -+ static struct timeval uptv; -+ struct timeval tv; -+ case 0x2a: -+ uptv.tv_sec = 0; -+ /* fall through */ -+ default: -+ return; -+ break; -+ case 0x31: -+ case 0xbf: -+ GET_TIME(tv); -+ if (!uptv.tv_sec) { -+ uptv.tv_sec = tv.tv_sec; -+ uptv.tv_usec = tv.tv_usec; -+ } -+ timediff = DIF_TIME(uptv, tv); -+ break; -+ } -+ -+#undef GET_TIME -+#undef DIF_TIME -+ -+ if (timediff && timediff < (which_mouse->opt_time)) -+ return; -+ -+ item = K_silitek[but].item; -+ if (*drag) { -+ item = K_silitek[but].drag; -+ but = 0; -+ } -+#if 0 -+ *drag = 0; -+#endif -+ -+ cfd = open_console(O_WRONLY|O_NONBLOCK|O_NOCTTY); -+ if (cfd < 0) -+ return; -+ while (*item && !ret) -+ ret = ioctl(cfd, TIOCSTI, item++); -+ ioctl(cfd, TIOCLINUX, &unblank); -+ close(cfd); -+} -+ -+int silitek_get_check_ps2(unsigned char *data) -+{ -+#if 0 -+ /* -+ * Enable this to trace foreign IR bytes sequences received by -+ * by the IR receiver of the SK-7100 keyboard. -+ */ -+ FILE *log; -+ if (!(log = fopen("/tmp/log", "a"))) -+ return 0; -+ fprintf(log, "TV: 0x%.2x 0x%.2x 0x%.2x\n", data[0], data[1], data[2]); -+ fclose(log); -+#endif -+ if ((data[0] != 0xe7) && /* key down */ -+ (data[0] != 0xd7) && /* key hold down */ -+ (data[0] != 0xf7) && /* key up */ -+ (data[0]&0xc0)) /* PS2 mouse event */ -+ return 0; -+ if (!silitek_read(&data[1], 50000)) -+ return 0; -+ if (!silitek_read(&data[2], 50000)) -+ return 0; -+ /* -+ * Other IR, current known: -+ * -+ * Sony IR -+ * 0x29 0x0c 0xf4 -+ * 0x29 0x14 0xf4 -+ */ -+ if (data[0] == 0x29 && data[2] == 0xf4 && ((data[1] && 0x0c) || (data[1] && 0x14))) { -+ return 0; -+ } -+ return 1; -+} -+ -+void silitek_keys_ps2(unsigned char *data, int *drag) -+{ -+ int ret = 0, unblank = 4, cfd; -+ int but = data[1]; -+ int chk = data[2]; -+ int timediff = 0; -+ char *item; -+ -+ if ((but&chk) && (but|chk) != 0xff) -+ return; -+ -+ if (but < 1 || but > SILITEK_KEYS) -+ return; -+ -+#define GET_TIME(tv) (gettimeofday(&tv, (struct timezone *)NULL)) -+#define DIF_TIME(t1,t2) ((t2.tv_sec-t1.tv_sec)*1000 + (t2.tv_usec-t1.tv_usec)/1000) -+ -+ switch(data[0]) { -+ static struct timeval uptv; -+ struct timeval tv; -+ case 0xe7: -+ uptv.tv_sec = 0; -+ /* fall through */ -+ default: -+ return; -+ break; -+ case 0xd7: -+ case 0xf7: -+ GET_TIME(tv); -+ if (!uptv.tv_sec) { -+ uptv.tv_sec = tv.tv_sec; -+ uptv.tv_usec = tv.tv_usec; -+ } -+ timediff = DIF_TIME(uptv, tv); -+ break; -+ } -+ -+#undef GET_TIME -+#undef DIF_TIME -+ -+ if (timediff && timediff < (which_mouse->opt_time)) -+ return; -+ -+ item = K_silitek[but].item; -+ if (*drag) { -+ item = K_silitek[but].drag; -+ but = 0; -+ } -+#if 0 -+ *drag = 0; -+#endif -+ -+ cfd = open_console(O_WRONLY|O_NONBLOCK|O_NOCTTY); -+ if (cfd < 0) -+ return; -+ while (*item && !ret) -+ ret = ioctl(cfd, TIOCSTI, item++); -+ ioctl(cfd, TIOCLINUX, &unblank); -+ close(cfd); -+} -+ -+/* -+ * Map some ghost mouse PS2 events caused by the other -+ * keys. Maybe there is a better initialization for the chip -+ * of the SK-7100 IR receiver which would avoid those events. -+ */ -+int silitek_ghost_ps2(unsigned char *data) -+{ -+ if (data[0] == 0x18 || data[0] == 0x19) { -+ int but = data[1] - 0xc0; -+ int chk = data[2] - 0x01; -+ -+ if ((but >= 1 && but <= SILITEK_KEYS) && (but == chk)) { -+ data[0] = 0xf7; -+ data[1] = but; -+ data[2] = 0xff - but; -+ } -+ } -+ return 0; -+} -+ -+static char ansicstr_ret[SILISTRLEN+1]; -+static char* ansicstr(char *string) -+{ -+ int c, conv = 0, o; -+ char *ptr = string; -+ char *ret = &ansicstr_ret[0]; -+ -+ memset(&ansicstr_ret[0], 0, sizeof(ansicstr_ret)); -+ while (ptr && *ptr) { -+ switch (c = *ptr++) { -+ case '\\': -+ if (!conv) { -+ conv = 1; -+ continue; -+ } else -+ c = '\\'; -+ conv = 0; break; -+ case 'a': if (conv) c = '\a'; conv = 0; break; -+ case 'b': if (conv) c = '\b'; conv = 0; break; -+ case 't': if (conv) c = '\t'; conv = 0; break; -+ case 'n': if (conv) c = '\n'; conv = 0; break; -+ case 'v': if (conv) c = '\v'; conv = 0; break; -+ case 'f': if (conv) c = '\f'; conv = 0; break; -+ case 'r': if (conv) c = '\r'; conv = 0; break; -+ case 'e': if (conv) c = '\e'; conv = 0; break; -+ case 'E': if (conv) c = '\e'; conv = 0; break; -+ case '0': case '1': case '2': case '3': -+ case '4': case '5': case '6': case '7': -+ if (!conv) break; -+ c -= '0'; -+ for (o = 2; ptr && (*ptr >= '0' && *ptr <= '7' ) && o--; ptr++) -+ c = (c * 8) + (*ptr - '0'); -+ conv = 0; break; -+ case 'x': -+ if (!conv) break; -+ for (o = 3; ptr && isxdigit(*ptr) && o--; ptr++) -+ c = (c * 16) + -+ ((*ptr >= 'a' && *ptr <= 'f') ? (*ptr - 'a' + 10) : -+ ((*ptr >= 'A' && *ptr <= 'F') ? (*ptr - 'A' + 10) : (*ptr - '0'))); -+ if (o == 3) { -+ *ret++ = '\\'; -+ c = 'x'; -+ } -+ conv = 0; break; -+ default: -+ conv = 0; break; -+ } -+ *ret++ = c; -+ } -+ return &ansicstr_ret[0]; -+} -+ -+void silitek_mapping() -+{ -+ static int mapdone = 0; -+ FILE *conf; -+ char line[128]; -+ int k = 1; -+ -+ /* Just in case if called twice with -M option */ -+ if (mapdone) -+ return; -+ mapdone = 1; -+ -+ if (!(conf = fopen(SILI_SYSTEM_FILE, "r"))) { -+ if (errno != ENOENT) -+ gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN,SILI_SYSTEM_FILE); -+ return; -+ } -+ -+ while (fgets(line, 128, conf)) { -+ int n; -+ char key[SILISTRLEN+1], item[SILISTRLEN+1], drag[SILISTRLEN+1]; -+ /* Comments and empty lines */ -+ if (line[0] == '\n' || line[0] == '#') -+ continue; -+ -+ if (line[strlen(line) - 1] == '\n') -+ line[strlen(line) - 1] = '\0'; -+ while (isspace(line[strlen(line) - 1])) -+ line[strlen(line) - 1] = '\0'; -+ -+ if (line[0] == '\0') -+ continue; -+ -+ key[0] = item[0] = drag[0] = '\0'; -+ if ((n = sscanf(line, SILISTRSCN, key, item, drag)) > 1 && n < 4) { -+ while (k < SILITEK_KEYS) { -+ if (!K_silitek[k].key) { -+ k = 1; -+ break; -+ } -+ if (!strncasecmp(key, K_silitek[k].key, SILISTRLEN)) { -+ size_t i = strlen(item), d = strlen(drag); -+ if (d) { -+ if (d > SILISTRLEN) -+ d = SILISTRLEN; -+ strncpy(K_silitek[k].drag, ansicstr(drag), d); -+ K_silitek[k].drag[d] = '\0'; -+ } -+ if (i) { -+ if (i > SILISTRLEN) -+ i = SILISTRLEN; -+ strncpy(K_silitek[k].item, ansicstr(item), i); -+ K_silitek[k].item[i] = '\0'; -+ } -+ break; -+ } -+ k++; -+ } -+ } -+ } -+} diff --git a/gpm-weak-wgetch.patch b/gpm-weak-wgetch.patch new file mode 100644 index 0000000..b03283a --- /dev/null +++ b/gpm-weak-wgetch.patch @@ -0,0 +1,26 @@ +--- src/lib/libcurses.c.weak-wgetch 2002-12-24 17:57:16.000000000 -0500 ++++ src/lib/libcurses.c 2004-03-22 15:51:24.000000000 -0500 +@@ -41,7 +41,12 @@ + #endif /* HAVE_NCURSES_CURSES_H */ + #endif /* HAVE_NCURSES_H */ + +-#define GET(win) ((win) ? wgetch(win) : getch()) ++/* If win != NULL, it must have been created by ncurses anyway. ++ Avoid circular library dependencies. */ ++#pragma weak wgetch ++#pragma weak stdscr ++ ++#define GET(win) ((win && wgetch) ? wgetch(win) : getch()) + + int Gpm_Wgetch(WINDOW *win) + { +--- configure.ac.weak-wgetch 2004-03-22 15:49:51.000000000 -0500 ++++ configure.ac 2004-03-22 15:51:24.000000000 -0500 +@@ -115,7 +115,7 @@ + AC_CHECK_LIB($i, wgetch,,,$TERMLIBS) + else :; fi + done +- SHARED_LIBS="$LIBS $TERMLIBS -lc" ++ SHARED_LIBS="-lc" + LIBS=$SAVELIBS ;; + esac diff --git a/gpm.changes b/gpm.changes index 36b7237..c1ff7b5 100644 --- a/gpm.changes +++ b/gpm.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Jan 27 16:57:52 CET 2011 - pth@suse.de + +- Through out the PS/2 patches that lead to gpm not working. +- Add patches from Fedora. + ------------------------------------------------------------------- Tue Oct 26 16:44:52 UTC 2010 - cristian.rodriguez@opensuse.org diff --git a/gpm.spec b/gpm.spec index bbf3b77..90a9372 100644 --- a/gpm.spec +++ b/gpm.spec @@ -40,15 +40,11 @@ Source2: rcgpm Source3: sysconfig.mouse-%{name} Source4: README.SuSE Source5: baselibs.conf +Source6: inputattach.c Patch0: gpm-DESTDIR.patch -Patch1: gpm-ps2_command_bytes.patch -Patch2: gpm-ps2_read.patch -Patch3: gpm-ps2_reconnection.patch Patch4: gpm-syn_conf.patch -Patch5: gpm-silitek.patch Patch6: gpm-conf.patch Patch7: gpm-va_arg.patch -Patch8: gpm-quiet_libgpm.patch Patch9: gpm-no_templates_for_new_multiple_mode.patch Patch10: gpm-ceil.patch Patch11: gpm-Gpm_Open.patch @@ -58,6 +54,12 @@ Patch17: gpm-log.patch Patch18: gpm-glibc210.patch Patch19: gpm-use_getdtablesize.patch Patch20: gpm-int_ptr_casts.patch +Patch21: gpm-close-fds.patch +Patch22: gpm-gcc4.3.patch +Patch23: gpm-lib-silent.patch +Patch24: gpm-libtool.patch +Patch25: gpm-multilib.patch +Patch26: gpm-weak-wgetch.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build PreReq: %install_info_prereq @@ -86,14 +88,9 @@ Development files for the gpm (general purpose mouse) package. %prep %setup -q %patch0 -%patch1 -%patch2 -%patch3 %patch4 -%patch5 %patch6 %patch7 -%patch8 %patch9 %patch10 %patch11 @@ -103,7 +100,12 @@ Development files for the gpm (general purpose mouse) package. %patch18 %patch19 %patch20 - +%patch21 +%patch22 +%patch23 +%patch24 +%patch25 +%patch26 cp %{S:2} %{S:3} %{S:4} . %build @@ -117,10 +119,11 @@ CFLAGS="$RPM_OPT_FLAGS -DQUIET_LIBGPM" \ %ifarch %arm make CC="gcc -lm" %endif -make +make %{?_smp_mflags} +%__cc %{optflags} -o inputattach %{SOURCE6} %install -make ROOT="" DESTDIR=$RPM_BUILD_ROOT install +%makeinstall ROOT="" # # gpm confings install -d $RPM_BUILD_ROOT/etc/${file/conf\/gpm-/gpm\/} @@ -138,6 +141,7 @@ done install -m 755 -d $RPM_BUILD_ROOT/var/adm/fillup-templates install -m 755 -d $RPM_BUILD_ROOT/etc/init.d install -m 755 -d $RPM_BUILD_ROOT/usr/sbin +install -m 755 inputattach %{buildroot}%{_sbindir} install -m 644 sysconfig.mouse-%{name} $RPM_BUILD_ROOT/var/adm/fillup-templates install -m 755 rcgpm $RPM_BUILD_ROOT/etc/init.d/gpm ln -sf ../../etc/init.d/gpm $RPM_BUILD_ROOT/usr/sbin/rcgpm diff --git a/inputattach.c b/inputattach.c new file mode 100644 index 0000000..d14ec0c --- /dev/null +++ b/inputattach.c @@ -0,0 +1,475 @@ +/* + * $Id: inputattach.c,v 1.2 2007/04/02 14:18:54 tjanouse Exp $ + * + * Copyright (c) 1999-2000 Vojtech Pavlik + * + * Sponsored by SuSE + * + * Twiddler support Copyright (c) 2001 Arndt Schoenewald + * Sponsored by Quelltext AG (http://www.quelltext-ag.de), Dortmund, Germany + */ + +/* + * Input line discipline attach program + */ + +/* + * 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., 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 , or by paper mail: + * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic + */ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +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; + + return 0; +} + + + +void setline(int fd, int flags, int speed) +{ + struct termios t; + + tcgetattr(fd, &t); + + t.c_cflag = flags | CREAD | HUPCL | CLOCAL; + t.c_iflag = IGNBRK | IGNPAR; + t.c_oflag = 0; + t.c_lflag = 0; + t.c_cc[VMIN ] = 1; + t.c_cc[VTIME] = 0; + + cfsetispeed(&t, speed); + cfsetospeed(&t, speed); + + tcsetattr(fd, TCSANOW, &t); +} + +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)) + return -1; + if (c[i] != d) + return -1; + } + return 0; +} + +int magellan_init(int fd, long *id, long *extra) +{ + write(fd, "m3\rpBB\rz\r", 9); + return 0; +} + +int warrior_init(int fd, long *id, long *extra) +{ + 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) +{ + unsigned char b = 0; + + while (!readchar(fd, &b, timeout)) { + if (b == 0x0a) continue; + *d++ = b; + if (b == c) break; + } + + *d = 0; + + return -(b != c); +} + +int spaceball_waitcmd(int fd, char c, char *d) +{ + int i; + + for (i = 0; i < 8; i++) { + if (spaceball_waitchar(fd, 0x0d, d, 1000)) + return -1; + if (d[0] == c) + return 0; + } + + return -1; +} + +int spaceball_cmd(int fd, char *c, char *d) +{ + int i; + + for (i = 0; c[i]; i++) + write(fd, c + i, 1); + write(fd, "\r", 1); + + i = spaceball_waitcmd(fd, toupper(c[0]), d); + + return i; +} + +#define SPACEBALL_1003 1 +#define SPACEBALL_2003B 3 +#define SPACEBALL_2003C 4 +#define SPACEBALL_3003C 7 +#define SPACEBALL_4000FLX 8 +#define SPACEBALL_4000FLX_L 9 + +int spaceball_init(int fd, long *id, long *extra) +{ + char r[64]; + + if (spaceball_waitchar(fd, 0x11, r, 4000) || + spaceball_waitchar(fd, 0x0d, r, 1000)) + return -1; + + if (spaceball_waitcmd(fd, '@', r)) + return -1; + + if (strncmp("@1 Spaceball alive", r, 18)) + return -1; + + if (spaceball_waitcmd(fd, '@', r)) + return -1; + + if (spaceball_cmd(fd, "hm", r)) + return -1; + + if (!strncmp("Hm2003B", r, 7)) + *id = SPACEBALL_2003B; + if (!strncmp("Hm2003C", r, 7)) + *id = SPACEBALL_2003C; + if (!strncmp("Hm3003C", r, 7)) + *id = SPACEBALL_3003C; + + if (!strncmp("HvFirmware", r, 10)) { + + if (spaceball_cmd(fd, "\"", r)) + return -1; + + if (strncmp("\"1 Spaceball 4000 FLX", r, 21)) + return -1; + + if (spaceball_waitcmd(fd, '"', r)) + return -1; + + if (strstr(r, " L ")) + *id = SPACEBALL_4000FLX_L; + else + *id = SPACEBALL_4000FLX; + + if (spaceball_waitcmd(fd, '"', r)) + return -1; + + if (spaceball_cmd(fd, "YS", r)) + return -1; + + if (spaceball_cmd(fd, "M", r)) + return -1; + + return 0; + } + + if (spaceball_cmd(fd, "P@A@A", r) || + spaceball_cmd(fd, "FT@", r) || + spaceball_cmd(fd, "MSS", r)) + return -1; + + return 0; +} + +int stinger_init(int fd, long *id, long *extra) +{ + int i; + unsigned char c; + unsigned char *response = "\r\n0600520058C272"; + + if (write(fd, " E5E5", 5) != 5) /* Enable command */ + return -1; + + for (i = 0; i < 16; i++) /* Check for Stinger */ + if (readchar(fd, &c, 200) || (c != response[i])) + return -1; + + return 0; +} + +int mzp_init(int fd, long *id, long *extra) +{ + if (logitech_command(fd, "*X*q")) return -1; + setline(fd, CS8, B9600); + return 0; +} + +int newton_init(int fd, long *id, 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 }; + + for (i = 0; i < 35; i++) + if (readchar(fd, &c, 400) || (c != response[i])) + return -1; + + return 0; +} + +int twiddler_init(int fd, long *id, 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; + line &= ~TIOCM_DTR; + if (ioctl(fd, TIOCMSET, &line)) return -1; + + /* 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. */ + + /* 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 (count == 5) { + /* Could not find header byte in data stream */ + return -1; + } + + /* Read remaining 4 bytes plus the full next data packet */ + 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 */ + return -1; + } + } + + return 0; +} + +int dump_init(int fd, long *id, long *extra) +{ + unsigned char c, o = 0; + + c = 0x80; + + if (write(fd, &c, 1) != 1) /* Enable command */ + return -1; + + while (1) + if (!readchar(fd, &c, 1)) { + printf("%02x (%c) ", c, ((c > 32) && (c < 127)) ? c : 'x'); + o = 1; + } else { + if (o) { + printf("\n"); + o = 0; + } + } +} + +struct input_types { + char name[16]; + char name2[16]; + int speed; + int flags; + unsigned long type; + unsigned long id; + unsigned long extra; + int flush; + int (*init)(int fd, long *id, long *extra); +}; + +struct input_types input_types[] = { + +{ "--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 } + +}; + +int main(int argc, char **argv) +{ + unsigned long devt; + int ldisc; + int type; + long id, extra; + int fd; + char c; + + if (argc < 2 || argc > 4 || (argc == 4 && strcmp(argv[3], "--daemon")) || !strcmp("--help", argv[1])) { + puts(""); + puts("Usage: inputttach "); + 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 (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 (!input_types[type].speed) { + fprintf(stderr, "inputattach: invalid mode\n"); + return 1; + } + + if ((fd = open(argv[2], O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) { + perror("inputattach"); + return 1; + } + + setline(fd, input_types[type].flags, input_types[type].speed); + + if (input_types[type].flush) + while (!readchar(fd, &c, 100)); + + id = input_types[type].id; + extra = input_types[type].extra; + + if (input_types[type].init && input_types[type].init(fd, &id, &extra)) { + fprintf(stderr, "inputattach: device initialization failed\n"); + return 1; + } + + ldisc = N_MOUSE; + if(ioctl(fd, TIOCSETD, &ldisc)) { + fprintf(stderr, "inputattach: can't set line discipline\n"); + return 1; + } + + devt = input_types[type].type | (id << 8) | (extra << 16); + + if(ioctl(fd, SPIOCSTYPE, &devt)) { + fprintf(stderr, "inputattach: can't set device type\n"); + return 1; + } + + if (argc == 4 && !strcmp(argv[3],"--daemon")) + daemon(0,0); + + read(fd, NULL, 0); + + ldisc = 0; + ioctl(fd, TIOCSETD, &ldisc); + close(fd); + + return 0; +}