[PATCH v2 synaptics] Add support for INPUT_PROP_TOPBUTTONPAD

Peter Hutterer peter.hutterer at who-t.net
Mon Apr 28 19:34:52 PDT 2014


From: Hans de Goede <hdegoede at redhat.com>

Add a HasSecondaryButtons boolean config option which defaults to true for
devices with the INPUT_PROP_TOPBUTTONPAD and false for all other devices.

Only parse the SecondarySoftButtonAreas when this option is true, effectively
disabling the top buttons when it is false. Likewise, only initialize the
SecondarySoftButtonAreas property if we enable support for it.

This means that it is now safe to always set a SecondarySoftButtonAreas
default in 50-synaptics.conf, and that he section which was intended for
use with future pnp-id matching can be dropped, as that is now all handled
in the kernel.

While at also remove the comment about disabling the bottom edge area, as that
is now done automatically.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- change from "TopClickPad" to HasSecondaryButtons. Not ideal either, I'm
  still open for bettert suggestions.
- man page additions
- don't initialize the property if HasSecondaryButtons is off

 conf/50-synaptics.conf | 25 ++++---------------------
 man/synaptics.man      | 29 +++++++++++++++++++++++------
 src/eventcomm.c        |  8 ++++++++
 src/properties.c       |  3 +++
 src/synaptics.c        |  7 ++++++-
 src/synapticsstr.h     |  1 +
 6 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/conf/50-synaptics.conf b/conf/50-synaptics.conf
index 161c1dd..a3145b8 100644
--- a/conf/50-synaptics.conf
+++ b/conf/50-synaptics.conf
@@ -25,16 +25,15 @@ Section "InputClass"
         Option "Ignore" "on"
 EndSection
 
-# This option enables the bottom right corner to be a right button on
-# non-synaptics clickpads.
+# This option enables the bottom right corner to be a right button on clickpads
+# and the right and middle top areas to be right / middle buttons on clickpads
+# with a top button area.
 # This option is only interpreted by clickpads.
 Section "InputClass"
         Identifier "Default clickpad buttons"
         MatchDriver "synaptics"
         Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
-#       To disable the bottom edge area so the buttons only work as buttons,
-#       not for movement, set the AreaBottomEdge
-#       Option "AreaBottomEdge" "82%"
+        Option "SecondarySoftButtonAreas" "58% 0 0 8% 42% 58% 0 8%"
 EndSection
 
 # This option disables software buttons on Apple touchpads.
@@ -45,19 +44,3 @@ Section "InputClass"
         MatchDriver "synaptics"
         Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
 EndSection
-
-# The Lenovo *40 series has no physical button for the TrackPoint and needs
-# the top softbutton area enabled by default.
-# Affected devices and their PNPIDs
-#       LEN0033:      Helix
-#       LEN0034:      T431, T540, X1 Carbon
-#       LEN0035:      X240
-#       LEN0036:      T440
-#       LEN0042:      Yoga
-#       LEN2004:      L440, L540
-Section "InputClass"
-        Identifier "Lenovo TrackPoint top software buttons"
-        MatchDriver "synaptics"
-        MatchPnPID  "LEN0033*|LEN0034*|LEN0035*|LEN0036*|LEN0042*|LEN2004*"
-        Option "SecondarySoftButtonAreas" "58% 0 0 8% 42% 58% 0 8%"
-EndSection
diff --git a/man/synaptics.man b/man/synaptics.man
index 2b8d1d9..76756be 100644
--- a/man/synaptics.man
+++ b/man/synaptics.man
@@ -495,17 +495,28 @@ buttons to share an edge value.
 Property: "Synaptics Soft Button Areas"
 .
 .TP
-.BI "Option \*qSecondarySoftButtonAreas\*q \*q" "RBL RBR RBT RBB MBL MBR MBT MBB" \*q
+.BI "Option \*qHasSecondarySoftButtons\*q \*q" boolean \*q
 This option is only available on ClickPad devices.
-Enable secondary soft button click area support on ClickPad devices (usually on
+Enable the secondary software button area support. The exact area must be
+set in option \*qSecondarySoftButtonAreas\*q.  See
+.B ClickPad support
+for more details.
+.
+.TP
+.BI "Option \*qSecondarySoftButtonAreas\*q \*q" "RBL RBR RBT RBB MBL MBR MBT MBB" \*q
+This option is only available on ClickPad devices and only if
+.B Option \*qHasSecondarySoftButtons\*q
+is enabled.
+Define the secondary soft button click areas on ClickPad devices (usually on
 top of the device).
 For the allowed values for this option, see
 .B Option \*qSoftButtonAreas\*q.
 Primary and secondary soft button areas must not overlap each other. If they do,
 the behavior of the driver is undefined.
 Property: "Synaptics Secondary Soft Button Areas". This property is only
-initialized if the option is set in the
-__xconfigfile__(__filemansuffix__).
+initialized if 
+.B Option \*qHasSecondarySoftButtons\*q 
+is enabled and this option is set in the __xconfigfile__(__filemansuffix__).
 .
 
 .SH CONFIGURATION DETAILS
@@ -729,9 +740,15 @@ area, a right or middle click is performed.
 .LP
 Some laptops, most notably the Lenovo T440, T540 and x240 series, provide a
 pointing stick without physical buttons. On those laptops, the top of the
-touchpad acts as software-emulated button area. This area can be configured
+touchpad acts as software-emulated button area. This area can be enabled
 with
-.B Option SecondarySoftButtonAreas.
+.B Option \*qHasSecondarySoftButtons\*q
+and configured
+with
+.B Option \*qSecondarySoftButtonAreas\*q.
+On some platforms, this option
+will be set automatically if the kernel detects a matching device. On Linux,
+the device must have the INPUT_PROP_TOPBUTTONPAD property set.
 
 .SH "DEVICE PROPERTIES"
 Synaptics 1.0 and higher support input device properties if the driver is
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 5871374..0a6ea48 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -50,6 +50,9 @@
 #ifndef INPUT_PROP_SEMI_MT
 #define INPUT_PROP_SEMI_MT 0x03
 #endif
+#ifndef INPUT_PROP_TOPBUTTONPAD
+#define INPUT_PROP_TOPBUTTONPAD 0x04
+#endif
 #ifndef ABS_MT_TOOL_Y
 #define ABS_MT_TOOL_Y 0x3d
 #endif
@@ -802,6 +805,11 @@ event_query_touch(InputInfoPtr pInfo)
         xf86IDrvMsg(pInfo, X_INFO, "found clickpad property\n");
         para->clickpad = TRUE;
     }
+
+    if (libevdev_has_property(dev, INPUT_PROP_TOPBUTTONPAD)) {
+        xf86IDrvMsg(pInfo, X_INFO, "found top buttonpad property\n");
+        para->has_secondary_buttons = TRUE;
+    }
 #endif
 
 
diff --git a/src/properties.c b/src/properties.c
index 4c75797..718d054 100644
--- a/src/properties.c
+++ b/src/properties.c
@@ -176,6 +176,9 @@ InitSoftButtonProperty(InputInfoPtr pInfo)
     prop_softbutton_areas =
         InitAtom(pInfo->dev, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 8, values);
 
+    if (!para->has_secondary_buttons)
+        return;
+
     values[0] = para->softbutton_areas[TOP_RIGHT_BUTTON_AREA][LEFT];
     values[1] = para->softbutton_areas[TOP_RIGHT_BUTTON_AREA][RIGHT];
     values[2] = para->softbutton_areas[TOP_RIGHT_BUTTON_AREA][TOP];
diff --git a/src/synaptics.c b/src/synaptics.c
index 118d1c6..c472a79 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -674,6 +674,10 @@ set_default_parameters(InputInfoPtr pInfo)
     pars->tap_time_2 = xf86SetIntOption(opts, "MaxDoubleTapTime", 180);
     pars->click_time = xf86SetIntOption(opts, "ClickTime", 100);
     pars->clickpad = xf86SetBoolOption(opts, "ClickPad", pars->clickpad);       /* Probed */
+    if (pars->clickpad)
+        pars->has_secondary_buttons = xf86SetBoolOption(opts,
+                                                        "HasSecondaryButtons",
+                                                        pars->has_secondary_buttons);
     pars->clickpad_ignore_motion_time = 100; /* ms */
     /* middle mouse button emulation on a clickpad? nah, you're joking */
     middle_button_timeout = pars->clickpad ? 0 : 75;
@@ -777,7 +781,8 @@ set_default_parameters(InputInfoPtr pInfo)
     }
 
     set_primary_softbutton_areas_option(pInfo);
-    set_secondary_softbutton_areas_option(pInfo);
+    if (pars->has_secondary_buttons)
+        set_secondary_softbutton_areas_option(pInfo);
 }
 
 static double
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index b8a3492..4bd32ac 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -176,6 +176,7 @@ typedef struct _SynapticsParameters {
     int tap_time_2;             /* max. tapping time for double taps */
     int click_time;             /* The duration of a single click */
     Bool clickpad;              /* Device is a has integrated buttons */
+    Bool has_secondary_buttons; /* Device has a top soft-button area */
     int clickpad_ignore_motion_time; /* Ignore motion for X ms after a click */
     int emulate_mid_button_time;        /* Max time between left and right button presses to
                                            emulate a middle button press. */
-- 
1.9.0



More information about the xorg-devel mailing list