Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pckbport Changes based on code from an anonymous con...



details:   https://anonhg.NetBSD.org/src/rev/b8ecf1a8b07e
branches:  trunk
changeset: 841826:b8ecf1a8b07e
user:      blymn <blymn%NetBSD.org@localhost>
date:      Sun Jun 02 08:55:00 2019 +0000

description:
Changes based on code from an anonymous contributor.  This should make
trackpads work for Thinkpads.  Also adds code to handle externally
connected buttons (synaptics parlance), the first five are mapped to
mouse buttons 1-5.  The rest are currently not reported but could be
decoded if required.

diffstat:

 sys/dev/pckbport/synaptics.c    |  40 ++++++++++++++++++++++++++++++++++------
 sys/dev/pckbport/synapticsreg.h |   8 +++++++-
 sys/dev/pckbport/synapticsvar.h |   3 ++-
 3 files changed, 43 insertions(+), 8 deletions(-)

diffs (114 lines):

diff -r 37731a689bbc -r b8ecf1a8b07e sys/dev/pckbport/synaptics.c
--- a/sys/dev/pckbport/synaptics.c      Sun Jun 02 06:09:17 2019 +0000
+++ b/sys/dev/pckbport/synaptics.c      Sun Jun 02 08:55:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: synaptics.c,v 1.48 2019/04/22 00:53:59 blymn Exp $     */
+/*     $NetBSD: synaptics.c,v 1.49 2019/06/02 08:55:00 blymn Exp $     */
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.48 2019/04/22 00:53:59 blymn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.49 2019/06/02 08:55:00 blymn Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -321,6 +321,9 @@
                                /* unreached */
                                break;
                        }
+
+                       if ((val & SYN_CCAP_HAS_ADV_GESTURE_MODE))
+                               sc->flags |= SYN_FLAG_HAS_ADV_GESTURE_MODE;
                }
        }
 }
@@ -477,7 +480,8 @@
                synaptics_poll_cmd(psc, PMS_SET_SCALE11, 0);
 
        /* Set advanced gesture mode */
-       if (sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE)
+       if ((sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE) ||
+           (sc->flags & SYN_FLAG_HAS_ADV_GESTURE_MODE))
                synaptics_special_write(psc, SYNAPTICS_WRITE_DELUXE_3, 0x3); 
 
        synaptics_poll_cmd(psc, PMS_DEV_ENABLE, 0);
@@ -990,9 +994,33 @@
                /* Pressure */
                sp.sp_z = psc->packet[2];
 
-               /* Left/Right button handling. */
-               sp.sp_left = psc->packet[0] & PMS_LBUTMASK;
-               sp.sp_right = psc->packet[0] & PMS_RBUTMASK;
+               if ((psc->packet[0] ^ psc->packet[3]) & 0x02) {
+                       /* extended buttons */
+
+                       aprint_debug_dev(psc->sc_dev,
+                           "synaptics_parse: %02x %02x %02x %02x %02x %02x\n",
+                           psc->packet[0], psc->packet[1], psc->packet[2],
+                           psc->packet[3], psc->packet[4], psc->packet[5]);
+
+                       if ((psc->packet[4] & SYN_1BUTMASK) != 0)
+                               sp.sp_left = PMS_LBUTMASK;
+
+                       if ((psc->packet[4] & SYN_3BUTMASK) != 0)
+                               sp.sp_middle = PMS_MBUTMASK;
+
+                       if ((psc->packet[5] & SYN_2BUTMASK) != 0)
+                               sp.sp_right = PMS_RBUTMASK;
+
+                       if ((psc->packet[5] & SYN_4BUTMASK) != 0)
+                               sp.sp_up = 1;
+
+                       if ((psc->packet[4] & SYN_5BUTMASK) != 0)
+                               sp.sp_down = 1;
+               } else {
+                       /* Left/Right button handling. */
+                       sp.sp_left = psc->packet[0] & PMS_LBUTMASK;
+                       sp.sp_right = psc->packet[0] & PMS_RBUTMASK;
+               }
 
                /* Up/Down buttons. */
                if (sc->flags & SYN_FLAG_HAS_BUTTONS_4_5) {
diff -r 37731a689bbc -r b8ecf1a8b07e sys/dev/pckbport/synapticsreg.h
--- a/sys/dev/pckbport/synapticsreg.h   Sun Jun 02 06:09:17 2019 +0000
+++ b/sys/dev/pckbport/synapticsreg.h   Sun Jun 02 08:55:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: synapticsreg.h,v 1.11 2019/04/22 00:53:59 blymn Exp $  */
+/*     $NetBSD: synapticsreg.h,v 1.12 2019/06/02 08:55:00 blymn Exp $  */
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -101,6 +101,12 @@
 /* Extended mode button masks. */
 #define        SYN_1BUTMASK                    0x1
 #define        SYN_2BUTMASK                    0x1
+#define        SYN_3BUTMASK                    0x2
+#define        SYN_4BUTMASK                    0x2
+#define        SYN_5BUTMASK                    0x4
+#define        SYN_6BUTMASK                    0x4
+#define        SYN_7BUTMASK                    0x8
+#define        SYN_8BUTMASK                    0x8
 
 /* Touchpad edge boundaries (Recommended values from Synaptics documentation) */
 #define        SYNAPTICS_EDGE_LEFT             1632
diff -r 37731a689bbc -r b8ecf1a8b07e sys/dev/pckbport/synapticsvar.h
--- a/sys/dev/pckbport/synapticsvar.h   Sun Jun 02 06:09:17 2019 +0000
+++ b/sys/dev/pckbport/synapticsvar.h   Sun Jun 02 08:55:00 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: synapticsvar.h,v 1.8 2018/11/06 09:13:17 blymn Exp $   */
+/*     $NetBSD: synapticsvar.h,v 1.9 2019/06/02 08:55:00 blymn Exp $   */
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -54,6 +54,7 @@
 #define        SYN_FLAG_HAS_ONE_BUTTON_CLICKPAD        (1 << 9)
 #define        SYN_FLAG_HAS_TWO_BUTTON_CLICKPAD        (1 << 10)
 #define        SYN_FLAG_HAS_EXTENDED_WMODE             (1 << 11)
+#define        SYN_FLAG_HAS_ADV_GESTURE_MODE           (1 << 12)
 
        u_int   total_packets[2];       /* Total number of packets received */
 #define        SYN_TIME(sc,c,n)        (((sc)->total_packets[(n)] >= (c)) ?    \



Home | Main Index | Thread Index | Old Index