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

📄 gpm-diff-first

📁 gpm-1.20.0.tar.gz
💻
📖 第 1 页 / 共 3 页
字号:
 			    byte *bytes)  {   ps2_send_cmd(fd, cmd);-  ps2_putbyte(fd, 0xE9);+  ps2_putbyte(fd, PS2_STATUS_REQ);   bytes [0]=ps2_getbyte(fd);   bytes [1]=ps2_getbyte(fd);   bytes [2]=ps2_getbyte(fd);@@ -1117,8 +1253,8 @@ {   byte bytes [3]; -  ps2_status_rqst (fd, 0x00, bytes);-  if (bytes [1] != 0x47) {+  ps2_status_rqst (fd, PS2_SYN_CMD_IDENTIFY, bytes);+  if (bytes [1] != PS2_SYN_STATUS_OK) {     printf ("PS/2 device doesn't appear to be a synaptics touchpad\n");   } else {     info->info_minor      = bytes [0];@@ -1128,6 +1264,36 @@ }  +++/* read the extended capibility from the ps2 touchpad, STIG page 15 */+static void syn_read_ps2_cap (int fd,+                              ext_cap_type *cap)+{+  unsigned char bytes [3];+  ps2_status_rqst (fd, PS2_SYN_CMD_CAPABILITIES, bytes);++  if (bytes [1] != PS2_SYN_STATUS_OK) {+    printf ("PS/2 device doesn't appear to be a synaptics touchpad\n");+  }++  cap->cap_ext          = check_bits (bytes[0], EXT_CAP_EXTENDED >> 16);++  /* If the extended bit is not set it should be assumed that neither of the+     other capabilites is availible.*/+  if(cap->cap_ext){+    cap->cap_sleep        = check_bits (bytes[2], EXT_CAP_SLEEP);+    cap->cap_four_button  = check_bits (bytes[2], EXT_CAP_FOUR_BUTTON);+    cap->cap_multi_finger = check_bits (bytes[2], EXT_CAP_MULTI_FINGER);+    cap->cap_palm_detect  = check_bits (bytes[2], EXT_CAP_PALM_DETECT);+  }else{+    cap->cap_sleep        = 0;+    cap->cap_four_button  = 0;+    cap->cap_multi_finger = 0;+    cap->cap_palm_detect  = 0;+  }+}+ /* read the model_id from the ps2 touchpad */ static void syn_read_ps2_model_id (int fd, 				   model_id_type *model) @@ -1135,75 +1301,97 @@   unsigned char bytes [3];   int model_int; -  ps2_status_rqst (fd, 0x03, bytes);+  ps2_status_rqst (fd, PS2_SYN_CMD_MODEL_ID, bytes);   model_int = ((bytes [0] << 16) | 	       (bytes [1] << 8)  |-	       bytes [2]);+	       (bytes [2]));   extract_model_id_info (model_int, model); } -/* read the extended capibility from the ps2 touchpad */-static void syn_read_ps2_cap (int fd,-                              ext_cap_type *cap)-{-  unsigned char bytes [3];-  ps2_status_rqst (fd, 0x02, bytes);-  cap->cap_ext          = check_bits (bytes[0], 0x80);-  cap->cap_sleep        = check_bits (bytes[2], 0x10);-  cap->cap_four_button  = check_bits (bytes[2], 0x08);-  cap->cap_multi_finger = check_bits (bytes[2], 0x02);-  cap->cap_palm_detect  = check_bits (bytes[2], 0x01);-}  /* read the modes from the touchpad (in ps/2 format) */ static void read_ps2_modes (int fd)  {   unsigned char bytes [3]; -  ps2_status_rqst (fd, 0x01, bytes);+  ps2_status_rqst (fd, PS2_SYN_CMD_MODES, bytes); #if DEBUG_SENT_DATA   gpm_debug_log (LOG_DEBUG,"PS/2 modes: %02X", bytes [2]); #endif } ++/*+ *  Translate the incomming data to an uniform report+ *+ */++/* STIG page 42+ * wmode = 0, newer version. Gesture, right and left are repeated.+ *+ * byte 0 |     1   |    0   |  Finger  | Reserved |    0   | Gesture |  Right  | Left |  + * byte 1 |         y-pos 11-8                     |         x-pos  11-8               |+ * byte 2 |                           z pressure 0-7                                   |+ * byte 3 |     1   |    1   | y-pos 12 | x-pos 12 |    0   | Gesture |  Right  | Left |+ * byte 4 |                                 x - pos 0-7                                |+ * byte 5 |                                 y - pos 0-7                                |+ *+ * STIG page 43+ * wmode = 0, old version <  3.2.+ * Second is a second gesture!?+ *+ * byte 0 |     1   |    1   |  z-pres 6-7         | Second | Gesture |  Right  | Left |  + * byte 1 |  finger |    0   |     0    |                    x-pos  12-8               |+ * byte 2 |                           x-pos  0-7                                       |+ * byte 3 |     1   |    0   |               z-pressure 0-5                            |+ * byte 4 |Reserved |    0   |    0     |              y - pos 8-12                    |+ * byte 5 |                                 y - pos 0-7                                |+ *+ + */+ /* Translate the reported data into a record for processing */ static void syn_translate_ps2_report (unsigned char *data, 				      report_type *report)  {   int i; -  if (((data [0] & 0xc8) == 0x80) &&-      ((data [3] & 0xc8) == 0xc0) &&-      ((data [0] & 0x0f) == (data [3] & 0x0f))) {+  /* Check that this is indead an absolute 6 byte new version packet*/+  if (((data [0] & 0xc8) == 0x80) && /* Check static in byte 0 */+      ((data [3] & 0xc8) == 0xc0) && /* Check static in byte 3 */+      ((data [0] & 0x0F) == (data [3] & 0x0F))) { /* check repeated date */     report->gesture  = check_bits (data [0], 0x04);     report->finger   = check_bits (data [0], 0x20);     report->left     = check_bits (data [0], 0x01);     report->middle   = 0;     report->right    = check_bits (data [0], 0x02);     report->x        = (((data [1] & 0x0f) << 8) | 			((data [3] & 0x10) << 8) |-			data [4]);-    report->y        = (((data [1] & 0xf0) << 4) |+			((data [4])));+    report->y        = (((data [1] & 0xF0) << 4) | 			((data [3] & 0x20) << 7) |-			data [5]);+			((data [5])));     report->pressure = data [2];-  } else if (((data [0] & 0xc0) == 0xc0) &&-	     ((data [1] & 0x60) == 0x00) &&-	     ((data [3] & 0xc0) == 0x80) &&-	     ((data [4] & 0x60) == 0x00)) {+  } /* Old style packet maybe */+   else if (((data [0] & 0xC0) == 0xC0) && /* Static in byte 0*/+	     ((data [1] & 0x60) == 0x00) && /* Static in byte 1*/+	     ((data [3] & 0xC0) == 0x80) && /* Static in byte 3*/+	     ((data [4] & 0x60) == 0x00)) { /* Static in byte 4*/     report->gesture  = check_bits (data [0], 0x04);     report->finger   = check_bits (data [1], 0x80);     report->left     = check_bits (data [0], 0x01);     report->middle   = 0;     report->right    = check_bits (data [0], 0x02);-    report->x        = (((data [1] & 0x1f) << 8) |-			data [2]);+    report->x        = (((data [1] & 0x1F) << 8) |+			((data [2])));     report->y        = (((data [4] & 0x1f) << 8) |-			data [5]);+			((data [5])));     report->pressure = (((data [0] & 0x30) << 2 ) |-			(data [3] & 0x3f));-  } else {-    gpm_debug_log (LOG_NOTICE,"tossing PS/2 data: ");+			((data [3] & 0x3f)));+   } else { /* Garbage  or not+	     * The synaptics pad keeps sending data 1 sec after last touch+	    */+    gpm_debug_log (LOG_NOTICE,"Garbage or tossing PS/2 data: ");     for (i = 0; i < 6; i++)       gpm_debug_log (LOG_NOTICE,"%02X ", data [i]);     report->gesture  = 0;@@ -1217,56 +1405,79 @@   } } ++/* STIG page 42+ * wmode = 1, + *+ * byte 0 |     1   |    0   |  W 2-3              |    0   | W 1     |  Right  | Left |  + * byte 1 |         y-pos 11-8                     |         x-pos  11-8               |+ * byte 2 |                           z pressure 0-7                                   |+ * byte 3 |     1   |    1   | y-pos 12 | x-pos 12 |    0   | W 0     |  R/D    | L/U  |+ * byte 4 |                                 x - pos 0-7                                |+ * byte 5 |                                 y - pos 0-7                                |+ *+ */+ static void syn_translate_ps2_wmode_report (unsigned char *data, 				      report_type *report)  {   int i;-  static int finger_timer = 0;-  static int gesture_timer = 0;+  static int finger_on_pad_timer = 0;+  static int time_to_forget_tap = 0;   static int gesture_delay = 0;   static int stroke_x;   static int stroke_y;   static int drag_locked = 0; +  /* Check that it is an absolute packet */   if (((data[0] & 0xc8) == 0x80) && ((data[3] & 0xc8) == 0xc0)) {-    unsigned int w = ((data[3] & 0x04) >> 2) |++    unsigned int w = (((data[3] & 0x04) >> 2) | 	    		((data[0] & 0x04) >> 1) |-			((data[0] & 0x30) >> 2);+		      ((data[0] & 0x30) >> 2));     report->left     = check_bits (data[0], 0x01);     report->middle   = check_bits (data[0] ^ data[3], 0x01);     report->down     = check_bits (data[0] ^ data[3], 0x02);     report->right    = check_bits (data[0], 0x02);-    report->x        = (((data[1] & 0x0f) << 8) |+    report->x        = (((data[1] & 0x0F) << 8) | 			((data[3] & 0x10) << 8) |-			data[4]);-    report->y        = (((data[1] & 0xf0) << 4) |+			((data[4])));+    report->y        = (((data[1] & 0xF0) << 4) | 			((data[3] & 0x20) << 7) |-			data[5]);+			((data[5])));     report->pressure = data[2];     report->finger   = (data[2] > finger_threshold);          if (report->finger) { 	    -      if (finger_timer == 0) { /* finger down */+      if (finger_on_pad_timer == 0) { /* finger down for the first time */ 	stroke_x = report->x; 	stroke_y = report->y;       }       -      if (finger_timer < (tap_upper_limit * 80 / 1000)) finger_timer ++; /* don't want timer to overflow */-      -      if (gesture_timer > 0) gesture_timer = 1; /* dragging or consecutive tap, gesture to end with finger up */+      /* don't want timer to overflow */+      if (finger_on_pad_timer < (tap_upper_limit * 80 / 1000)) +	finger_on_pad_timer ++; +      +       /* dragging or consecutive tap, gesture to end with finger up +       *  forget fast that there was a tap if this is not a part of a tap.*/+      if (time_to_forget_tap > 0) +	time_to_forget_tap = 1;            } else { /* interesting things happen when finger is up */ 	    -      /* tap determination */-      if ((finger_timer > (tap_lower_limit * 80 / 1000)) &&  /* minimum finger down time */-	  (finger_timer < (tap_upper_limit * 80 / 1000)) &&  /* maximum finger down time */+      /* tap determination: Was the finger long enough on the pad and not too+       * long, while staying at the same place.+       */+      if ((finger_on_pad_timer > (tap_lower_limit * 80 / 1000)) &&  /* minimum finger down time */+	  (finger_on_pad_timer < (tap_upper_limit * 80 / 1000)) &&  /* maximum finger down time */ 	  (distance((double)(stroke_x - report->x),  /* maximum range for finger to drift while down */ 	    (double)(stroke_y - report->y)) 	    < sqr((double)tap_range))) {  	/* not a consecutive tap? */-	if (gesture_timer == 0) gesture_delay = 0; /* right -> don't delay gesture */+	if (time_to_forget_tap == 0) +	  gesture_delay = 0; /* right -> don't delay gesture */ 	else { /* a consecutive tap! */ 	  gesture_delay = multiple_click_delay * 80 / 1000; /* delay gesture to create multiple click */ 	}@@ -1274,28 +1485,32 @@ 	/* is drag locked */ 	if (drag_locked) { 	  drag_locked = 0; /* unlock it and don't gesture. */-	  gesture_timer = 0;-	} else gesture_timer = tap_interval * 80 / 1000; /* setup gesture time to count down */+	  time_to_forget_tap = 0;+	} else +	  time_to_forget_tap = tap_interval * 80 / 1000; /* setup gesture time to count down */ 	-      } else {+      } else { /* It was not a tap */ 	      -	/* a drag to lock? */-	if (drag_lock && (gesture_timer > 0) && (finger_timer >= (tap_upper_limit * 80 / 1000)))+	/* a drag to lock?  If user did a tap and quickly hold the finger longer than a tap.+	*/+	if (drag_lock && (time_to_forget_tap > 0) && (finger_on_pad_timer >= (tap_upper_limit * 80 / 1000))) 	  drag_locked = 1; 	      -	if (gesture_timer > 0) gesture_timer --;+	if (time_to_forget_tap > 0) time_to_forget_tap --; 	if (gesture_delay > 0) gesture_delay --; 	       }       -      finger_timer = 0;+      finger_on_pad_timer = 0;            }     -    report->gesture  = ((gesture_timer > 0) && (gesture_delay == 0)) || drag_locked;+    report->gesture  = ((time_to_forget_tap > 0) && (gesture_delay == 0)) || drag_locked;     report->left = (report->left || report->gesture); -  } else {+  } else { /* Packet is garbage or not?? The synaptics pad keeps sending data 1+	    * sec after last touch, +	    */     gpm_debug_log (LOG_NOTICE,"tossing PS/2 data: ");     for (i = 0; i < 6; i++)       gpm_debug_log (LOG_NOTICE,"%02X ", data [i]);@@ -1343,8 +1558,11 @@ {   report_type   report; -  if (use_wmode) syn_translate_ps2_wmode_report (data, &report);-  else syn_translate_ps2_report (data, &report);+  if (use_wmode) +    syn_translate_ps2_wmode_report (data, &report);+  else +    syn_translate_ps2_report (data, &report);+   syn_process_data (state, report); } @@ -1394,7 +1612,8 @@   syn_read_ps2_ident (fd, &ident);   syn_read_ps2_model_id (fd, &model);   syn_read_ps2_cap (fd, &cap);-  if (! (cap.cap_ext)) use_wmode = 0; /* wmode not support by the pad */+  if (! (cap.cap_ext)) +    use_wmode = 0; /* wmode not support by the pad */   syn_process_config (ident, model);    /* select 6 byte packet, high packet rate, no-sleep */

⌨️ 快捷键说明

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