wsconsctl treats it as an error if a wsmouse device reports a touchpad
type in the WSMOUSEIO_GTYPE call but doesn't provide touchpad configuration
data.  With revision 1.3 of ims.c, committed in January, ims devices show
this behaviour.

This patch splits the GETPARAMS call into two parts.  If reading general
parameters is successful but reading touchpad parameters is not, wsconsctl
will silently clear the touchpad flag and continue without an error message.

OK?

Index: sbin/wsconsctl/mousecfg.c
===================================================================
RCS file: /cvs/src/sbin/wsconsctl/mousecfg.c,v
retrieving revision 1.7
diff -u -p -r1.7 mousecfg.c
--- mousecfg.c  2 Apr 2020 17:17:04 -0000       1.7
+++ mousecfg.c  2 Mar 2021 00:14:40 -0000
@@ -162,10 +162,16 @@ mousecfg_init(int dev_fd, const char **e
                }

        parameters.params = cfg_buffer;
-       parameters.nparams = (cfg_touchpad ? BUFSIZE : BASESIZE);
+       parameters.nparams = BASESIZE;
        if ((err = ioctl(dev_fd, WSMOUSEIO_GETPARAMS, &parameters))) {
                *errstr = "WSMOUSEIO_GETPARAMS";
                return (err);
+       }
+       if (cfg_touchpad) {
+               parameters.params = cfg_buffer + BASESIZE;
+               parameters.nparams = BUFSIZE - BASESIZE;
+               if (ioctl(dev_fd, WSMOUSEIO_GETPARAMS, &parameters))
+                       cfg_touchpad = 0;
        }

        return (0);

Reply via email to