⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpm-1.19.3-imps-autodetect.patch

📁 gpm-1.20.0.tar.gz
💻 PATCH
字号:
diff  -u gpm-1.19.3/mice.c--- gpm-1.19.3/mice.c.orig+++ gpm-1.19.3/mice.c	Fri Jul 27 12:36:25 2001@@ -58,6 +58,7 @@  #include <linux/kdev_t.h> /* MAJOR */ #include <linux/keyboard.h>+#include <linux/pc_keyb.h>  #ifdef HAVE_LINUX_JOYSTICK_H #include <linux/joystick.h>@@ -1620,21 +1621,112 @@   return type; } -/* intellimouse, ps2 version: Ben Pfaff and Colin Plumb */-static Gpm_Type *I_imps2(int fd, unsigned short flags,-			 struct Gpm_Type *type, int argc, char **argv)-{-  static unsigned char s1[] = { 243, 200, 243, 100, 243, 80, };-  static unsigned char s2[] = { 246, 230, 244, 243, 100, 232, 3, };+#define AUX_SEND_ID 0xF2+#define AUX_ID_ERROR  -1+#define AUX_ID_PS2    0+#define AUX_ID_IMPS2  3 -  if (check_no_argv(argc, argv)) return NULL;+/*+ * Sends the SEND_ID command to the ps2-type mouse.+ * Return one of AUX_ID_...+ */+static int read_mouse_id(int fd)+ {+  unsigned char c = AUX_SEND_ID;+  unsigned char id;++  write(fd, &c, 1);+  read(fd, &c, 1);+  if (c != AUX_ACK) {+    return(AUX_ID_ERROR);+  }+  read(fd, &id, 1); -  write (fd, s1, sizeof (s1));-  usleep (30000);-  write (fd, s2, sizeof (s2));+  return(id);+}++/**+ * Writes the given data to the ps2-type mouse.+ * Checks for an ACK from each byte.+ * + * 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)+{+  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 != AUX_ACK) {+      error++;+    }+  }++  /* flush any left-over input */   usleep (30000);   tcflush (fd, TCIFLUSH);-  return type;+  return(error);+}+++/* 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 i;+  int id;+  static unsigned char basic_init[] = { AUX_ENABLE_DEV, AUX_SET_SAMPLE, 100 };+  static unsigned char imps2_init[] = { AUX_SET_SAMPLE, 200, AUX_SET_SAMPLE, 100, AUX_SET_SAMPLE, 80, };+  static unsigned char ps2_init[] = { AUX_SET_SCALE11, AUX_ENABLE_DEV, AUX_SET_SAMPLE, 100, AUX_SET_RES, 3, };++  /* Do a basic init in case the mouse is confused */+  write_to_mouse(fd, basic_init, sizeof (basic_init));++  /* Now try again and make sure we have a PS/2 mouse */+  if (write_to_mouse(fd, basic_init, sizeof (basic_init)) != 0) {+    gpm_debug_log(LOG_ERR, "imps2: 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_debug_log(LOG_ERR, "imps2: PS/2 mouse failed (3 button) init");+    return(NULL);+  }++  /* Read the mouse id */+  id = read_mouse_id(fd);+  if (id == AUX_ID_ERROR) {+    gpm_debug_log(LOG_ERR, "imps2: PS/2 mouse failed to read id, assuming standard PS/2");+    id = AUX_ID_PS2;+  }++  /* And do the real initialisation */+  if (write_to_mouse(fd, ps2_init, sizeof (ps2_init)) != 0) {+    gpm_debug_log(LOG_ERR, "imps2: PS/2 mouse failed setup, continuing...");+  }++  if (id == AUX_ID_IMPS2) {+    /* Really an intellipoint, so initialise 3 button mode (4 byte packets) */+    gpm_debug_log(LOG_NOTICE, "imps2: Auto-detected intellimouse PS/2");++    return type;+  }+  if (id != AUX_ID_PS2) {+    gpm_debug_log(LOG_ERR, "imps2: Auto-detected unknown mouse type %d, assuming standard PS/2", id);+  }+  else {+    gpm_debug_log(LOG_NOTICE, "imps2: Auto-detected standard PS/2");+  }+  for (type=mice; type->fun; type++) {+    if (strcmp(type->name, "ps2") == 0) {+      return(type);+    }+  }+  /* ps2 was not found!!! */+  return(NULL); }  static Gpm_Type *I_twid(int fd, unsigned short flags,@@ -1991,7 +2083,7 @@   {"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},-  {"imps2",   "Microsoft Intellimouse (ps2) - 3 buttons, wheel unused",+  {"imps2",   "Microsoft Intellimouse (ps2) - autodetect 2/3 buttons, wheel unused",            "", M_ps2, I_imps2, STD_FLG,                                 {0xc0, 0x00, 0x00, 0x00}, 4, 1, 0, 0, 0},   {"ms3", "Microsoft Intellimouse (serial) - 3 buttons, wheel unused",diff  -u gpm-1.19.3/doc/doc.gpm--- gpm-1.19.3/doc/doc.gpm.orig+++ gpm-1.19.3/doc/doc.gpm	Fri Jul 27 12:49:08 2001@@ -720,7 +720,8 @@         ones. The wheel is currently unused.  @item imps2-	``IntelliMouse'' on the ps/2 port.+	``IntelliMouse'' on the ps/2 port. This type can also be used for+        a generic 2-button ps/2 mouse too, since it will auto-detect the type.  @item netmouse         Decodes the ``Genius NetMouse'' type of devices.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -