changeset 30532:328993ad6017

(Fmsdos_set_mouse_buttons, syms_of_msdos): New functions. (syms_of_msdos): Defsubr Fmsdos_set_mouse_buttons.
author Eli Zaretskii <eliz@gnu.org>
date Mon, 31 Jul 2000 06:38:19 +0000
parents 181a2490ab9e
children 1f906dd9b085
files src/msdos.c
diffstat 1 files changed, 34 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/msdos.c	Mon Jul 31 06:33:58 2000 +0000
+++ b/src/msdos.c	Mon Jul 31 06:38:19 2000 +0000
@@ -168,6 +168,38 @@
 }
 
 static void
+mouse_setup_buttons (int n_buttons)
+{
+  if (n_buttons == 3)
+    {
+      mouse_button_count = 3;
+      mouse_button_translate[0] = 0; /* Left */
+      mouse_button_translate[1] = 2; /* Middle */
+      mouse_button_translate[2] = 1; /* Right */
+    }
+  else	/* two, what else? */
+    {
+      mouse_button_count = 2;
+      mouse_button_translate[0] = 0;
+      mouse_button_translate[1] = 1;
+    }
+}
+
+DEFUN ("msdos-set-mouse-buttons", Fmsdos_set_mouse_buttons, Smsdos_set_mouse_buttons,
+       1, 1, "NSet number of mouse buttons to: ",
+  "Set the number of mouse buttons to use by Emacs.\n
+This is useful with mice that report the number of buttons inconsistently,\n
+e.g., if the number of buttons is reported as 3, but Emacs only sees 2 of\n
+them.  This happens with wheeled mice on Windows 9X, for example.")
+  (nbuttons)
+     Lisp_Object nbuttons;
+{
+  CHECK_NUMBER (nbuttons, 0);
+  mouse_setup_buttons (XINT (nbuttons));
+  return Qnil;
+}
+
+static void
 mouse_get_xy (int *x, int *y)
 {
   union REGS regs;
@@ -4517,20 +4549,7 @@
 	    {
 	      have_mouse = 1;	/* enable mouse */
 	      mouse_visible = 0;
-	      
-	      if (outregs.x.bx == 3)
-		{
-		  mouse_button_count = 3;
-		  mouse_button_translate[0] = 0; /* Left */
-		  mouse_button_translate[1] = 2; /* Middle */
-		  mouse_button_translate[2] = 1; /* Right */
-		}
-	      else
-		{
-		  mouse_button_count = 2;
-		  mouse_button_translate[0] = 0;
-		  mouse_button_translate[1] = 1;
-		}
+	      mouse_setup_buttons (outregs.x.bx);
 	      mouse_position_hook = &mouse_get_pos;
 	      mouse_init ();
 	    }
@@ -5224,6 +5243,7 @@
   defsubr (&Smsdos_long_file_names);
   defsubr (&Smsdos_downcase_filename);
   defsubr (&Smsdos_remember_default_colors);
+  defsubr (&Smsdos_set_mouse_buttons);
 }
 
 #endif /* MSDOS */