📄 gpm-diff-first
字号:
-} location_type;- /*-** The information in the mode byte.+** The sensor types as of STIG 2.5+** Page 11 */-#define RELATIVE_MODE 0x00-#define ABSOLUTE_MODE 0x80-#define LOW_REPORT_RATE 0x00-#define HIGH_REPORT_RATE 0x40-#define USE_1200_BAUD 0x00-#define USE_9600_BAUD 0x08-#define PS2_NO_SLEEP 0x00-#define PS2_SLEEP 0x08-#define NORMAL_REPORT 0x00-#define EXTENDED_REPORT 0x02-#define REPORT_W_OFF 0x00-#define REPORT_W_ON 0x01-- static char *model_names [] = { "Unknown",- "Standard TouchPad",- "Mini Module",- "Super Module",+ "Standard TouchPad (TM41xx134)",+ "Mini Module (TM41xx156)",+ "Super Module (TM41xx180)", "", "", "",- "Flexible pad",- "Ultra-thin Module",- "Wide pad Module",+ "Flexible pad (discontinued)",+ "Ultra-thin Module (TM41xx220)",+ "Wide pad Module (TW41xx230)", "",- "Stamp pad Module",- "Sub-mini Module",- "TBD",+ "Stamp pad Module (TM41xx240)",+ "Sub-mini Module (TM41xx140)",+ "MultiSwitch module (TBD)", "",- "Advanced Technology pad",+ "Advanced Technology pad (TM41xx221)", "Ultra-thin Module, connector reversed" }; /* ** Define the information known about a sensor.+** STIG page 14.+** Resolution only apply for absolute mode.+** For older models the default resulotion is 85x94. */ typedef struct { char *model;@@ -381,6 +374,76 @@ /*+** The information returned in the extended capability packet.+** STIG page 15+*/++#define EXT_CAP_EXTENDED 0x8000 /* Bit 15 */+#define EXT_CAP_SLEEP 0x0010 /* Bit 4 */+#define EXT_CAP_FOUR_BUTTON 0x0008 /* Bit 3 */+#define EXT_CAP_MULTI_FINGER 0X0002 /* Bit 1 */+#define EXT_CAP_PALM_DETECT 0X0001 /* Bit 0 */++typedef struct {+ int cap_ext; + int cap_sleep; + int cap_four_button; + int cap_multi_finger; + int cap_palm_detect; +} ext_cap_type;++++/*+** The information in the mode byte.+** STIG Page 17+*/+#define ABSOLUTE_MODE 0x80 /* Bit 7 set */+#define RELATIVE_MODE 0x00 /* Bit */+#define HIGH_REPORT_RATE 0x40 /* Bit 6 set 0 = 80 packages per second */+#define LOW_REPORT_RATE 0x00 /* Bit 40 packages per second */+#define USE_9600_BAUD 0x08 /* Bit 3 for serial protocol */+#define USE_1200_BAUD 0x00 /* Bit */+#define PS2_SLEEP 0x08 /* Bit 3 for ps2 protocol */+#define PS2_NO_SLEEP 0x00 /* Bit */+#define NO_TAPDRAG_GESTURE 0x04 /* Bit 2 for model version >= 4 */+#define TAPDRAG_GESTURE 0x00 /* Bit */ +#define EXTENDED_REPORT 0x02 /* Bit 1 for serial absolute mode only */+#define NORMAL_REPORT 0x00 /* Bit */+#define REPORT_W_ON 0x01 /* Bit 0 set */+#define REPORT_W_OFF 0x00 /* Bit */++++/*+** The format of the reported absolute data.+*/+typedef struct {+ int gesture;+ int finger;+ int left;+ int middle;+ int down;+ int right;+ int x;+ int y;+ int pressure;+} report_type;+++/*+** A location record.+** This is needed to make an average over several packages, +** because the reported x,y might not be that accurate.+*/+typedef struct {+ int x;+ int y;+} location_type;++++/* ** Parameters for controlling the touchpad. */ /* touchpad information */@@ -417,7 +481,8 @@ ** ****************************************************************************/ +/* Get model name, STIG page 11 */ static char *syn_model_name (int sensor) { if (sensor < 0 || sensor > 16) { return "Reserved";@@ -427,24 +492,27 @@ } -/* convert the model id from bits to values */+/* convert the model id from bits to values +* STIG page 11 +*/ void extract_model_id_info (int model_int, model_id_type *model) {- model->info_rot180 = check_bits (model_int, 0x00800000);- model->info_portrait = check_bits (model_int, 0x00400000);- model->info_sensor = (model_int & 0x003f0000) >> 16;- model->info_hardware = (model_int & 0x0000fe00) >> 8;- model->info_new_abs = check_bits (model_int, 0x00000080);- model->info_cap_pen = check_bits (model_int, 0x00000040);- model->info_simple_cmd = check_bits (model_int, 0x00000020);- model->info_geometry = model_int & 0x0000000f;+ model->info_rot180 = check_bits (model_int, INFO_ROT180_BITS);+ model->info_portrait = check_bits (model_int, INFO_PORTRAIT_BITS);+ model->info_sensor = (model_int & INFO_SENSOR_BITS) >> 16;+ model->info_hardware = (model_int & INFO_HARDWARE_BITS) >> 8;+ model->info_new_abs = check_bits (model_int, INFO_NEW_ABS_BITS);+ model->info_cap_pen = check_bits (model_int, INFO_CAP_PEN_BITS);+ model->info_simple_cmd = check_bits (model_int, INFO_SIMPLE_CMD_BITS);+ model->info_geometry = (model_int & INFO_GEOMETRY_BITS); } -/* Translate the reported data into a record for processing */+/* Translate the reported data into a record for processing + * STIG page 14*/ static sensor_info_type *syn_get_sensor_info (int sensor_id) {- if (sensor_id < 0 || sensor_id > 12) {+ if (sensor_id < 0 || 12 < sensor_id ) { return &sensor_info [0]; } else { return &sensor_info [sensor_id];@@ -519,14 +589,14 @@ int edges) { gpm_debug_log (LOG_DEBUG,- "\r%c%c%c%c%c %4dx%-4d %3d %c%c%c%c %c%c",+ "\rSynps2: %c%c%c%c%c %4dx%-4d %3d %c%c%c%c %c%c", report.gesture ? 'g' : '-', report.finger ? 'f' : '-', report.left ? 'l' : '-', report.middle ? 'm' : '-', - report.right ? 'r' : '-',+ report.x, report.y, report.pressure, edges & LEFT_EDGE ? 'l' : '-', edges & RIGHT_EDGE ? 'r' : '-',@@ -637,6 +707,7 @@ last_edges = edges; packet_num++; } else {+ /* No finger on the pad */ /* handle the tossing action if enabled */ if (tossing_enabled && !was_tossing && last_finger &&@@ -1045,66 +1120,127 @@ /* Adapted from tpconfig.c by C. Scott Ananian */ /*------------------------------------------------------------------------*/ +/* PS2 Synaptics is using LSB, STIG page 29. +**+** After power on or reset:+** 100 samples per second+** Resolution is 4 counts per mm+** Scaling 1:1+** Stream mode is selected+** Data reporting is disabled+** Absolte mode is disabled+*/++/* Normal ps2 commands, Command set is on STIG page 33 */+#define PS2_RESET 0xFF /* Reset */+#define PS2_RESEND 0xFE /* Resend command */+#define PS2_ERROR 0xFC /* Error, after an resend or disconnect*/+#define PS2_ACK 0xFA /* Command acknowledge */+#define PS2_SAMPLE_RATE 0xF3 /* Set sample rate to the following byte */+#define PS2_READ_DEVICE 0xF2 /* Read device type */+#define PS2_READY 0xAA /* Send after a calibration or ERROR */+#define PS2_STATUS_REQ 0xE9 /* Send status request */+#define PS2_RESOLUTION 0xE8 /* Set resolution, to following transmitted byte */+#define PS2_SCALE_11 0xE6 /* Set scale to 1:1 */+++/* Additional commands*/+#define PS2_SYN_CMD 0xE8 /* Four of these each with an following byte encodes a command*/+#define PS2_SYN_INERT 0xE6 /* This ps2 command is ignored by synaptics */+#define PS2_SYN_STATUS_OK 0x47 /* Special synaptics Status report is recognized */+#define PS2_SYN_IDCODE 0x00+#define PS2_SYN_SET_MODE 0x14 /* Set the mode instead of sample rate (used after a sample rate cmd) */+++/* These are the commands that can be given (encoded) by PS_SYN_CMD */+#define PS2_SYN_CMD_IDENTIFY 0x00 /* Identify Touchpad */+#define PS2_SYN_CMD_MODES 0x01 /* Read Touchpad Modes */+#define PS2_SYN_CMD_CAPABILITIES 0x02 /* Read capabilities */+#define PS2_SYN_CMD_MODEL_ID 0x03 /* Read model id */+#define PS2_SYN_CMD_SERIAL_NO_P 0x06 /* Read serial number prefix */+#define PS2_SYN_CMD_SERIAL_NO_S 0x07 /* Read serial number suffix */+#define PS2_SYN_CMD_RESOLUTIONS 0x08 /* Read resolutions */++++ typedef unsigned char byte; +/* read a byte from the ps/2 port */+static byte ps2_getbyte(int fd) +{+ byte b;++ read(fd, &b, 1);+ return b;+}++ /* write a byte to the ps/2 port, handling ACK */ static void ps2_putbyte(int fd, byte b) { byte ack;+ write(fd, &b, 1); read(fd, &ack, 1);- if (ack != 0xFA)+ /* Should check for resend code PS2_RESEND also */+ if (ack != PS2_ACK) gpm_debug_log (LOG_ERR,"Invalid ACK in synps2 initialization"); } -/* read a byte from the ps/2 port */-static byte ps2_getbyte(int fd) -{- byte b;- read(fd, &b, 1);- return b;-}--/* use the Synaptics extended ps/2 syntax to write a special command byte */+/* use the Synaptics extended ps/2 syntax to write a special command byte +* STIG page 36: Send exactly four PS2_SYN_CMD (which is otherwise ignored)+* and after each a byte with the 2 first bits being the command (LSB). End it with+* either PS2_SAMPLE_RATE or PS2_STATUS_REQ. It is hinted to send an inert command+* first so not have five or more PS2_SYN_CMD by coincident.+*/ static void ps2_send_cmd(int fd, byte cmd) { int i;+ /* initialize with 'inert' command */- ps2_putbyte(fd, 0xE6);+ ps2_putbyte(fd, PS2_SYN_INERT); for (i=0; i<4; i++) {- ps2_putbyte(fd, 0xE8);+ ps2_putbyte(fd, PS2_SYN_CMD); ps2_putbyte(fd, (cmd>>6)&0x3); cmd<<=2; } } -/* write 'cmd' to mode byte 1 */+/* write 'cmd' to mode byte 1.+ * See ps2_send_cmd */ static void ps2_set_mode1(int fd, byte cmd) { ps2_send_cmd(fd, cmd);- ps2_putbyte(fd, 0xF3);+ ps2_putbyte(fd, PS2_SAMPLE_RATE); ps2_putbyte(fd, 0x0A); } -/* write 'cmd' to mode byte 2 */+/* write 'cmd' to mode byte 2 + * See ps2_send_cmd. PS2_SR_SET_MODE stores the touchpad mode encoded in the + * four PS2_SYN_CMD commands+ */ static void ps2_set_mode2(int fd, byte cmd) { ps2_send_cmd(fd, cmd);- ps2_putbyte(fd, 0xF3);- ps2_putbyte(fd, 0x14);+ ps2_putbyte(fd, PS2_SAMPLE_RATE);+ ps2_putbyte(fd, PS2_SYN_SET_MODE); } -/* read three byte status ('a','b','c') corresponding to register 'cmd' */+/* read three byte status ('a','b','c') corresponding to register 'cmd' +* Special status request for synatips is given after a cmd.+* Byte b is PS2_SYN_STATUS_OK to recognize a synaptics+*/ static void ps2_status_rqst(int fd, byte cmd,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -