From 125ea367eaf49828d74c9b5111e327a4bc7c8f06 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 01/19] Add no-op option -V for compatibility Gbp-Pq: Name 001_missing_V_option.patch --- src/daemon/cmdline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c index 66c8ecc..4cc0955 100644 --- a/src/daemon/cmdline.c +++ b/src/daemon/cmdline.c @@ -32,7 +32,7 @@ void cmdline(int argc, char **argv) { extern struct options option; - char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:Tuv23"; + char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TuvV23"; int opt; /* initialize for the dual mouse */ @@ -81,6 +81,7 @@ void cmdline(int argc, char **argv) case 'u': option.autodetect = 1; break; case 'T': opt_test++; break; case 'v': printf(GPM_MESS_VERSION "\n"); exit(0); + case 'V': /* Compat code */ break; case '2': (which_mouse->opt_three) = -1; break; case '3': (which_mouse->opt_three) = 1; break; default: exit(usage("commandline")); From b4507c7c20df38402822f0a834d34e2bce27b1fb Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 02/19] _force_repeat_000 Gbp-Pq: Name 002_force_repeat_000 --- src/daemon/cmdline.c | 6 +++++- src/daemon/getmousedata.c | 5 +++-- src/daemon/old_main.c | 2 +- src/daemon/processmouse.c | 2 +- src/headers/daemon.h | 1 + src/headers/message.h | 1 + 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c index 4cc0955..b3618cb 100644 --- a/src/daemon/cmdline.c +++ b/src/daemon/cmdline.c @@ -32,7 +32,7 @@ void cmdline(int argc, char **argv) { extern struct options option; - char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TuvV23"; + char options[]="a:A::b:B:d:DFg:hi:kl:m:Mo:pr:R::s:S:t:TuvV23"; int opt; /* initialize for the dual mouse */ @@ -60,6 +60,10 @@ void cmdline(int argc, char **argv) if (option.repeater_type == 0) option.repeater_type = "msc"; which_mouse=mouse_table+2; break; + case 'F': option.repeater++; option.force_repeat = 1; + if (option.repeater_type == 0) + option.repeater_type = "msc"; + break; case 'o': add_mouse(GPM_ADD_OPTIONS,optarg); gpm_report(GPM_PR_DEBUG,"options: %s",optarg); (which_mouse->opt_options) = optarg; break; /* GO AWAY */ diff --git a/src/daemon/getmousedata.c b/src/daemon/getmousedata.c index b1c69d8..db53a6a 100644 --- a/src/daemon/getmousedata.c +++ b/src/daemon/getmousedata.c @@ -48,7 +48,7 @@ char *getMouseData(int fd, Gpm_Type *type, int kd_mode) return NULL; } - if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep) + if ((kd_mode!=KD_TEXT || option.force_repeat) && fifofd != -1 && opt_rawrep) write(fifofd, data, howmany); if ((data[0]&((which_mouse->m_type)->proto)[0]) != ((which_mouse->m_type)->proto)[1]) { @@ -71,7 +71,8 @@ char *getMouseData(int fd, Gpm_Type *type, int kd_mode) if((i=(which_mouse->m_type)->packetlen-howmany)) /* still to get */ do { j = read(fd,edata-i,i); /* edata is pointer just after data */ - if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep && j > 0) + if ((kd_mode!=KD_TEXT || option.force_repeat) + && fifofd != -1 && opt_rawrep && j > 0) write(fifofd, edata-i, j); i -= j; } while (i && j); diff --git a/src/daemon/old_main.c b/src/daemon/old_main.c index 9cd4e56..dc6aafa 100644 --- a/src/daemon/old_main.c +++ b/src/daemon/old_main.c @@ -168,7 +168,7 @@ int old_main() if (ioctl(fd, KDGETMODE, &kd_mode) < 0) gpm_report(GPM_PR_OOPS,GPM_MESS_IOCTL_KDGETMODE); close(fd); - if(kd_mode != KD_TEXT && !option.repeater) { + if(kd_mode != KD_TEXT && !option.repeater && !option.force_repeat) { wait_text(&mouse_table[1].fd); maxfd=max(maxfd,mouse_table[1].fd); readySet=connSet; diff --git a/src/daemon/processmouse.c b/src/daemon/processmouse.c index b3f3994..1d94ffe 100644 --- a/src/daemon/processmouse.c +++ b/src/daemon/processmouse.c @@ -131,7 +131,7 @@ int processMouse(int fd, Gpm_Event *event, Gpm_Type *type, int kd_mode) /*....................................... we're a repeater, aren't we? */ - if (kd_mode!=KD_TEXT) { + if (kd_mode!=KD_TEXT || option.force_repeat) { if (fifofd != -1 && ! opt_rawrep) { if ((which_mouse->m_type)->absolute) { /* hof Wed Feb 3 21:43:28 MET 1999 */ /* prepare the values from a absolute device for repeater mode */ diff --git a/src/headers/daemon.h b/src/headers/daemon.h index a8936ad..1313121 100644 --- a/src/headers/daemon.h +++ b/src/headers/daemon.h @@ -47,6 +47,7 @@ struct options { char *progname; /* hopefully gpm ;) */ struct micetab *micelist; /* mice and their options */ char *consolename; /* /dev/tty0 || /dev/vc/0 */ + int force_repeat; /* force click repeat */ }; typedef struct Gpm_Cinfo { diff --git a/src/headers/message.h b/src/headers/message.h index a0fed0e..cac128c 100644 --- a/src/headers/message.h +++ b/src/headers/message.h @@ -92,6 +92,7 @@ " -R mouse-type enter repeater mode. X should read /dev/gpmdata\n" \ " like it was a mouse-type device. Default is MouseSystems.\n" \ " You can also specify \"raw\" to relay the raw device data.\n" \ + " -F Always force repeat mode.\n" \ " -s sample-rate sets the sample rate (default %d)\n" \ " -S [commands] enable special commands (see man page)\n" \ " -t mouse-type sets mouse type (default '%s')\n" \ From 027d51d74851b7fd819caa18a6e9ae0f39a80f88 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 03/19] _types_000 Gbp-Pq: Name 005_types_000 --- src/daemon/add_mouse.c | 1 + src/daemon/startup.c | 2 +- src/headers/message.h | 1 + src/mice.c | 71 ++++++++++++++++++++++++++++-------------- 4 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/daemon/add_mouse.c b/src/daemon/add_mouse.c index 5507246..5a9cdc1 100644 --- a/src/daemon/add_mouse.c +++ b/src/daemon/add_mouse.c @@ -86,6 +86,7 @@ void add_mouse(int type, char *value) /*---------------------------------------------------------------------*/ case GPM_ADD_TYPE: + if (!strcmp(value, "types")) exit(M_listTypes()); if(option.micelist == NULL) gpm_report(GPM_PR_OOPS,GPM_MESS_FIRST_DEV); /* skip to next mouse, where either device or protocol is missing */ diff --git a/src/daemon/startup.c b/src/daemon/startup.c index 1d00255..e76b348 100644 --- a/src/daemon/startup.c +++ b/src/daemon/startup.c @@ -106,7 +106,7 @@ void startup(int argc, char **argv) /* look for the mouse type */ (which_mouse->m_type) = find_mouse_by_name((which_mouse->opt_type)); if (!(which_mouse->m_type)) /* not found */ - exit(M_listTypes()); + exit(M_listMice()); } /* Check repeater status */ diff --git a/src/headers/message.h b/src/headers/message.h index cac128c..f426a85 100644 --- a/src/headers/message.h +++ b/src/headers/message.h @@ -97,6 +97,7 @@ " -S [commands] enable special commands (see man page)\n" \ " -t mouse-type sets mouse type (default '%s')\n" \ " Use a non-existent type (e.g. \"help\") to get a list\n" \ + " or \"types\" to get a list of just the mnemonics.\n" \ " -T test: read mouse, no clients\n" \ " -v print version and exit\n" \ " -V verbosity increase number of logged messages\n\n\n" \ diff --git a/src/mice.c b/src/mice.c index 6cbd491..52597ba 100644 --- a/src/mice.c +++ b/src/mice.c @@ -2373,28 +2373,32 @@ static Gpm_Type *I_wp(int fd, unsigned short flags, Gpm_Type mice[]={ - {"mman", "The \"MouseMan\" and similar devices (3/4 bytes per packet).", + {"mman", "The MouseMan protocol used by new Logitech mice.", "Mouseman", M_mman, I_serial, CS7 | STD_FLG, /* first */ {0x40, 0x40, 0x40, 0x00}, 3, 1, 1, 0, 0}, - {"ms", "The original ms protocol, with a middle-button extension.", + {"ms", "For Microsoft mice (2 or 3 buttons). Some old 2 button mice\n" + " send some spurious packets, which can be misunderstood as\n" + " middle-button events. If this is happening to you, use the\n" + " 'bare' mouse type.", "", M_ms, I_serial, CS7 | STD_FLG, {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, - {"acecad", "Acecad tablet absolute mode(Sumagrapics MM-Series mode)", + {"acecad", "For Acecad tablet in absolute mode(Sumagrapics MM-Series mode)", "", M_summa, I_summa, STD_FLG, {0x80, 0x80, 0x00, 0x00}, 7, 1, 0, 1, 0}, - {"bare", "Unadorned ms protocol. Needed with some 2-buttons mice.", + {"bare", "For some 2 button Microsoft mice. Same as 'ms except that\n" + " gpm will not attempt to simulate a third button.", "Microsoft", M_bare, I_serial, CS7 | STD_FLG, {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, - {"bm", "Micro$oft busmice and compatible devices.", + {"bm", "For some busmice, including Microsoft and Logitech busmice.", "BusMouse", M_bm, I_empty, STD_FLG, /* bm is sun */ {0xf8, 0x80, 0x00, 0x00}, 3, 3, 0, 0, 0}, - {"brw", "Fellowes Browser - 4 buttons (and a wheel) (dual protocol?)", + {"brw", "For the 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}, - {"cal", "Calcomp UltraSlate", + {"cal", "For a Calcomp UltraSlate", "", M_calus, I_calus, CS8 | CSTOPB | STD_FLG, {0x80, 0x80, 0x80, 0x00}, 6, 6, 0, 1, 0}, - {"calr", "Calcomp UltraSlate - relative mode", + {"calr", "For a Calcomp UltraSlate in relative mode.", "", M_calus_rel, I_calus, CS8 | CSTOPB | STD_FLG, {0x80, 0x80, 0x80, 0x00}, 6, 6, 0, 0, 0}, {"etouch", "EloTouch touch-screens (only button-1 events, by now)", @@ -2409,7 +2413,7 @@ Gpm_Type mice[]={ "ExplorerPS/2", M_imps2, I_exps2, STD_FLG, {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, #ifdef HAVE_LINUX_JOYSTICK_H - {"js", "Joystick mouse emulation", + {"js", "For joystick mouse emulation", "Joystick", M_js, NULL, 0, {0xFC, 0x00, 0x00, 0x00}, 12, 12, 0, 0, 0}, #endif @@ -2419,19 +2423,21 @@ Gpm_Type mice[]={ {"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}, - {"imps2","Microsoft Intellimouse (ps2)-autodetect 2/3 buttons,wheel unused", + {"imps2","For the Microsoft IntelliMouse on a PS/2 port (round\n" + " connector with 6 pins), 3 buttons (wheel is repeated).", "", M_imps2, I_imps2, STD_FLG, {0xC0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, R_imps2}, - {"logi", "Used in some Logitech devices (only serial).", + {"logi", "For old serial Logitech mice.", "Logitech", M_logi, I_logi, CS8 | CSTOPB | STD_FLG, {0xe0, 0x80, 0x80, 0x00}, 3, 3, 0, 0, 0}, - {"logim", "Turn logitech into Mouse-Systems-Compatible.", + {"logim", "For turning on the MouseSystems compatible mode (3 buttons)\n" + " of some Logitech mice", "", M_logimsc, I_serial, CS8 | CSTOPB | STD_FLG, {0xf8, 0x80, 0x00, 0x00}, 5, 1, 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}, - {"ms3", "Microsoft Intellimouse (serial) - 3 buttons, wheel unused", + {"ms3", "For the Microsoft Intellimouse (serial), 3 buttons (wheel is repeated).", "", M_ms3, I_pnp, CS7 | STD_FLG, {0xc0, 0x40, 0xc0, 0x00}, 4, 1, 0, 0, R_ms3}, {"ms+", "Like 'ms', but allows dragging with the middle button.", @@ -2440,37 +2446,40 @@ Gpm_Type mice[]={ {"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}, - {"msc", "Mouse-Systems-Compatible (5bytes). Most 3-button mice.", + {"msc", "For most 3 button serial mice.", "MouseSystems", M_msc, I_serial, CS8 | CSTOPB | STD_FLG, {0xf8, 0x80, 0x00, 0x00}, 5, 1, 0, 0, R_msc}, - {"mtouch", "MicroTouch touch-screens (only button-1 events, by now)", + {"mtouch", "For MicroTouch touch-screens (only button-1 events right now)", "", M_mtouch, I_mtouch, STD_FLG, {0x80, 0x80, 0x80, 0x00}, 5, 1, 0, 1, NULL}, {"ncr", "Ncr3125pen, found on some laptops", "", M_ncr, NULL, STD_FLG, {0x08, 0x08, 0x00, 0x00}, 7, 7, 0, 1, 0}, - {"netmouse","Genius NetMouse (ps2) - 2 buttons and 2 buttons 'up'/'down'.", + {"netmouse","For the 'Genius NetMouse'. This one has two normal buttons plus\n" + " 'up'/'down' buttons.", "", M_netmouse, I_netmouse, CS7 | STD_FLG, {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, - {"pnp", "Plug and pray. New mice may not run with '-t ms'.", + {"pnp", "For the new 'plug and play' mice produced by Microsoft.\n" + " Try it if '-t ms' does not work.", "", M_bare, I_pnp, CS7 | STD_FLG, {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, - {"ps2", "Busmice of the ps/2 series. Most busmice, actually.", + {"ps2", "For most busmice connected to a PS/2 port (round with 6 metal\n" + " pins).", "PS/2", M_ps2, I_ps2, STD_FLG, {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, R_ps2}, - {"sun", "'msc' protocol, but only 3 bytes per packet.", + {"sun", "For Sun (Sparc) mice.", "", M_sun, I_serial, CS8 | CSTOPB | STD_FLG, {0xf8, 0x80, 0x00, 0x00}, 3, 1, 0, 0, R_sun}, - {"summa", "Summagraphics or Genius tablet absolute mode(MM-Series)", + {"summa", "For a Summa/Genius tablet in absolute mode (906, 1212B, EasyPainter...)", "", M_summa, I_summa, STD_FLG, {0x80, 0x80, 0x00, 0x00}, 5, 1, 0, 1, R_summa}, - {"syn", "The \"Synaptics\" serial TouchPad.", + {"syn", "For the 'Synaptics' serial TouchPad.", "synaptics", M_synaptics_serial, I_serial, CS7 | STD_FLG, {0x40, 0x40, 0x40, 0x00}, 6, 6, 1, 0, 0}, - {"synps2", "The \"Synaptics\" PS/2 TouchPad", + {"synps2", "For the 'Synaptics' PS/2 TouchPad", "synaptics_ps2", M_synaptics_ps2, I_synps2, STD_FLG, {0x80, 0x80, 0x00, 0x00}, 6, 1, 1, 0, 0}, - {"twid", "Twidddler keyboard", + {"twid", "For the 'Twidddler' keyboard.", "", M_twid, I_twid, CS8 | STD_FLG, {0x80, 0x00, 0x80, 0x80}, 5, 1, 0, 0, 0}, {"vsxxxaa", "The DEC VSXXX-AA/GA serial mouse on DEC workstations.", @@ -2490,7 +2499,7 @@ Gpm_Type mice[]={ /*------------------------------------------------------------------------*/ /* and the help */ -int M_listTypes(void) +int M_listMice(void) { Gpm_Type *type; @@ -2505,6 +2514,20 @@ int M_listTypes(void) return 1; /* to exit() */ } +int M_listTypes(void) +{ + Gpm_Type *type; + + /* Only print the mouse mnemonics so that it is easy to parse */ + for (type = mice; type->fun; type++) + { + puts(type->name); + if (type->synonyms[0] != '\0') + puts(type->synonyms); + } + return 1; +} + /* indent: use three spaces. no tab. not two or four. three */ /* Local Variables: */ From dfad6ebfec5d795f43635ef329d14ea06bc91d75 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 04/19] Misc. documentation fixes and man-page renamings Gbp-Pq: Name 007_doc_fix_000 --- doc/Makefile.in | 8 ++++---- doc/doc.gpm.in | 39 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/doc/Makefile.in b/doc/Makefile.in index 709fa6d..d6efd23 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -30,7 +30,7 @@ top_builddir = .. include $(top_builddir)/Makefile.include -MANPAGES = gpm.8 mev.1 gpm-root.1 gpm-types.7 mouse-test.1 +MANPAGES = gpm.8 mev.1 gpm-root.1 gpm-types.7 gpm-mouse-test.8 all: $(srcdir)/gpm.info gpm.man @@ -60,7 +60,7 @@ all: $(srcdir)/gpm.info gpm.man $(MANPAGES): gpm.man gpm.man: doc.gpm $(srcdir)/manpager $(AWK) -f $(srcdir)/manpager doc.gpm - for i in gpm-root.1 gpm-types.7 gpm.8 mev.1 mouse-test.1; do \ + for i in gpm-root.1 gpm-types.7 gpm.8 mev.1 gpm-mouse-test.8; do \ expand $$i | sed s/^'[ ]*'//g > $$i.new; \ mv $$i.new $$i; \ done; @@ -115,7 +115,7 @@ installdirs: install: all installdirs $(INSTALL_DATA) -m 644 mev.1 $(man1dir) - $(INSTALL_DATA) -m 644 mouse-test.1 $(man1dir) + $(INSTALL_DATA) -m 644 gpm-mouse-test.8 $(man8dir) $(INSTALL_DATA) -m 644 gpm-root.1 $(man1dir) $(INSTALL_DATA) -m 644 gpm-types.7 $(man7dir) $(INSTALL_DATA) -m 644 gpm.8 $(man8dir) @@ -139,7 +139,7 @@ install: all installdirs # e.g. /var/cache/man/cat1/mev.1.gz. Deleting these is not our job, # but the job of the man program on the host. uninstall: - cd $(man1dir) && rm -f mev.1 mouse-test.1 gpm-root.1 + cd $(man1dir) && rm -f mev.1 gpm-mouse-test.8 gpm-root.1 rm -f $(man7dir)/gpm-types.7 $(man8dir)/gpm.8 rm -f $(infodir)/gpm.info $(infodir)/gpm.info.gz -if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ diff --git a/doc/doc.gpm.in b/doc/doc.gpm.in index afd5a29..77a4d42 100644 --- a/doc/doc.gpm.in +++ b/doc/doc.gpm.in @@ -411,8 +411,9 @@ Available command line options are the following: @item \-r @var{number} - Set the responsiveness. A higher responsiveness is used for a faster - cursor motion. + Set the responsiveness as a percentage of motion (1 to 100, default + 10). A lower number can be used to slow down cursor motion, this can + not be used to make a mouse move faster, see @samp{-a}. @item \-R[@var{name}] Causes @code{gpm} to act as a repeater: any mouse data received while @@ -441,10 +442,7 @@ Available command line options are the following: @item \-t @var{name} Set the mouse type. Use @samp{\-t help} to get a list - of allowable types. Since version 1.18.1, the list also shows - which protocols are available as repeaters (see @t{\-R} above), - by marking them with an asterisk (``@t{*}''). - @xref{Mouse Types}. + of allowable types. @xref{Mouse Types}. Use \-t after you selected the mouse device with \-m. @item \-v @@ -547,8 +545,7 @@ the source distribution of gpm. .SH SEE ALSO .nf -\fB mev(1)\fP A sample client for the gpm daemon. -\fB gpm-root(1)\fP An handler for Control-Mouse events. +\fB gpm-types(7)\fP Description of current pointer types supported by gpm .fi The info file about `gpm', which gives more complete information and @@ -900,6 +897,10 @@ following: The change in position since the last reported event. +@item short wdx, wdy; + The change in horizontal and vertical wheel positions since the + last reported event. + @item enum Gpm_Etype type; A bit-mask, representing the type of reported event, as described later. @@ -1629,8 +1630,7 @@ fields: %......................................................................... -@deftypefun Gpm_Roi* Gpm_PushRoi (int @var{xmin}, int @var{ymin}, int @var{xmax}, int @var{ymax}, - int @var{mask}, Gpm_Handler *@var{fun}, void *@var{xtradata}); +@deftypefun Gpm_Roi* Gpm_PushRoi (int @var{xmin}, int @var{ymin}, int @var{xmax}, int @var{ymax}, int @var{mask}, Gpm_Handler *@var{fun}, void *@var{xtradata}); This function pushes a Region of Interest on top of the stack, after @@ -1732,7 +1732,7 @@ hpux-8.x and Ultrix-3.0. * Emacs Support:: * gpm-root:: * hltest:: -* mouse-test:: +* gpm-mouse-test:: @end menu %========================================================================== @@ -1860,7 +1860,6 @@ Ian Zimmerman .SH SEE ALSO .nf \fB gpm(8) \fP The mouse server -\fB gpm-root(1) \fP An handler for Control-Mouse events. .fi The info file about `gpm', which gives more complete information and @@ -2203,7 +2202,7 @@ explains how to write a gpm client. %MANPAGE END %========================================================================== -@node hltest, mouse-test, gpm-root, Demo Clients +@node hltest, gpm-mouse-test, gpm-root, Demo Clients @section @code{hltest} High-level test is a simple sample application using the high-level @@ -2215,15 +2214,15 @@ high-level library. It is equipped with event reporting to help in understanding the internal workings. %========================================================================== -@node mouse-test, , hltest, Demo Clients -@section @code{mouse-test} +@node gpm-mouse-test, , hltest, Demo Clients +@section @code{gpm-mouse-test} -%MANPAGE mouse-test.1 -%M .TH mouse-test 1 "March 26, 1998" "" +%MANPAGE gpm-mouse-test.8 +%M .TH gpm-mouse-test 8 "March 26, 1998" "" %M .SH NAME -%M mouse-test \- a tool for determining mouse type and device it's attached to. +%M gpm-mouse-test \- a tool for determining mouse type and device it's attached to. %M .SH SYNTAX -%M \fBmouse-test\fR [ \fIdevice\fR ... ] +%M \fBgpm-mouse-test\fR [ \fIdevice\fR ... ] %M .SH DESCRIPTION This experimental and incomplete application tries to help in detecting @@ -2243,7 +2242,7 @@ from my laziness. .IP \fIdevice\fP [ \fIdevice\fP ... ] .PP -Check this \fIdevice\fP for a mouse. If no devices are listed, mouse-test will try all possible devices. +Check this \fIdevice\fP for a mouse. If no devices are listed, gpm-mouse-test will try all possible devices. .SH AUTHOR Alessandro Rubini From 804abf6502f4a648287c426bdd137e0f0775a0f3 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 05/19] _doc_fix_001 Description Fixes to awk manpages script Gbp-Pq: Name 007_doc_fix_001 --- doc/manpager | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/doc/manpager b/doc/manpager index c7b1119..8b94ac5 100755 --- a/doc/manpager +++ b/doc/manpager @@ -1,10 +1,21 @@ #! /usr/bin/awk -f # Copyright (c) 1998-2001 Alessandro Rubini +function eat(pat, start, stop) +{ + N = split($0, arr, "@"pat"{"); + res = arr[1]; + for (i = 2; i <= N; i++) { + sub("}", stop, arr[i]); + res = res start arr[i]; + } + $0 = res; +} + BEGIN {IN=0} /^%MANPAGE END/ {IN=0; next} -/^%MANPAGE/ {IN=1; USELP=NEEDLP=INTABLE=0; NAME=$2; next} +/^%MANPAGE/ {IN=1; USELP=NEEDLP=0; NAME=$2; next} IN==0 {next} /^%MSKIP/ {SKIP=1;next} @@ -22,32 +33,13 @@ SKIP==1 {next} { gsub("^%M ?",""); } -# Use gensub for converting tags: itz Sep 30 1998 +# Use eat for converting tags # -# However, the gensub function is gawk-specific, and we want things -# to work with original-awk too (for portability). -# Therefore, use a normal gsub, even though it's a subobptimal solution -# as it may step in extra braces. The good solution will be piping to sed, -# or match, extract subesxpression, replace, reinsert -- bleah... -# (ARub, Oct 10 2000) -/@b\{/ { - #$0 = gensub(/@b\{([^}]+)\}/, "\\\\fB\\1\\\\fP","g"); - gsub("@b\{","\\fB"); - gsub("\}","\\fP"); -} - -/@var\{/ { - #$0 = gensub(/@var\{([^}]+)\}/, "\\\\fI\\1\\\\fP","g"); - gsub("@var\{","\\fB"); - gsub("\}","\\fP"); -} - -/@(samp|code|file)\{/ { - #$0 = gensub(/@(samp|code|file)\{([^}]+)\}/, "`\\2'","g"); - gsub("@(samp|code|file)\{",""); - gsub("\}",""); -} - +/@b\{/ {eat("b", "\\fB", "\\fP")} +/@samp\{/ {eat("samp", "`", "'")} +/@code\{/ {eat("code", "`", "'")} +/@file\{/ {eat("file", "`", "'")} +/@var\{/ {eat("var", "\\fI", "\\fP")} /@xref\{.*\}\./ { gsub(/@xref\{.*\}\./,""); @@ -96,7 +88,7 @@ SKIP==1 {next} # remove leading blanks -/^[ \t]/ {gsub("^[ \t]","");} +/^[ \t]/ {sub("^[ \t]*","")} # put a .LP at blank lines @@ -112,7 +104,7 @@ SKIP==1 {next} # Escape single slashes (e.g. in documentation for `-l' command line option) - {gsub("\\\\ ", "\\\\ ");} + {gsub("\\\\ ", "\\\\&");} {gsub("~", "~~");} From 1da0bfc56c1259f7f1dd462dc672dafb86a8673d Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 06/19] Remove FAQ entries about compilation issues Gbp-Pq: Name 007_doc_fix_FAQ --- doc/FAQ | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/doc/FAQ b/doc/FAQ index 90b8626..d393eaf 100644 --- a/doc/FAQ +++ b/doc/FAQ @@ -19,31 +19,6 @@ __( )/( )__ rubini@prosa.it +39-382-529554 1. Installation / Compiling -=========================================================================== -Q: Compilation fails with - - yacc gpm-root.y - make: /usr/bin/make: cannot execute binary file - make: *** [gpm-root.c] Error 126 - -A: This is a typical error (I've got several of them reported), though - not related to gpm. - - It looks like you have an old slackware installation, like mine, or - another faulty setup. I've been reported that slackware-3 is wrong - as well. - - The 'yacc' executable is a shell script that calls bison, and it - lacks the '#!/bin/sh' line (or has it incorrect, missing the - '!'). I don't remember the details, but while it runs under your - shell, it can't be executed under make. I looked in the binfmt - sources in the kernel, and /bin/sh doesn't appear explicitly, so - you must fix the first line in the 'yacc' script, and everything - should go fine. - - Note however that the server has already been compiles. Only the - gpm-root client, written with yacc, is affected by this problem. - =========================================================================== 2. Running problems From 196f3f434bf0d655589529248d99cd2090d02d13 Mon Sep 17 00:00:00 2001 From: "Zephaniah E. Hull" Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 07/19] PS/2 rework Gbp-Pq: Name 010_ps2_rework.patch --- src/daemon/processmouse.c | 11 ++ src/daemon/startup.c | 37 +++--- src/headers/daemon.h | 1 + src/headers/gpmInt.h | 2 + src/mice.c | 270 +++++++++++++++++++++++++------------- 5 files changed, 207 insertions(+), 114 deletions(-) diff --git a/src/daemon/processmouse.c b/src/daemon/processmouse.c index 1d94ffe..7061909 100644 --- a/src/daemon/processmouse.c +++ b/src/daemon/processmouse.c @@ -46,6 +46,7 @@ int processMouse(int fd, Gpm_Event *event, Gpm_Type *type, int kd_mode) static int fine_dx, fine_dy, i, j, m, + obuttons, newB=0, /* old buttons and Type to chain events */ oldB=0, oldT=0; @@ -91,8 +92,18 @@ int processMouse(int fd, Gpm_Event *event, Gpm_Type *type, int kd_mode) event->modifiers = nEvent.modifiers; /* propagate modifiers */ /* propagate buttons */ + /* Change the button order */ + obuttons = nEvent.buttons; + nEvent.buttons = 0; + for (j = 0; j < 8; j++) { + if (obuttons & (1 << j)) { + nEvent.buttons |= which_mouse->opt_buts[j]; + } + } +#if 0 nEvent.buttons = ((which_mouse->opt_sequence)[nEvent.buttons&7]&7) | (nEvent.buttons & ~7); /* change the order */ +#endif oldB=newB; newB=nEvent.buttons; if (!i) event->buttons=nEvent.buttons; diff --git a/src/daemon/startup.c b/src/daemon/startup.c index e76b348..636f143 100644 --- a/src/daemon/startup.c +++ b/src/daemon/startup.c @@ -35,21 +35,9 @@ void startup(int argc, char **argv) { - int i, opt; + int i, j, opt; + char *p; - static struct { - char *in; - char *out; - } seq[] = { - {"123","01234567"}, - {"132","02134657"}, - {"213","01452367"}, /* warning: these must be readable as integers... */ - {"231","02461357"}, - {"312","04152637"}, - {"321","04261537"}, - {NULL,NULL} - }; - /* log to debug, who we are */ gpm_report(GPM_PR_DEBUG, GPM_MESS_VERSION); @@ -92,16 +80,23 @@ void startup(int argc, char **argv) which_mouse=mouse_table+i; /* used to access options */ if ((which_mouse->opt_accel) < 1) exit(usage("acceleration")); if ((which_mouse->opt_delta) < 2) exit(usage("delta")); - if (strlen((which_mouse->opt_sequence)) != 3 || atoi((which_mouse->opt_sequence))<100) + if (strlen(which_mouse->opt_sequence) <= 0) exit(usage("sequence")); - if ((which_mouse->opt_glidepoint_tap) > 3) exit(usage("glidepoint tap button")); - if ((which_mouse->opt_glidepoint_tap)) - (which_mouse->opt_glidepoint_tap)=GPM_B_LEFT >> ((which_mouse->opt_glidepoint_tap)-1); /* choose the sequence */ - for (opt=0; seq[opt].in && strcmp(seq[opt].in,(which_mouse->opt_sequence)); opt++) ; - if(!seq[opt].in) exit(usage("button sequence")); - (which_mouse->opt_sequence)=strdup(seq[opt].out); /* I can rewrite on it */ + for (j = 0; j < 9; j++) + which_mouse->opt_buts[j] = 1 << j; + + for (p = which_mouse->opt_sequence, j = 0; *p != '\0'; p++, j++) { + if ((*p < '0') || (*p > '9')) + exit(usage("button sequence")); + which_mouse->opt_buts[j] = (1 << (*p - '1')); + } + + if (which_mouse->opt_glidepoint_tap > 9) + exit(usage("glidepoint tap button")); + if (which_mouse->opt_glidepoint_tap) + which_mouse->opt_glidepoint_tap = which_mouse->opt_buts[which_mouse->opt_glidepoint_tap - 1]; /* look for the mouse type */ (which_mouse->m_type) = find_mouse_by_name((which_mouse->opt_type)); diff --git a/src/headers/daemon.h b/src/headers/daemon.h index 1313121..60c0189 100644 --- a/src/headers/daemon.h +++ b/src/headers/daemon.h @@ -97,6 +97,7 @@ struct mouse_features { char *opt_options; /* extra textual configuration */ Gpm_Type *m_type; int fd; + int opt_buts[9]; }; /************************************************************************* diff --git a/src/headers/gpmInt.h b/src/headers/gpmInt.h index 397d996..754d40d 100644 --- a/src/headers/gpmInt.h +++ b/src/headers/gpmInt.h @@ -54,6 +54,7 @@ #define GPM_AUX_ID_ERROR -1 #define GPM_AUX_ID_PS2 0 #define GPM_AUX_ID_IMPS2 3 +#define GPM_AUX_ID_EXPS2 4 /* these are shameless stolen from /usr/src/linux/include/linux/pc_keyb.h */ @@ -65,6 +66,7 @@ #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_RESET 0xFF /* Reset aux device */ #define GPM_AUX_ACK 0xFA /* Command byte ACK. */ diff --git a/src/mice.c b/src/mice.c index 52597ba..2e8f708 100644 --- a/src/mice.c +++ b/src/mice.c @@ -5,6 +5,7 @@ * Copyright (C) 1994-2000 Alessandro Rubini * Copyright (C) 1998,1999 Ian Zimmerman * Copyright (C) 2001-2008 Nico Schottelius + * Copyright (C) 2002 Zephaniah E. Hull * * 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 @@ -55,6 +56,7 @@ #include #include /* stat() */ #include /* select() */ +#include /* poll() */ #include /* MAJOR */ #include @@ -603,14 +605,21 @@ static int M_bm(Gpm_Event *state, unsigned char *data) /* equal to sun */ return 0; } +/* + * PS/2 mouse parser. + * Also called by the 'children' of the PS/2 mouse, for insanity sake. + * -- Zephaniah E. Hull. + */ static int M_ps2(Gpm_Event *state, unsigned char *data) { static int tap_active=0; /* there exist glidepoint ps2 mice */ - state->buttons= - !!(data[0]&1) * GPM_B_LEFT + - !!(data[0]&2) * GPM_B_RIGHT + - !!(data[0]&4) * GPM_B_MIDDLE; + state->wdx = state->wdy = 0; + + state->buttons = + ((data[0] & 0x02) ? (1 << 0) : 0) | // Right. + ((data[0] & 0x04) ? (1 << 1) : 0) | // Middle. + ((data[0] & 0x01) ? (1 << 2) : 0); // Left. if (data[0]==0 && (which_mouse->opt_glidepoint_tap)) /* by default this is false */ state->buttons = tap_active = (which_mouse->opt_glidepoint_tap); @@ -639,27 +648,28 @@ static int M_ps2(Gpm_Event *state, unsigned char *data) return 0; } +/* + * I cheat, because the two protocols are almost identical except for + * the 4th and 5th buttons, I just handle both. + * + * Note, the only thing that I've seen describe the 4th and 5th buttons + * for the IMPS/2 protocol is the X4 source, someone let me know if they + * actually see this used? + * -- Zephaniah E. Hull. + */ static int M_imps2(Gpm_Event *state, unsigned char *data) { - - static int tap_active=0; /* there exist glidepoint ps2 mice */ - state->wdx = state->wdy = 0; /* Clear them.. */ - state->dx = state->dy = state->wdx = state->wdy = 0; - - state->buttons= ((data[0] & 1) << 2) /* left */ - | ((data[0] & 6) >> 1); /* middle and right */ - - if (data[0]==0 && (which_mouse->opt_glidepoint_tap)) // by default this is false - state->buttons = tap_active = (which_mouse->opt_glidepoint_tap); - else if (tap_active) { - if (data[0]==8) - state->buttons = tap_active = 0; - else state->buttons = tap_active; - } + M_ps2(state, data); /* Standard movement.. */ state->dx = (data[0] & 0x10) ? data[1] - 256 : data[1]; state->dy = (data[0] & 0x20) ? -(data[2] - 256) : -data[2]; + + state->buttons += + ((data[0] & 0x40) ? (1 << 3) : 0) | // IMPS/2 Button 4 + ((data[0] & 0x80) ? (1 << 4) : 0) | // IMPS/2 Button 5 + ((data[3] & 0x10) ? (1 << 3) : 0) | // EXPS/2 Button 4 + ((data[3] & 0x20) ? (1 << 4) : 0); // EXPS/2 Button 5 /* The wheels.. */ unsigned char wheel = data[3] & 0x0f; @@ -723,17 +733,6 @@ static int M_netmouse(Gpm_Event *state, unsigned char *data) return 0; } -/* standard ps2 */ -static Gpm_Type *I_ps2(int fd, unsigned short flags, - struct Gpm_Type *type, int argc, char **argv) -{ - static unsigned char s[] = { 246, 230, 244, 243, 100, 232, 3, }; - write (fd, s, sizeof (s)); - usleep (30000); - tcflush (fd, TCIFLUSH); - return type; -} - static Gpm_Type *I_netmouse(int fd, unsigned short flags, struct Gpm_Type *type, int argc, char **argv) { @@ -1930,92 +1929,168 @@ 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_ps2(int fd, unsigned char cmd0, unsigned char cmd1, + size_t num, size_t rnum, unsigned long int sleep) { - int i; - int error = 0; - for (i = 0; i < len; i++) { - unsigned char c; - write(fd, &data[i], 1); - read(fd, &c, 1); - if (c != GPM_AUX_ACK) error++; + int i, error = 0, rcnt; + unsigned char cmd[2], ret[512]; + + cmd[0] = cmd0; + cmd[1] = cmd1; + + if (sleep == -1) + sleep = 50000; + + alarm(5); + rcnt = write(fd, cmd, num); + alarm(0); + if (rcnt != num) + return 1; + + usleep(sleep); + + alarm(5); + rcnt = read(fd, ret, rnum); + alarm(0); + + usleep(sleep); + + if (rcnt <= 0) + error++; + + for (i = 0; i < rcnt; i++) { + if (ret[i] != GPM_AUX_ACK) { + gpm_report(GPM_PR_ERR, "write_ps2: %d %d, %x", rcnt, i, ret[i]); + error++; + } } - /* flush any left-over input */ - usleep (30000); - tcflush (fd, TCIFLUSH); return(error); } +static Gpm_Type *get_mouse_type(char *name) +{ + Gpm_Type *type; + for (type = mice; type->fun; type++) { + if (strcmp(type->name, name) == 0) + return(type); + } + return NULL; +} + /* intellimouse, ps2 version: Ben Pfaff and Colin Plumb */ /* Autodetect: Steve Bennett */ -static Gpm_Type *I_imps2(int fd, unsigned short flags, struct Gpm_Type *type, - int argc, char **argv) +static Gpm_Type *I_ps2(int fd, unsigned short flags_unused, + struct Gpm_Type *type, int argc, char **argv) { - int id; - static unsigned char basic_init[] = { GPM_AUX_ENABLE_DEV, GPM_AUX_SET_SAMPLE, 100 }; - static unsigned char imps2_init[] = { GPM_AUX_SET_SAMPLE, 200, GPM_AUX_SET_SAMPLE, 100, GPM_AUX_SET_SAMPLE, 80, }; - static unsigned char ps2_init[] = { GPM_AUX_SET_SCALE11, GPM_AUX_ENABLE_DEV, GPM_AUX_SET_SAMPLE, 100, GPM_AUX_SET_RES, 3, }; + int id, error = 0, rate; - /* Do a basic init in case the mouse is confused */ - write_to_mouse(fd, basic_init, sizeof (basic_init)); + /* Flush any existing input. */ + tcflush(fd, TCIOFLUSH); - /* Now try again and make sure we have a PS/2 mouse */ - if (write_to_mouse(fd, basic_init, sizeof (basic_init)) != 0) { - gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_INIT); + if (write_ps2(fd, GPM_AUX_DEFAULTS, '\0', 1, 1, -1)) { + gpm_report(GPM_PR_ERR, "PS/2 mouse failed init"); return(NULL); } - /* Try to switch to 3 button mode */ - if (write_to_mouse(fd, imps2_init, sizeof (imps2_init)) != 0) { - gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_FAILED); - return(NULL); + // Magic to enable the IMPS/2 protocol. + if ((!strcmp(type->name, "imps2")) || (!strcmp(type->name, "autops2"))) { + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 100, 2, 2, -1); + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 80, 2, 2, -1); + if (error) { + gpm_report(GPM_PR_ERR, "imps2: PS/2 mouse failed (3 button) init"); + return(NULL); + } + } + if ((!strcmp(type->name, "exps2")) || (!strcmp(type->name, "autops2"))) { + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 80, 2, 2, -1); + if (error) { + gpm_report(GPM_PR_ERR, "exps2: PS/2 mouse failed (3 button) init"); + return (NULL); + } } - /* Read the mouse id */ - id = read_mouse_id(fd); - if (id == GPM_AUX_ID_ERROR) { - gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_MID_FAIL); - id = GPM_AUX_ID_PS2; + if (write_ps2(fd, GPM_AUX_SET_SCALE11, '\0', 1, 1, -1)) { + gpm_report(GPM_PR_ERR, "PS/2 mouse failed init: Unable to set 1:1 scale."); + return (NULL); } - /* And do the real initialisation */ - if (write_to_mouse(fd, ps2_init, sizeof (ps2_init)) != 0) { - gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_SETUP_FAIL); + if (which_mouse->opt_sample > 0) { + if (which_mouse->opt_sample >= 200) rate = 200; + else if (which_mouse->opt_sample >= 100) rate = 100; + else if (which_mouse->opt_sample >= 80) rate = 80; + else if (which_mouse->opt_sample >= 60) rate = 60; + else if (which_mouse->opt_sample >= 40) rate = 40; + else if (which_mouse->opt_sample >= 20) rate = 20; + else if (which_mouse->opt_sample >= 10) rate = 10; + else rate = 100; + } else { + rate = 100; } - if (id == GPM_AUX_ID_IMPS2) { - /* Really an intellipoint, so initialise 3 button mode (4 byte packets) */ - gpm_report(GPM_PR_INFO,GPM_MESS_IMPS2_AUTO); - return type; + if (write_ps2(fd, GPM_AUX_SET_SAMPLE, rate, 2, 1, -1)) { + gpm_report(GPM_PR_ERR, "PS/2 mouse failed init: Unable to set rate."); + return (NULL); } - if (id != GPM_AUX_ID_PS2) { - gpm_report(GPM_PR_ERR,GPM_MESS_IMPS2_BAD_ID, id); + + if (!strcmp(type->name, "autops2")) { + /* Read the mouse id */ + id = read_mouse_id(fd); + + switch (id) { + case GPM_AUX_ID_ERROR: + gpm_report(GPM_PR_ERR, "Unable to read PS/2 mouse ID: Using base PS/2 protocol.\n"); + write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); + write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); + return get_mouse_type("ps2"); + case GPM_AUX_ID_PS2: + gpm_report(GPM_PR_INFO, "Detected base PS/2 protocol mouse."); + write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); + write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); + return get_mouse_type("ps2"); + case GPM_AUX_ID_IMPS2: + gpm_report(GPM_PR_INFO, "Detected IMPS/2 protocol mouse."); + write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); + write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); + return get_mouse_type("imps2"); + case GPM_AUX_ID_EXPS2: + gpm_report(GPM_PR_INFO, "Detected EXPS/2 protocol mouse."); + write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); + write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); + return get_mouse_type("exps2"); + default: + gpm_report(GPM_PR_ERR, "Unknown mouse ID, using base PS/2 protocol."); + write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); + write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); + return get_mouse_type("ps2"); + } } - else gpm_report(GPM_PR_INFO,GPM_MESS_IMPS2_PS2); - for (type=mice; type->fun; type++) - if (strcmp(type->name, "ps2") == 0) return(type); + write_ps2(fd, GPM_AUX_SET_STREAM, '\0', 1, 1, 1); + write_ps2(fd, GPM_AUX_ENABLE_DEV, '\0', 1, 1, 1); - /* ps2 was not found!!! */ - return(NULL); + return type; } -/* - * This works with Dexxa Optical Mouse, but because in X same initstring - * is named ExplorerPS/2 so I named it in the same way. - */ -static Gpm_Type *I_exps2(int fd, unsigned short flags, - struct Gpm_Type *type, int argc, char **argv) +/* PS/2 Init */ +static Gpm_Type *I_fuimps2(int fd, unsigned short flags, + struct Gpm_Type *type, int argc, char **argv) { - static unsigned char s1[] = { 243, 200, 243, 200, 243, 80, }; + int error = 0; if (check_no_argv(argc, argv)) return NULL; - write (fd, s1, sizeof (s1)); - usleep (30000); - tcflush (fd, TCIFLUSH); + // Magic to enable the IMPS/2 protocol. + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 200, 2, 2, -1); + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 100, 2, 2, -1); + error += write_ps2(fd, GPM_AUX_SET_SAMPLE, 80, 2, 2, -1); + if (error) + gpm_report(GPM_PR_ERR, "fuimps2: %d errors in init, ignoring.", error); + return type; } @@ -2409,9 +2484,12 @@ Gpm_Type mice[]={ "", M_evdev, I_empty, STD_FLG, {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 0, NULL}, #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}, + {"exps2", "IntelliMouse Explorer (ps2) - 3 buttons (wheel is repeated).", + "ExplorerPS/2", M_imps2, I_ps2, STD_FLG, + {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, + {"autops2","For PS/2 type mouse, specific protocol will be auto detected", + "", M_ps2, I_ps2, STD_FLG, + {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, 0}, #ifdef HAVE_LINUX_JOYSTICK_H {"js", "For joystick mouse emulation", "Joystick", M_js, NULL, 0, @@ -2423,10 +2501,14 @@ Gpm_Type mice[]={ {"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}, - {"imps2","For the Microsoft IntelliMouse on a PS/2 port (round\n" - " connector with 6 pins), 3 buttons (wheel is repeated).", - "", M_imps2, I_imps2, STD_FLG, + {"imps2","For the Microsoft IntelliMouse on a PS/2 port\n" + "(round connector with 6 pins), 3 buttons (wheel is repeated).", + "", M_imps2, I_ps2, STD_FLG, {0xC0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, R_imps2}, + {"fuimps2","For BROKEN wheel mice on a PS/2 port\n" + "(round connector with 6 pins), 3 buttons (wheel is repeated).", + "", M_imps2, I_fuimps2, STD_FLG, + {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0}, {"logi", "For old serial Logitech mice.", "Logitech", M_logi, I_logi, CS8 | CSTOPB | STD_FLG, {0xe0, 0x80, 0x80, 0x00}, 3, 3, 0, 0, 0}, @@ -2463,10 +2545,12 @@ Gpm_Type mice[]={ " Try it if '-t ms' does not work.", "", M_bare, I_pnp, CS7 | STD_FLG, {0x40, 0x40, 0x40, 0x00}, 3, 1, 0, 0, 0}, - {"ps2", "For most busmice connected to a PS/2 port (round with 6 metal\n" - " pins).", + {"ps2", "For PS/2 mice (round with 6 metal pins).\n", "PS/2", M_ps2, I_ps2, STD_FLG, {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, R_ps2}, + {"fups2", "For /BROKEN/ PS/2 mice (round with 6 metal pins).\n", + "PS/2", M_ps2, I_empty, STD_FLG, + {0xc0, 0x00, 0x00, 0x00}, 3, 1, 0, 0, 0}, {"sun", "For Sun (Sparc) mice.", "", M_sun, I_serial, CS8 | CSTOPB | STD_FLG, {0xf8, 0x80, 0x00, 0x00}, 3, 1, 0, 0, R_sun}, From 2a2bc494d269da71703d255bc85a1cb93e97e7a1 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 08/19] Also check for term.h and handle its presence Gbp-Pq: Name 013_xterm_mouse_support_000 --- configure.ac.footer | 4 ++-- src/lib/liblow.c | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/configure.ac.footer b/configure.ac.footer index 89a4cd9..d9f7190 100644 --- a/configure.ac.footer +++ b/configure.ac.footer @@ -67,7 +67,7 @@ else fi # Header-checks -AC_CHECK_HEADERS(syslog.h linux/input.h linux/joystick.h ncurses.h ncurses/curses.h curses.h) +AC_CHECK_HEADERS(syslog.h linux/input.h linux/joystick.h ncurses.h ncurses/curses.h curses.h term.h) AC_CHECK_HEADERS(sys/sysmacros.h linux/major.h linux/tty.h) # Required headers @@ -130,7 +130,7 @@ No|no|N|n) SHARED_LIBS=-lc ;; else :; fi done SHARED_LIBS="$LIBS $TERMLIBS -lc" - LIBS=$SAVELIBS ;; + LIBS="$LIBS $SAVELIBS" ;; esac GPMXTERM= diff --git a/src/lib/liblow.c b/src/lib/liblow.c index e789d09..e709762 100644 --- a/src/lib/liblow.c +++ b/src/lib/liblow.c @@ -46,6 +46,12 @@ #include /* KDGETMODE */ #include /* winsize */ +#ifdef HAVE_TERM_H +#include +#include +#undef buttons +#endif /* HAVE_TERM_H */ + #include "headers/gpmInt.h" #include "headers/message.h" @@ -190,24 +196,40 @@ static void gpm_suspend_hook (int signum) int Gpm_Open(Gpm_Connect *conn, int flag) { char *tty = NULL; - char *term = NULL; int i; struct sockaddr_un addr; struct winsize win; Gpm_Stst *new = NULL; char* sock_name = 0; +#ifdef HAVE_TERM_H + char *mousecap; + int terror; +#else /* ! HAVE_TERM_H */ + char *term; +#endif /* HAVE_TERM_H */ static char *consolename = NULL; int gpm_is_disabled = 0; /*....................................... First of all, check xterm */ +#ifdef HAVE_TERM_H + if (setupterm((char *) 0, 1, &terror) == 0 && terror == 1 + && (mousecap=tigetstr("kmous")) && mousecap != (char *)-1 + && mousecap[0]) { + del_curterm(cur_term); +#else /* ! HAVE_TERM_H */ if ((term=(char *)getenv("TERM")) && !strncmp(term,"xterm",5)) { +#endif if(gpm_tried) return gpm_fd; /* no stack */ gpm_fd=-2; GPM_XTERM_ON; gpm_flag=1; return gpm_fd; } +#ifdef HAVE_TERM_H + if (cur_term) + del_curterm(cur_term); +#endif /* HAVE_TERM_H */ /*....................................... No xterm, go on */ /* check whether we know what name the console is: what's with the lib??? */ From 040a5770ce263cab6108e2bc637b00d35748fd85 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 09/19] source code of gpm_has_mouse_control helper Gbp-Pq: Name 014_has_mouse_control.patch --- contrib/control/Makefile | 7 +++++++ contrib/control/gpm_has_mouse_control.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 contrib/control/Makefile create mode 100644 contrib/control/gpm_has_mouse_control.c diff --git a/contrib/control/Makefile b/contrib/control/Makefile new file mode 100644 index 0000000..01b05d5 --- /dev/null +++ b/contrib/control/Makefile @@ -0,0 +1,7 @@ +CC := gcc + +all: gpm_has_mouse_control.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpm_has_mouse_control -Wall gpm_has_mouse_control.c + +clean: + -rm -f gpm_has_mouse_control diff --git a/contrib/control/gpm_has_mouse_control.c b/contrib/control/gpm_has_mouse_control.c new file mode 100644 index 0000000..7f4a9d9 --- /dev/null +++ b/contrib/control/gpm_has_mouse_control.c @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include + +int main (int argc, char **argv) +{ + int fd; + int mode; + fd = open ("/dev/tty0", O_RDONLY); + if (fd == -1) + fd = open ("/dev/vc/0", O_RDONLY); + if (fd == -1) + perror ("open"); + if (ioctl (fd, KDGETMODE, &mode) != 0) + perror ("ioctl"); + exit(mode); +} + From ae2b8f1e641c2d2c740c3215016a1c02d0888e18 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 10/19] Use MAX_NR_CONSOLES instead of MAX_VC Gbp-Pq: Name 031_max_consoles.patch --- src/daemon/gpm.c | 2 +- src/daemon/old_main.c | 4 ++-- src/daemon/processconn.c | 4 ++-- src/daemon/processrequest.c | 2 +- src/headers/daemon.h | 10 ++-------- src/headers/gpmCfg.h | 8 -------- 6 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/daemon/gpm.c b/src/daemon/gpm.c index 771da5c..4d62cfe 100644 --- a/src/daemon/gpm.c +++ b/src/daemon/gpm.c @@ -93,7 +93,7 @@ int maxx, maxy; int fifofd=-1; int eventFlag=0; -Gpm_Cinfo *cinfo[MAX_VC+1]; +Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1]; time_t last_selection_time; time_t opt_age_limit = 0; diff --git a/src/daemon/old_main.c b/src/daemon/old_main.c index dc6aafa..48d834f 100644 --- a/src/daemon/old_main.c +++ b/src/daemon/old_main.c @@ -141,7 +141,7 @@ int old_main() signal(SIGWINCH,gpm_killed); /* reinstall handler */ /* and notify clients */ - for(i=0; inext) kill(ci->data.pid,SIGWINCH); } @@ -214,7 +214,7 @@ int old_main() /*........................ got request */ /* itz 10-22-96 check _all_ clients, not just those on top! */ - for (i=0; pending && (i<=MAX_VC); i++) { + for (i=0; pending && (i<=MAX_NR_CONSOLES); i++) { Gpm_Cinfo* ci; for (ci = cinfo[i]; pending && ci; ci = ci->next) { if (FD_ISSET(ci->fd,&selSet)) { diff --git a/src/daemon/processconn.c b/src/daemon/processconn.c index a5839a3..236cbc8 100644 --- a/src/daemon/processconn.c +++ b/src/daemon/processconn.c @@ -67,8 +67,8 @@ int processConn(int fd) return -1; } - if((vc = request->vc) > MAX_VC) { - gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_VC); + if((vc = request->vc) > MAX_NR_CONSOLES) { + gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_NR_CONSOLES); free(info); close(newfd); return -1; diff --git a/src/daemon/processrequest.c b/src/daemon/processrequest.c index 309834c..1a80520 100644 --- a/src/daemon/processrequest.c +++ b/src/daemon/processrequest.c @@ -41,7 +41,7 @@ int processRequest(Gpm_Cinfo *ci, int vc) gpm_report(GPM_PR_INFO, GPM_MESS_CON_REQUEST, ci->fd, vc); - if (vc>MAX_VC) return -1; + if (vc>MAX_NR_CONSOLES) return -1; /* itz 10-22-96 this shouldn't happen now */ if (vc==-1) gpm_report(GPM_PR_OOPS, GPM_MESS_UNKNOWN_FD); diff --git a/src/headers/daemon.h b/src/headers/daemon.h index 60c0189..263c9b4 100644 --- a/src/headers/daemon.h +++ b/src/headers/daemon.h @@ -26,6 +26,7 @@ */ #include "gpm.h" /* Gpm_Event */ #include /* fd_set */ +#include /* for cinfo -- to be moved to os/linux in 2.x! */ /************************************************************************* * Types / structures @@ -104,13 +105,6 @@ struct mouse_features { * Macros */ -/* How many virtual consoles are managed? */ -#ifndef MAX_NR_CONSOLES -# define MAX_NR_CONSOLES 64 /* this is always sure */ -#endif - -#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */ - /* for adding a mouse; add_mouse */ #define GPM_ADD_DEVICE 0 #define GPM_ADD_TYPE 1 @@ -174,7 +168,7 @@ extern fd_set selSet, extern int eventFlag; extern struct winsize win; -extern Gpm_Cinfo *cinfo[MAX_VC+1]; +extern Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1]; extern struct mouse_features mouse_table[3], *which_mouse; /*the current one*/ diff --git a/src/headers/gpmCfg.h b/src/headers/gpmCfg.h index 73f6db3..e5623f3 100644 --- a/src/headers/gpmCfg.h +++ b/src/headers/gpmCfg.h @@ -32,14 +32,6 @@ #include #endif -/* FIXME: still needed ?? */ -/* How many virtual consoles are managed? */ -#ifndef MAX_NR_CONSOLES -# define MAX_NR_CONSOLES 64 /* this is always sure */ -#endif - -#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */ - /* How many buttons may the mouse have? */ /* #define MAX_BUTTONS 3 ===> not used, it is hardwired :-( */ From 895a5056bc79bbdce28deaafdcbb22d2706aabb2 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 11/19] Don't link against libcurses Gbp-Pq: Name 050_dont_link_libcurses --- configure.ac.footer | 15 ++++----------- src/lib/libcurses.c | 8 +++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/configure.ac.footer b/configure.ac.footer index d9f7190..a6d016e 100644 --- a/configure.ac.footer +++ b/configure.ac.footer @@ -67,7 +67,7 @@ else fi # Header-checks -AC_CHECK_HEADERS(syslog.h linux/input.h linux/joystick.h ncurses.h ncurses/curses.h curses.h term.h) +AC_CHECK_HEADERS(syslog.h linux/input.h linux/joystick.h) AC_CHECK_HEADERS(sys/sysmacros.h linux/major.h linux/tty.h) # Required headers @@ -86,16 +86,7 @@ AS_IF([test "x$enable_static" = "xyes"], [ AC_ARG_WITH(curses, [ --without-curses disable curses support even if curses found]) -CURSES_OBJS= - -case $with_curses in -No|no|N|n) : ;; - *) if test ${ac_cv_header_ncurses_h} = yes || - test ${ac_cv_header_ncurses_curses_h} = yes || - test ${ac_cv_header_curses_h} = yes ; then - CURSES_OBJS=lib/libcurses.o ; fi ;; -esac - +CURSES_OBJS=lib/libcurses.o ITZ_CHECK_TYPE(__u32,linux/types.h) if test ${itz_cv_type___u32} = yes || test ${ac_cv_type___u32} = yes ; then @@ -112,6 +103,7 @@ fi AC_CHECK_FUNCS(vsyslog syslog) AC_FUNC_ALLOCA +if false; then # we actually don't want -lcurses case $with_curses in No|no|N|n) SHARED_LIBS=-lc ;; *) @@ -132,6 +124,7 @@ No|no|N|n) SHARED_LIBS=-lc ;; SHARED_LIBS="$LIBS $TERMLIBS -lc" LIBS="$LIBS $SAVELIBS" ;; esac +fi GPMXTERM= AC_SUBST(GPMXTERM) diff --git a/src/lib/libcurses.c b/src/lib/libcurses.c index e7ebf84..55f026e 100644 --- a/src/lib/libcurses.c +++ b/src/lib/libcurses.c @@ -29,6 +29,7 @@ #include "headers/gpmInt.h" +#if 0 /* hack - we do not want to depend on libcurses headers */ #ifdef HAVE_NCURSES_H #include #else @@ -40,8 +41,13 @@ #endif /* HAVE_CURSES_H */ #endif /* HAVE_NCURSES_CURSES_H */ #endif /* HAVE_NCURSES_H */ - +#else +typedef struct _WINDOW WINDOW; +extern int wgetch(WINDOW *) __attribute__((weak)); +extern WINDOW *stdscr __attribute__((weak)); +#define getch() wgetch(stdscr) #define GET(win) ((win) ? wgetch(win) : getch()) +#endif int Gpm_Wgetch(WINDOW *win) { From 53d4bfdd91bca7c5ce54009713fffabc679a1464 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 12/19] No blocking on mouse device under X Gbp-Pq: Name 060_no_blocking_on_mouse_device_under_x --- src/daemon/old_main.c | 30 ++++++++++++++++++++---------- src/headers/gpmInt.h | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/daemon/old_main.c b/src/daemon/old_main.c index 48d834f..38087a4 100644 --- a/src/daemon/old_main.c +++ b/src/daemon/old_main.c @@ -130,10 +130,8 @@ int old_main() FD_SET(mouse_table[eventFlag].fd,&selSet); } else - while((pending=select(maxfd+1,&selSet,NULL_SET,NULL_SET,&timeout))==0){ - selSet=readySet; + if((pending=select(maxfd+1,&selSet,NULL_SET,NULL_SET,&timeout))==0) resetTimeout(); - } /* go on */ if(opt_resize) { /* did the console resize? */ get_console_size(&event); @@ -168,12 +166,24 @@ int old_main() if (ioctl(fd, KDGETMODE, &kd_mode) < 0) gpm_report(GPM_PR_OOPS,GPM_MESS_IOCTL_KDGETMODE); close(fd); - if(kd_mode != KD_TEXT && !option.repeater && !option.force_repeat) { - wait_text(&mouse_table[1].fd); - maxfd=max(maxfd,mouse_table[1].fd); - readySet=connSet; - FD_SET(mouse_table[1].fd,&readySet); - continue; /* reselect */ + if (!option.repeater && !option.force_repeat) { + if (mouse_table[1].fd >= 0 && kd_mode != KD_TEXT) { + /* Non-text mode, close mouse */ + close(mouse_table[1].fd); + FD_CLR(mouse_table[1].fd,&readySet); + mouse_table[1].fd=-1; + } else if (mouse_table[1].fd < 0 && kd_mode == KD_TEXT) { + /* Back to text mode, reopen mouse */ + if ((mouse_table[1].fd=open((mouse_table[1].opt_dev),O_RDWR))<0) + gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN,(mouse_table[1].opt_dev)); + else { + if ((mouse_table[1].m_type)->init) + (mouse_table[1].m_type)=((mouse_table[1].m_type)->init)(mouse_table[1].fd, (mouse_table[1].m_type)->flags, (mouse_table[1].m_type), mouse_argc[1], + mouse_argv[1]); + maxfd=max(maxfd,mouse_table[1].fd); + FD_SET(mouse_table[1].fd,&readySet); + } + } } } @@ -185,7 +195,7 @@ int old_main() for (i=1; i <= 1+opt_double; i++) { which_mouse=mouse_table+i; /* used to access options */ - if (FD_ISSET(which_mouse->fd,&selSet)) { + if (which_mouse->fd >= 0 && 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)) /* pass it to the client, if any diff --git a/src/headers/gpmInt.h b/src/headers/gpmInt.h index 754d40d..9ce7b4b 100644 --- a/src/headers/gpmInt.h +++ b/src/headers/gpmInt.h @@ -33,7 +33,7 @@ /*....................................... old gpmCfg.h */ /* timeout for the select() syscall */ -#define SELECT_TIME 86400 /* one day */ +#define SELECT_TIME 2 /* two seconds */ #ifdef HAVE_LINUX_TTY_H #include From 7b4ce7076c306233e5a305d8723b4a52cc4f5a6f Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:09 +0800 Subject: [PATCH 13/19] Fix "storage size of 'sucred' is unknown" FTBFS Bug-Debian: https://bugs.debian.org/520853 Gbp-Pq: Name 070_struct_ucred --- src/daemon/processconn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/daemon/processconn.c b/src/daemon/processconn.c index 236cbc8..a15781e 100644 --- a/src/daemon/processconn.c +++ b/src/daemon/processconn.c @@ -20,6 +20,7 @@ * ********/ +#define _GNU_SOURCE /* needed for struct ucred */ #include /* accept */ #include /* malloc */ #include /* close */ From acd75965db388fa4cbd6eb6fb8597a14d54d8867 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:10 +0800 Subject: [PATCH 14/19] Add AC_CANONICAL_HOST Gbp-Pq: Name 080_cross-compile.patch --- configure.ac.footer | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac.footer b/configure.ac.footer index a6d016e..b876859 100644 --- a/configure.ac.footer +++ b/configure.ac.footer @@ -35,6 +35,8 @@ AC_DEFINE_UNQUOTED([GPM_ABI_FULL],["$abi_full"],[Full library version]) # Find programs # +AC_CANONICAL_HOST + AC_PROG_CC AC_PROG_LIBTOOL AC_PROG_INSTALL From 897638add3c93dd2a43f66d8a7fb6a9c8e8bb999 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:10 +0800 Subject: [PATCH 15/19] Initialize kernel version, to cope with empty sublevel definitions Example: VERSION = 3 PATCHLEVEL = 3 SUBLEVEL = EXTRAVERSION = NAME = Saber-toothed Squirrel Signed-off-by: Stefan Lippers-Hollmann Gbp-Pq: Name 090_linux3_versions --- src/prog/gpm-root.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prog/gpm-root.y b/src/prog/gpm-root.y index 069d801..6e4d76a 100644 --- a/src/prog/gpm-root.y +++ b/src/prog/gpm-root.y @@ -1161,7 +1161,7 @@ int main(int argc, char **argv) */ { struct utsname linux_info; - int v1,v2,v3; + int v1=0,v2=0,v3=0; struct stat sbuf; if (uname(&linux_info)) { From a936f972f356b4624d2873731f1009f3a3c6b4c3 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Fri, 13 May 2022 23:47:10 +0800 Subject: [PATCH 16/19] Fix FTBFS with glibc 2.17 Bug-Debian: https://bugs.debian.org/700229 Gbp-Pq: Name 091_glibc_2.17_types --- src/daemon/open_console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/daemon/open_console.c b/src/daemon/open_console.c index 98297c9..2f16087 100644 --- a/src/daemon/open_console.c +++ b/src/daemon/open_console.c @@ -22,6 +22,7 @@ #include /* open and co. */ #include /* stat() */ #include /* ioctl */ +#include /* major() */ /* Linux specific (to be outsourced in gpm2 */ #include /* for serial console check */ From 0267581ebe4744680eb95cc05f1b0b836a22a45e Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:10 +0800 Subject: [PATCH 17/19] Fix FTBFS with -Wformat-security Bug-Debian: https://bugs.debian.org/888792 Bug-Debian: https://bugs.debian.org/888797 Gbp-Pq: Name 092_fix-format-not-a-string-literal-and-no-format-arguments.patch --- src/lib/report-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/report-lib.c b/src/lib/report-lib.c index c0ae086..1b9754d 100644 --- a/src/lib/report-lib.c +++ b/src/lib/report-lib.c @@ -47,7 +47,7 @@ void gpm_report(int line, char *file, int stat, char *text, ... ) log_level = LOG_CRIT; break; } #ifdef HAVE_VSYSLOG - syslog(log_level, string); + syslog(log_level, "%s", string); vsyslog(log_level, text, ap); #else fprintf(stderr,"%s[%s(%d)]:\n",string,file,line); From 4fb0a9e9c933ef2ef31c8a1e6b4c18ef3c4f0274 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:10 +0800 Subject: [PATCH 18/19] Fix spelling errors found by lintian Gbp-Pq: Name 093_fix-typos.patch --- doc/FAQ | 2 +- doc/doc.gpm.in | 2 +- src/daemon/old_main.c | 2 +- src/mice.c | 2 +- src/prog/mouse-test.c | 2 +- src/synaptics.c | 18 +++++++++--------- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/FAQ b/doc/FAQ index d393eaf..9ba3586 100644 --- a/doc/FAQ +++ b/doc/FAQ @@ -132,7 +132,7 @@ A: Bill chose to use its own Plug-and-Pray specification, which finally to keep hold of processor time for at least 1 second). - no pnp vendor will be able to support three buttons any more (no more mouse protocols, all mice must behave the same). - - similary, only 1200 baud devices (any serial device) are supported, + - similarly, only 1200 baud devices (any serial device) are supported, because the initialization string of pnp devices only tells the vendor and release, with no information about required port configuration. diff --git a/doc/doc.gpm.in b/doc/doc.gpm.in index 77a4d42..829e07e 100644 --- a/doc/doc.gpm.in +++ b/doc/doc.gpm.in @@ -394,7 +394,7 @@ Available command line options are the following: automatically forces the @emph{repeater} (@samp{\-R}) option on. @item \-o @var{list-of-extra-options} - The option works similary to the ``\-o'' option of mount; it is + The option works similarly to the ``\-o'' option of mount; it is used to specify a list of ``extra options'' that are specific to each mouse type. The list is comma-separated. The options @samp{dtr}, @samp{rts} or @samp{both} are used by the serial diff --git a/src/daemon/old_main.c b/src/daemon/old_main.c index 38087a4..aba44d6 100644 --- a/src/daemon/old_main.c +++ b/src/daemon/old_main.c @@ -190,7 +190,7 @@ int old_main() /*....................................... got mouse, process event */ /* * Well, actually, run a loop to maintain inlining of functions without - * lenghtening the file. This is not too clean a code, but it works.... + * lengthening the file. This is not too clean a code, but it works.... */ for (i=1; i <= 1+opt_double; i++) { diff --git a/src/mice.c b/src/mice.c index 2e8f708..3aa4838 100644 --- a/src/mice.c +++ b/src/mice.c @@ -122,7 +122,7 @@ static int parse_argv(argv_helper *info, int argc, char **argv) break; } if (p->type == ARGV_END) { /* not found */ - fprintf(stderr, "%s: Uknown option \"%s\" for pointer \"%s\"\n", + fprintf(stderr, "%s: Unknown option \"%s\" for pointer \"%s\"\n", option.progname, argv[i], argv[0]); errors++; continue; diff --git a/src/prog/mouse-test.c b/src/prog/mouse-test.c index 0bb1982..7d29ed4 100644 --- a/src/prog/mouse-test.c +++ b/src/prog/mouse-test.c @@ -524,7 +524,7 @@ int main(int argc, char **argv) Gpm_Event event; if (packetsize!=cur->this->packetlen) { - REMOVETYPE(cur,"different packet lenght"); + REMOVETYPE(cur,"different packet length"); continue; } diff --git a/src/synaptics.c b/src/synaptics.c index 2418c75..7e15936 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -2471,7 +2471,7 @@ static void syn_serial_read_cap (int fd, #define PS2_SCALE_11 0xE6 /* Set scale to 1:1 */ -/* Normal ps2 responce */ +/* Normal ps2 response */ #define PS2_ERROR 0xFC /* Error, after a reset,resend or disconnect*/ #define PS2_ACK 0xFA /* Command acknowledge */ #define PS2_READY 0xAA /* Send after a calibration or ERROR */ @@ -2538,7 +2538,7 @@ static byte tp_ps2_putbyte(int fd, } # ifdef DEBUG_PUTBYTE_ACK - gpm_report(GPM_PR_DEBUG,"Responce %X to byte %X",ack,b); + gpm_report(GPM_PR_DEBUG,"Response %X to byte %X",ack,b); # endif return ack; @@ -2565,11 +2565,11 @@ static byte syn_ps2_getbyte(int fd, int stick) /* Do some sanity checking */ if((response[0] & 0xFC) != 0x84) { - gpm_report (GPM_PR_ERR,"Byte 0 of stick device responce is not valid"); + gpm_report (GPM_PR_ERR,"Byte 0 of stick device response is not valid"); return -1; } if((response[3] & 0xCC) != 0xC4) { - gpm_report (GPM_PR_ERR,"Byte 3 of stick device responce is not valid"); + gpm_report (GPM_PR_ERR,"Byte 3 of stick device response is not valid"); return -1; } } @@ -2844,7 +2844,7 @@ static void syn_ps2_send_reset(int fd, int stick) byte status,id_code = PS2_MOUSE_IDCODE; byte reset_cmd = PS2_RESET; - gpm_report(GPM_PR_DEBUG,"Reseting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad")); + gpm_report(GPM_PR_DEBUG,"Resetting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad")); /* Send reset command without eating the ack. */ if(!stick) { @@ -2871,11 +2871,11 @@ static void syn_ps2_send_reset(int fd, int stick) usleep(750000); if ( (status = syn_ps2_getbyte(fd,stick)) != PS2_READY ){ - gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: No READY, got %02X.\n" + gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: No READY, got %02X.\n" "Check pc_keyb.c for reconnect smartness.\n",status); } if ( (id_code = syn_ps2_getbyte(fd,stick)) != PS2_MOUSE_IDCODE){ - gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: Wrong ID, got %02X.\n",id_code); + gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: Wrong ID, got %02X.\n",id_code); } } @@ -3155,7 +3155,7 @@ void syn_process_serial_data (Gpm_Event *state, void syn_serial_reset(int fd) { - gpm_report (GPM_PR_INFO,"Reseting Synaptic Serial Touchpad."); + gpm_report (GPM_PR_INFO,"Resetting Synaptic Serial Touchpad."); syn_serial_set_mode (fd, (RELATIVE_MODE | HIGH_REPORT_RATE | @@ -3247,7 +3247,7 @@ void syn_process_ps2_data (Gpm_Event *state, void syn_ps2_reset (int fd) { - gpm_report (GPM_PR_INFO,"Reseting Synaptic PS/2 Touchpad."); + gpm_report (GPM_PR_INFO,"Resetting Synaptic PS/2 Touchpad."); /* Stop incoming motion data (of whatever kind absolute/relative). */ tp_ps2_disable_data(fd); From 7b643237fa5f035132ceb516f04a56cc5b3e5cb8 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 13 May 2022 23:47:10 +0800 Subject: [PATCH 19/19] Fix FTBFS with glibc 2.26 Origin: http://downloads.nutyx.org/x86_64/development/base/gpm/gpm-1.20.7-glibc-2.26-1.patch Bug: https://github.com/telmich/gpm/issues/21 Bug-Debian: https://bugs.debian.org/886903 Bug-LFS: http://wiki.linuxfromscratch.org/blfs/ticket/9616#ticket Gbp-Pq: Name 94_gpm-1.20.7-glibc-2.26-1.patch --- src/daemon/open_console.c | 4 ++++ src/prog/gpm-root.y | 12 ++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/daemon/open_console.c b/src/daemon/open_console.c index 2f16087..12119db 100644 --- a/src/daemon/open_console.c +++ b/src/daemon/open_console.c @@ -24,6 +24,10 @@ #include /* ioctl */ #include /* major() */ +#ifdef HAVE_SYS_SYSMACROS_H +#include /* major() w/newer glibc */ +#endif + /* Linux specific (to be outsourced in gpm2 */ #include /* for serial console check */ #include /* for serial console check */ diff --git a/src/prog/gpm-root.y b/src/prog/gpm-root.y index 6e4d76a..75079e9 100644 --- a/src/prog/gpm-root.y +++ b/src/prog/gpm-root.y @@ -443,6 +443,7 @@ void f__fix(struct passwd *pass) } /*---------------------------------------------------------------------*/ +#if 0 static int f_debug_one(FILE *f, Draw *draw) { DrawItem *ip; @@ -465,6 +466,7 @@ static int f_debug_one(FILE *f, Draw *draw) #undef LINE return 0; } +#endif int f_debug(int mode, DrawItem *self, int uid) { @@ -960,10 +962,8 @@ static inline void scr_dump(int fd, FILE *f, unsigned char *buffer, int vc) /*------------*/ static inline void scr_restore(int fd, FILE *f, unsigned char *buffer, int vc) { - int x,y, dumpfd; + int dumpfd; char dumpname[20]; - - x=buffer[2]; y=buffer[3]; /* WILL NOT WORK WITH DEVFS! FIXME! */ sprintf(dumpname,"/dev/vcsa%i",vc); @@ -1196,11 +1196,7 @@ int main(int argc, char **argv) LOG_DAEMON : LOG_USER); /* reap your zombies */ childaction.sa_handler=reap_children; -#if defined(__GLIBC__) - __sigemptyset(&childaction.sa_mask); -#else /* __GLIBC__ */ - childaction.sa_mask=0; -#endif /* __GLIBC__ */ + sigemptyset(&childaction.sa_mask); childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */ sigaction(SIGCHLD,&childaction,NULL);