Re: wsmouse(4): multi-touch buttons again

2023-06-28 Thread Tobias Heider
On Wed, Jun 28, 2023 at 12:03:41AM +0200, Ulf Brosziewski wrote:
> This version of the diff adds a wsconsctl field, named "mouse.tp.
> mtbuttons", and an update to the wsmouse.4 page.  Apart from that, it
> contains only stylistic changes.
> 
> The new wsconsctl field is just a boolean, I don't think that it would
> make sense to include the distance filter in the configuration options.
> However, if a default value is derived from the length of the touchpad
> diagonal, it might be too high for over-sized touchpads.  If that turns
> out to be a problem, the proper place to fix it is the hardware driver.
> 
> OK?

Thank you! Looks good and works as intended here.

I also have a diff to enable it for another Apple touch pad
but this diff is already big enough so I'll just send that
once this is in.

One minor comment inline, other than that ok tobhe@.

> 
> On 2/21/23 20:10, Ulf Brosziewski wrote:
> > This diff is an extension of Tobias Heider's proposal, which aims at
> > providing "Apple-like" button inputs on clickpads.  I have added some
> > things in order to approximate the behaviour of other input drivers.
> > 
> > [...]>
> > The feature won't work decently on small touchpads, and it cannot work
> > on touchpads without MT-support in our kernel.  wsmouse checks whether
> > a touchpad
> > 1) has MT support,
> > 2) is a clickpad,
> > 3) its resolution is reported to wsmouse,
> > 4) it reports a horizontal size greater than 100mm, and
> > 5) a vertical size greater than 60mm.
> > 
> > If these conditions aren't met, wsmouse sets the distance limit to -1,
> > which blocks the MTBUTTONS feature.  I think only imt(4) touchpads can
> > meet these criteria; however, the value can be overridden manually or
> > programmatically, and ubcmtp and aplms do this on initialization.
> > These drivers don't report resolution values; the distance limit will
> > be set to a fourth of the length of the touchpad diagonal.  That's a
> > workaround based on a wild guess, and I couldn't test it with Apple
> > hardware.  If you want to apply it to an Elantech-v4 touchpad run by
> > pms(4), try
> > 
> > # wsconsctl mouse.param=143:0,72:1
> > 
> > (A change from -1 to 0 will trigger the workaround.)
> > 
> > 
> > [...]
> Index: src/sbin/wsconsctl/mouse.c
> ===
> RCS file: /cvs/src/sbin/wsconsctl/mouse.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 mouse.c
> --- src/sbin/wsconsctl/mouse.c19 Aug 2019 21:42:33 -  1.20
> +++ src/sbin/wsconsctl/mouse.c27 Jun 2023 18:54:31 -
> @@ -57,6 +57,7 @@ struct field mouse_field_tab[] = {
>  { "reverse_scrolling",   _revscroll, FMT_CFG,FLG_NORDBACK },
>  /* touchpad-specific options: */
>  { "tp.tapping",  _tapping,   FMT_CFG,FLG_NORDBACK },
> +{ "tp.mtbuttons",_mtbuttons, FMT_CFG,
> FLG_NORDBACK },
>  { "tp.scaling",  _scaling,   FMT_CFG,FLG_NORDBACK },
>  { "tp.swapsides",_swapsides, FMT_CFG,
> FLG_NORDBACK },
>  { "tp.disable",  _disable,   FMT_CFG,FLG_NORDBACK },
> @@ -69,6 +70,10 @@ struct field mouse_field_tab[] = {
> 
>  static int dev_index = -1;
> 
> +static struct wsmouse_parameters mtbtn_maxdist = {
> +(struct wsmouse_param[]) { { WSMOUSECFG_MTBTN_MAXDIST, 0 } }, 1
> +};
> +
> 
>  void
>  mouse_init(int devfd, int devidx) {
> @@ -91,6 +96,12 @@ mouse_init(int devfd, int devidx) {
>   if (f->format == FMT_CFG) {
>   f->flags &= ~FLG_DEAD;
>   }
> + /* Hide the 'mtbuttons' field if the feature is unavailable. */
> + if (mousecfg_get_field(_maxdist) ||
> + mtbtn_maxdist.params[0].value < 0) {
> + f = field_by_value(mouse_field_tab, _mtbuttons);
> + f->flags |= FLG_DEAD;
> + }
>   } else {
>   for (f = mouse_field_tab; f->name != NULL; f++)
>   if (f->format == FMT_CFG) {
> Index: src/sbin/wsconsctl/mousecfg.c
> ===
> RCS file: /cvs/src/sbin/wsconsctl/mousecfg.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 mousecfg.c
> --- src/sbin/wsconsctl/mousecfg.c 3 Mar 2021 19:44:37 -   1.9
> +++ src/sbin/wsconsctl/mousecfg.c 27 Jun 2023 18:54:31 -
> @@ -35,30 +35,15 @@
>  #define nitems(_a)   (sizeof((_a)) / sizeof((_a)[0]))
>  #endif
> 
> -#define BASE_FIRST   WSMOUSECFG_DX_SCALE
> -#define BASE_LASTWSMOUSECFG_REVERSE_SCROLLING
> -#define TP_FILTER_FIRST  WSMOUSECFG_DX_MAX
> -#define TP_FILTER_LAST   WSMOUSECFG_SMOOTHING
> -#define TP_FEATURES_FIRSTWSMOUSECFG_SOFTBUTTONS
> -#define TP_FEATURES_LAST WSMOUSECFG_DISABLE
> -#define TP_SETUP_FIRST   WSMOUSECFG_LEFT_EDGE
> -#define TP_SETUP_LAST 

Re: wsmouse(4): multi-touch buttons again

2023-06-27 Thread Jason McIntyre
On Wed, Jun 28, 2023 at 12:03:41AM +0200, Ulf Brosziewski wrote:
> This version of the diff adds a wsconsctl field, named "mouse.tp.
> mtbuttons", and an update to the wsmouse.4 page.  Apart from that, it
> contains only stylistic changes.
> 
> The new wsconsctl field is just a boolean, I don't think that it would
> make sense to include the distance filter in the configuration options.
> However, if a default value is derived from the length of the touchpad
> diagonal, it might be too high for over-sized touchpads.  If that turns
> out to be a problem, the proper place to fix it is the hardware driver.
> 
> OK?
> 

hi.

one note about the doc:

> Index: src/share/man/man4/wsmouse.4
> ===
> RCS file: /cvs/src/share/man/man4/wsmouse.4,v
> retrieving revision 1.22
> diff -u -p -r1.22 wsmouse.4
> --- src/share/man/man4/wsmouse.4  4 Mar 2021 17:03:42 -   1.22
> +++ src/share/man/man4/wsmouse.4  27 Jun 2023 18:54:31 -
> @@ -106,6 +106,10 @@ If, within a short time interval, a seco
>  mapped to a left-button click, the button-up event is not issued
>  until that touch ends
>  .Pq Dq tap-and-drag .
> +.It Cm mouse.tp.mtbuttons
> +This feature is supported from some clickpads.
> +If enabled, two-finger clicks - with the fingers side by side - generate
> +left-button events, three-finger clicks generate middle-button events.

at a minimum, i'd put a semi-colon after "events", not a comma.

or you could join the two parts like this:

...generate left-button events, whilst three-finger clicks...

or more simple:

...generate left-button events, and three-finger clicks...

jmc

>  .It Cm mouse.tp.scaling
>  The value is a scale coefficient that is applied to the relative
>  coordinates.



Re: wsmouse(4): multi-touch buttons again

2023-06-27 Thread Ulf Brosziewski
This version of the diff adds a wsconsctl field, named "mouse.tp.
mtbuttons", and an update to the wsmouse.4 page.  Apart from that, it
contains only stylistic changes.

The new wsconsctl field is just a boolean, I don't think that it would
make sense to include the distance filter in the configuration options.
However, if a default value is derived from the length of the touchpad
diagonal, it might be too high for over-sized touchpads.  If that turns
out to be a problem, the proper place to fix it is the hardware driver.

OK?

On 2/21/23 20:10, Ulf Brosziewski wrote:
> This diff is an extension of Tobias Heider's proposal, which aims at
> providing "Apple-like" button inputs on clickpads.  I have added some
> things in order to approximate the behaviour of other input drivers.
> 
> [...]>
> The feature won't work decently on small touchpads, and it cannot work
> on touchpads without MT-support in our kernel.  wsmouse checks whether
> a touchpad
> 1) has MT support,
> 2) is a clickpad,
> 3) its resolution is reported to wsmouse,
> 4) it reports a horizontal size greater than 100mm, and
> 5) a vertical size greater than 60mm.
> 
> If these conditions aren't met, wsmouse sets the distance limit to -1,
> which blocks the MTBUTTONS feature.  I think only imt(4) touchpads can
> meet these criteria; however, the value can be overridden manually or
> programmatically, and ubcmtp and aplms do this on initialization.
> These drivers don't report resolution values; the distance limit will
> be set to a fourth of the length of the touchpad diagonal.  That's a
> workaround based on a wild guess, and I couldn't test it with Apple
> hardware.  If you want to apply it to an Elantech-v4 touchpad run by
> pms(4), try
> 
> # wsconsctl mouse.param=143:0,72:1
> 
> (A change from -1 to 0 will trigger the workaround.)
> 
> 
> [...]
Index: src/sbin/wsconsctl/mouse.c
===
RCS file: /cvs/src/sbin/wsconsctl/mouse.c,v
retrieving revision 1.20
diff -u -p -r1.20 mouse.c
--- src/sbin/wsconsctl/mouse.c  19 Aug 2019 21:42:33 -  1.20
+++ src/sbin/wsconsctl/mouse.c  27 Jun 2023 18:54:31 -
@@ -57,6 +57,7 @@ struct field mouse_field_tab[] = {
 { "reverse_scrolling", _revscroll, FMT_CFG,FLG_NORDBACK },
 /* touchpad-specific options: */
 { "tp.tapping",_tapping,   FMT_CFG,FLG_NORDBACK },
+{ "tp.mtbuttons",  _mtbuttons, FMT_CFG,FLG_NORDBACK },
 { "tp.scaling",_scaling,   FMT_CFG,FLG_NORDBACK },
 { "tp.swapsides",  _swapsides, FMT_CFG,FLG_NORDBACK },
 { "tp.disable",_disable,   FMT_CFG,FLG_NORDBACK },
@@ -69,6 +70,10 @@ struct field mouse_field_tab[] = {

 static int dev_index = -1;

+static struct wsmouse_parameters mtbtn_maxdist = {
+(struct wsmouse_param[]) { { WSMOUSECFG_MTBTN_MAXDIST, 0 } }, 1
+};
+

 void
 mouse_init(int devfd, int devidx) {
@@ -91,6 +96,12 @@ mouse_init(int devfd, int devidx) {
if (f->format == FMT_CFG) {
f->flags &= ~FLG_DEAD;
}
+   /* Hide the 'mtbuttons' field if the feature is unavailable. */
+   if (mousecfg_get_field(_maxdist) ||
+   mtbtn_maxdist.params[0].value < 0) {
+   f = field_by_value(mouse_field_tab, _mtbuttons);
+   f->flags |= FLG_DEAD;
+   }
} else {
for (f = mouse_field_tab; f->name != NULL; f++)
if (f->format == FMT_CFG) {
Index: src/sbin/wsconsctl/mousecfg.c
===
RCS file: /cvs/src/sbin/wsconsctl/mousecfg.c,v
retrieving revision 1.9
diff -u -p -r1.9 mousecfg.c
--- src/sbin/wsconsctl/mousecfg.c   3 Mar 2021 19:44:37 -   1.9
+++ src/sbin/wsconsctl/mousecfg.c   27 Jun 2023 18:54:31 -
@@ -35,30 +35,15 @@
 #define nitems(_a)   (sizeof((_a)) / sizeof((_a)[0]))
 #endif

-#define BASE_FIRST WSMOUSECFG_DX_SCALE
-#define BASE_LAST  WSMOUSECFG_REVERSE_SCROLLING
-#define TP_FILTER_FIRSTWSMOUSECFG_DX_MAX
-#define TP_FILTER_LAST WSMOUSECFG_SMOOTHING
-#define TP_FEATURES_FIRST  WSMOUSECFG_SOFTBUTTONS
-#define TP_FEATURES_LAST   WSMOUSECFG_DISABLE
-#define TP_SETUP_FIRST WSMOUSECFG_LEFT_EDGE
-#define TP_SETUP_LAST  WSMOUSECFG_TAP_THREE_BTNMAP
-#define LOG_FIRST  WSMOUSECFG_LOG_INPUT
-#define LOG_LAST   WSMOUSECFG_LOG_EVENTS
-
-#define BASESIZE ((BASE_LAST - BASE_FIRST + 1) + (LOG_LAST - LOG_FIRST + 1))
-
-#define BUFSIZE (BASESIZE \
-+ (TP_FILTER_LAST - TP_FILTER_FIRST + 1) \
-+ (TP_FEATURES_LAST - TP_FEATURES_FIRST + 1) \
-+ (TP_SETUP_LAST - TP_SETUP_FIRST + 1))
+#define BASESIZE ((WSMOUSECFG__FILTERS - WSMOUSECFG_DX_SCALE) \
++ (WSMOUSECFG__DEBUG - WSMOUSECFG_LOG_INPUT))

 

Re: wsmouse(4): multi-touch buttons again

2023-02-23 Thread Ulf Brosziewski
I do not expect users to find that field, or play around with it
if they don't know what they do.  It's "hidden" in wsconsctl for a
reason.  And plainly, I had no time for the wsconsctl part.

On 2/23/23 17:25, joshua stein wrote:
> On Thu, 23 Feb 2023 at 17:05:53 +0100, Tobias Heider wrote:
>> Wow, thank you for looking into this! I've used your version for a few days
>> now and it works really well for me (on a m2 macbook air).  I actually think
>> the default works so well that we can default to 0 for param 143.
>>
>> IMO we can add it to the tree at this point to give others the change to
>> test it before the diff gets even bigger.
> 
> But please add properly named knobs to wsconsctl for this first, and 
> preferably for all of the other hidden settings that were added with 
> wstpad.  Expecting users to enable, let alone find, 
> "mouse.tp.param=72:1" is ridiculous.
> 
> On one of my laptops I wanted to disable the middle soft button and 
> had to dig through the code to figure out that I had to use 
> "wsconsctl mouse.tp.param=65:0".
> 



Re: wsmouse(4): multi-touch buttons again

2023-02-23 Thread Tobias Heider
On Thu, Feb 23, 2023 at 10:25:15AM -0600, joshua stein wrote:
> On Thu, 23 Feb 2023 at 17:05:53 +0100, Tobias Heider wrote:
> > Wow, thank you for looking into this! I've used your version for a few days
> > now and it works really well for me (on a m2 macbook air).  I actually think
> > the default works so well that we can default to 0 for param 143.
> > 
> > IMO we can add it to the tree at this point to give others the change to
> > test it before the diff gets even bigger.
> 
> But please add properly named knobs to wsconsctl for this first, and 
> preferably for all of the other hidden settings that were added with 
> wstpad.  Expecting users to enable, let alone find, 
> "mouse.tp.param=72:1" is ridiculous.
> 
> On one of my laptops I wanted to disable the middle soft button and 
> had to dig through the code to figure out that I had to use 
> "wsconsctl mouse.tp.param=65:0".
> 

Absolutely. I assumed once it goes in it gets a name.

I called it tp.mtbuttons in my intitial diff because that was the
best thing I could come up with.  The libinput docs call it
"clickfinger" behavior [1]. I don't have a strong preference as
long as it has a name.

[1] 
https://wayland.freedesktop.org/libinput/doc/latest/clickpad-softbuttons.html#clickfinger



Re: wsmouse(4): multi-touch buttons again

2023-02-23 Thread joshua stein
On Thu, 23 Feb 2023 at 17:05:53 +0100, Tobias Heider wrote:
> Wow, thank you for looking into this! I've used your version for a few days
> now and it works really well for me (on a m2 macbook air).  I actually think
> the default works so well that we can default to 0 for param 143.
> 
> IMO we can add it to the tree at this point to give others the change to
> test it before the diff gets even bigger.

But please add properly named knobs to wsconsctl for this first, and 
preferably for all of the other hidden settings that were added with 
wstpad.  Expecting users to enable, let alone find, 
"mouse.tp.param=72:1" is ridiculous.

On one of my laptops I wanted to disable the middle soft button and 
had to dig through the code to figure out that I had to use 
"wsconsctl mouse.tp.param=65:0".



Re: wsmouse(4): multi-touch buttons again

2023-02-23 Thread Tobias Heider
On Tue, Feb 21, 2023 at 08:10:36PM +0100, Ulf Brosziewski wrote:
> This diff is an extension of Tobias Heider's proposal, which aims at
> providing "Apple-like" button inputs on clickpads.  I have added some
> things in order to approximate the behaviour of other input drivers.
> 
> It's a quick shot, and I have no idea whether it is sufficient in
> practice, it certainly needs thorough testing.
> 
> The wsconsctl part doesn't provide a named field yet.  With a
> recompiled wsconsctl and kernel, the command
> 
> # wsconsctl mouse.param=72:1
> 
> activates the feature, if it is available (see below).
> 
> The patch contains a simple filter for distinguishing the two-finger
> inputs that should trigger right-button events from the ones that
> shouldn't:  If the distance between two contacts is small, the driver
> generates a right-button event; if it is greater than some threshold
> value, the second contact will be ignored.
> 
> When a touch is resting in the bottom area, it will be ignored, and no
> further filtering applies to the other touches.
> 
> You can inspect the threshold value with
> 
> # wsconsctl mouse.param=143
> 
> and change it with
> 
> # wsconsctl mouse.param=143:
> 
> The value is given in device units.  If the driver for your touchpad is
> imt(4), the default should correspond, roughly, to a distance of 35mm.
> The threshold is reduced by one third if a two-finger click involves a
> touch in the bottom area.  (On medium-sized touchpads, this may be
> necessary to leave enough room for left-button clicks performed by the
> thumb while the pointer-controlling touch remains on the touchpad.)
> 
> The feature won't work decently on small touchpads, and it cannot work
> on touchpads without MT-support in our kernel.  wsmouse checks whether
> a touchpad
> 1) has MT support,
> 2) is a clickpad,
> 3) its resolution is reported to wsmouse,
> 4) it reports a horizontal size greater than 100mm, and
> 5) a vertical size greater than 60mm.
> 
> If these conditions aren't met, wsmouse sets the distance limit to -1,
> which blocks the MTBUTTONS feature.  I think only imt(4) touchpads can
> meet these criteria; however, the value can be overridden manually or
> programmatically, and ubcmtp and aplms do this on initialization.
> These drivers don't report resolution values; the distance limit will
> be set to a fourth of the length of the touchpad diagonal.  That's a
> workaround based on a wild guess, and I couldn't test it with Apple
> hardware.  If you want to apply it to an Elantech-v4 touchpad run by
> pms(4), try
> 
> # wsconsctl mouse.param=143:0,72:1
> 
> (A change from -1 to 0 will trigger the workaround.)

Wow, thank you for looking into this! I've used your version for a few days
now and it works really well for me (on a m2 macbook air).  I actually think
the default works so well that we can default to 0 for param 143.

IMO we can add it to the tree at this point to give others the change to
test it before the diff gets even bigger.

> 
> 
> diff --git a/sbin/wsconsctl/mousecfg.c b/sbin/wsconsctl/mousecfg.c
> index 76a9984bd86..d6609218372 100644
> --- a/sbin/wsconsctl/mousecfg.c
> +++ b/sbin/wsconsctl/mousecfg.c
> @@ -40,9 +40,9 @@
>  #define TP_FILTER_FIRST  WSMOUSECFG_DX_MAX
>  #define TP_FILTER_LAST   WSMOUSECFG_SMOOTHING
>  #define TP_FEATURES_FIRSTWSMOUSECFG_SOFTBUTTONS
> -#define TP_FEATURES_LAST WSMOUSECFG_DISABLE
> +#define TP_FEATURES_LAST WSMOUSECFG_MTBUTTONS
>  #define TP_SETUP_FIRST   WSMOUSECFG_LEFT_EDGE
> -#define TP_SETUP_LASTWSMOUSECFG_TAP_THREE_BTNMAP
> +#define TP_SETUP_LASTWSMOUSECFG_MTBTN_MAXDIST
>  #define LOG_FIRSTWSMOUSECFG_LOG_INPUT
>  #define LOG_LAST WSMOUSECFG_LOG_EVENTS
> 
> diff --git a/sys/arch/arm64/dev/aplhidev.c b/sys/arch/arm64/dev/aplhidev.c
> index 265c5196168..b3bf4838fe8 100644
> --- a/sys/arch/arm64/dev/aplhidev.c
> +++ b/sys/arch/arm64/dev/aplhidev.c
> @@ -680,6 +680,10 @@ struct ubcmtp_finger {
>  /* Use a constant, synaptics-compatible pressure value for now. */
>  #define DEFAULT_PRESSURE 40
> 
> +static struct wsmouse_param aplms_wsmousecfg[] = {
> + { WSMOUSECFG_MTBTN_MAXDIST, 0 }, /* 0: Compute a default value. */
> +};
> +
>  struct aplms_softc {
>   struct device   sc_dev;
>   struct device   *sc_wsmousedev;
> @@ -759,7 +763,8 @@ aplms_configure(struct aplms_softc *sc)
>   hw->mt_slots = UBCMTP_MAX_FINGERS;
>   hw->flags = WSMOUSEHW_MT_TRACKING;
> 
> - return wsmouse_configure(sc->sc_wsmousedev, NULL, 0);
> + return wsmouse_configure(sc->sc_wsmousedev,
> + aplms_wsmousecfg, nitems(aplms_wsmousecfg));
>  }
> 
>  void
> diff --git a/sys/dev/hid/hidmt.c b/sys/dev/hid/hidmt.c
> index 62b500a4f44..9e01fe597bf 100644
> --- a/sys/dev/hid/hidmt.c
> +++ b/sys/dev/hid/hidmt.c
> @@ -103,7 +103,7 @@ hidmt_get_resolution(struct hid_item *h)
>   phy_extent *= 10;
> 

wsmouse(4): multi-touch buttons again

2023-02-21 Thread Ulf Brosziewski
This diff is an extension of Tobias Heider's proposal, which aims at
providing "Apple-like" button inputs on clickpads.  I have added some
things in order to approximate the behaviour of other input drivers.

It's a quick shot, and I have no idea whether it is sufficient in
practice, it certainly needs thorough testing.

The wsconsctl part doesn't provide a named field yet.  With a
recompiled wsconsctl and kernel, the command

# wsconsctl mouse.param=72:1

activates the feature, if it is available (see below).

The patch contains a simple filter for distinguishing the two-finger
inputs that should trigger right-button events from the ones that
shouldn't:  If the distance between two contacts is small, the driver
generates a right-button event; if it is greater than some threshold
value, the second contact will be ignored.

When a touch is resting in the bottom area, it will be ignored, and no
further filtering applies to the other touches.

You can inspect the threshold value with

# wsconsctl mouse.param=143

and change it with

# wsconsctl mouse.param=143:

The value is given in device units.  If the driver for your touchpad is
imt(4), the default should correspond, roughly, to a distance of 35mm.
The threshold is reduced by one third if a two-finger click involves a
touch in the bottom area.  (On medium-sized touchpads, this may be
necessary to leave enough room for left-button clicks performed by the
thumb while the pointer-controlling touch remains on the touchpad.)

The feature won't work decently on small touchpads, and it cannot work
on touchpads without MT-support in our kernel.  wsmouse checks whether
a touchpad
1) has MT support,
2) is a clickpad,
3) its resolution is reported to wsmouse,
4) it reports a horizontal size greater than 100mm, and
5) a vertical size greater than 60mm.

If these conditions aren't met, wsmouse sets the distance limit to -1,
which blocks the MTBUTTONS feature.  I think only imt(4) touchpads can
meet these criteria; however, the value can be overridden manually or
programmatically, and ubcmtp and aplms do this on initialization.
These drivers don't report resolution values; the distance limit will
be set to a fourth of the length of the touchpad diagonal.  That's a
workaround based on a wild guess, and I couldn't test it with Apple
hardware.  If you want to apply it to an Elantech-v4 touchpad run by
pms(4), try

# wsconsctl mouse.param=143:0,72:1

(A change from -1 to 0 will trigger the workaround.)


diff --git a/sbin/wsconsctl/mousecfg.c b/sbin/wsconsctl/mousecfg.c
index 76a9984bd86..d6609218372 100644
--- a/sbin/wsconsctl/mousecfg.c
+++ b/sbin/wsconsctl/mousecfg.c
@@ -40,9 +40,9 @@
 #define TP_FILTER_FIRSTWSMOUSECFG_DX_MAX
 #define TP_FILTER_LAST WSMOUSECFG_SMOOTHING
 #define TP_FEATURES_FIRST  WSMOUSECFG_SOFTBUTTONS
-#define TP_FEATURES_LAST   WSMOUSECFG_DISABLE
+#define TP_FEATURES_LAST   WSMOUSECFG_MTBUTTONS
 #define TP_SETUP_FIRST WSMOUSECFG_LEFT_EDGE
-#define TP_SETUP_LAST  WSMOUSECFG_TAP_THREE_BTNMAP
+#define TP_SETUP_LAST  WSMOUSECFG_MTBTN_MAXDIST
 #define LOG_FIRST  WSMOUSECFG_LOG_INPUT
 #define LOG_LAST   WSMOUSECFG_LOG_EVENTS

diff --git a/sys/arch/arm64/dev/aplhidev.c b/sys/arch/arm64/dev/aplhidev.c
index 265c5196168..b3bf4838fe8 100644
--- a/sys/arch/arm64/dev/aplhidev.c
+++ b/sys/arch/arm64/dev/aplhidev.c
@@ -680,6 +680,10 @@ struct ubcmtp_finger {
 /* Use a constant, synaptics-compatible pressure value for now. */
 #define DEFAULT_PRESSURE   40

+static struct wsmouse_param aplms_wsmousecfg[] = {
+   { WSMOUSECFG_MTBTN_MAXDIST, 0 }, /* 0: Compute a default value. */
+};
+
 struct aplms_softc {
struct device   sc_dev;
struct device   *sc_wsmousedev;
@@ -759,7 +763,8 @@ aplms_configure(struct aplms_softc *sc)
hw->mt_slots = UBCMTP_MAX_FINGERS;
hw->flags = WSMOUSEHW_MT_TRACKING;

-   return wsmouse_configure(sc->sc_wsmousedev, NULL, 0);
+   return wsmouse_configure(sc->sc_wsmousedev,
+   aplms_wsmousecfg, nitems(aplms_wsmousecfg));
 }

 void
diff --git a/sys/dev/hid/hidmt.c b/sys/dev/hid/hidmt.c
index 62b500a4f44..9e01fe597bf 100644
--- a/sys/dev/hid/hidmt.c
+++ b/sys/dev/hid/hidmt.c
@@ -103,7 +103,7 @@ hidmt_get_resolution(struct hid_item *h)
phy_extent *= 10;
}

-   return (log_extent / phy_extent);
+   return ((log_extent + phy_extent / 2) / phy_extent);
 }

 int
diff --git a/sys/dev/usb/ubcmtp.c b/sys/dev/usb/ubcmtp.c
index d86883bd6c2..b5acdadef46 100644
--- a/sys/dev/usb/ubcmtp.c
+++ b/sys/dev/usb/ubcmtp.c
@@ -309,6 +309,10 @@ static const struct ubcmtp_dev ubcmtp_devices[] = {
},
 };

+static struct wsmouse_param ubcmtp_wsmousecfg[] = {
+   { WSMOUSECFG_MTBTN_MAXDIST, 0 }, /* 0: Compute a default value. */
+};
+
 struct ubcmtp_softc {
struct device   sc_dev; /* base device */

@@ -529,7 +533,8 @@