From nobody Mon Sep 22 09:23:29 2025 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cVd2T4w4wz68rTj; Mon, 22 Sep 2025 09:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cVd2T41pMz40Nt; Mon, 22 Sep 2025 09:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758533009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SY2QZPzztqqLH1JKTHrEX0k7kRE1zwXEJA3tdIO6Vh8=; b=ifHusSxMiGOZizZX8X1DLnaqUxu3xPRRhoptCAYKehgDwHOW/6qn/DzF0wmUpfdpmqA3QN Ulgl4EezaW7XS6qLy6PgSMGRxz+YaFL7oY3WyepVfTm5El2HerA+cw6D7xOnOhvypURWFl UprI/ffsjCbbIBtyFlkZzm7/pj3VhG00hJ2KYQIQWPdyiVWhM9jP+nRw74rTKiWvnMN6wp 8Bz5AdAQfcSV1BxnWNWBxD8UtpqakKlsgg88HH6u2kWwhlgaaQyxRj5m9nTSIvRGU4NciY m2QhuoYi0Dq1tZgcFFv0XQANVyYgPMmcw6mcyRku1A7s4pWN/FKeXOD6IQXBJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758533009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SY2QZPzztqqLH1JKTHrEX0k7kRE1zwXEJA3tdIO6Vh8=; b=hC+gL+s7ZPSoFGvPLgCkq77KDCLeGzZd0oyFwP+5bHy59Az2Zq1fmU5BmoaIvqUtwZgZtM hW+yg/3qRQnEAkIF/RXT3QuSqs5Es754DCDSkoP3s8N0aAx10QGw4uuYhMna7NI0JivFlt 3gY55Gav9oe1GhOEDn50Zv9nba2qVpONMlZovYFuc3/pABEbv9Ir7VyzQQ30He00FP7dEV Z0PJJv847Gow+u9cq9qc66BTPTidMeurjUamEsXMwM3SyON3E5zhPOkKsHMcAh9TRhnbcy ULkSAruDzd9O5GdFNNFAq73sPJqFla36Rc6ONDvsmlnQ9Bww4BUCWRUik5gAjA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758533009; a=rsa-sha256; cv=none; b=FisCR0mLsRXCRR6uyT5Nvwf25rrpWviqYYyWUCQGkJBbcJSJslkldGKXuNtl7v1vYdGsdl UiOjtfC95NEDlrR9zfSXFzDUtn/XyFzYs0QHTuMr+n0IsL6fNXJmqaMXBtJTWP6+JuKRa1 DduZHl5onoUa3NJ5NhbVWi6lJ87vumjU+k++81r81b4mF5b5evYgxTBEXEbwmhmmX7JX1f dGE2FKWrOeqLf8xvR0O8vkf3gOjcsoEyI5kTY5q+qaGKeBQtDm/XawDBKw0OSdN2FjcOLd RFL7uRpsY8faYYF+lQ7w4Bda7zQsjZxtaevtX9vaehVJD3+KfQ6RihYd2/WaRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cVd2T3bNPztjt; Mon, 22 Sep 2025 09:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58M9NTCB099955; Mon, 22 Sep 2025 09:23:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58M9NTS7099952; Mon, 22 Sep 2025 09:23:29 GMT (envelope-from git) Date: Mon, 22 Sep 2025 09:23:29 GMT Message-Id: <202509220923.58M9NTS7099952@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: d5f63d6b3738 - stable/15 - moused(8): Add command line option to restrict interface type List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: d5f63d6b373890ce4654f27d89e281d3c4c265cf Auto-Submitted: auto-generated The branch stable/15 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=d5f63d6b373890ce4654f27d89e281d3c4c265cf commit d5f63d6b373890ce4654f27d89e281d3c4c265cf Author: Vladimir Kondratyev AuthorDate: 2025-09-21 13:14:48 +0000 Commit: Vladimir Kondratyev CommitDate: 2025-09-22 09:22:12 +0000 moused(8): Add command line option to restrict interface type to evdev or sysmouse. It is required to avoid receiving of double events on hybrid devices supporting both interfaces like ums (4). MFC after: 1 day Reviewed by: glebius (via private chat) Differential Revision: https://reviews.freebsd.org/D52647 (cherry picked from commit 1335bf5ce1c9f0bf15c1fbed502f49e5a4950e32) --- libexec/rc/rc.conf | 2 +- libexec/rc/rc.d/moused | 7 +++++-- usr.sbin/moused/moused/moused.8 | 31 +++++++++++++++++++++++++++---- usr.sbin/moused/moused/moused.c | 39 +++++++++++++++++++++++++++------------ 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 82b6efa6ca62..2506bd45a53f 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -589,7 +589,7 @@ saver="NO" # screen saver: Uses /boot/kernel/${saver}_saver.ko moused_nondefault_enable="NO" # Treat non-default mice as enabled unless # specifically overridden in rc.conf(5). moused_enable="NO" # Run the mouse daemon. -moused_type="auto" # See man page for rc.conf(5) for available settings. +moused_type="evdev" # See man page for rc.conf(5) for available settings. moused_port="auto" # Set to your mouse port. moused_flags="" # Any additional flags to moused. mousechar_start="NO" # if 0xd0-0xd3 default range is occupied in your diff --git a/libexec/rc/rc.d/moused b/libexec/rc/rc.d/moused index aaf0dd0890a8..64e4f815eea9 100755 --- a/libexec/rc/rc.d/moused +++ b/libexec/rc/rc.d/moused @@ -16,6 +16,7 @@ start_cmd="moused_start" pidprefix="/var/run/moused" pidfile="${pidprefix}.pid" pidarg= +typearg= load_rc_config $name # doesn't make sense to run in a svcj: nojail keyword @@ -49,15 +50,17 @@ moused_start() eval myflags=\${moused_${ms}_flags-$moused_flags} eval myport=\${moused_${ms}_port-/dev/$ms} eval mytype=\${moused_${ms}_type-$moused_type} + if [ -n "$mytype" ] && check_kern_features evdev_support; then + typearg="-t ${mytype}" + fi else ms="default" myflags="$moused_flags" myport="$moused_port" - mytype="$moused_type" fi startmsg -n "Starting ${ms} moused" - /usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg} + /usr/sbin/moused ${myflags} -p ${myport} ${typearg} ${pidarg} startmsg '.' mousechar_arg= diff --git a/usr.sbin/moused/moused/moused.8 b/usr.sbin/moused/moused/moused.8 index 96feeda336c9..2483f8a04b2a 100644 --- a/usr.sbin/moused/moused/moused.8 +++ b/usr.sbin/moused/moused/moused.8 @@ -49,7 +49,7 @@ .Op Fl m Ar N=M .Op Fl w Ar N .Op Fl z Ar target -.Op Fl t Ar mousetype +.Op Fl t Ar interfacetype .Op Fl l Ar level .Op Fl 3 Op Fl E Ar timeout .Op Fl T Ar distance Ns Op , Ns Ar time Ns Op , Ns Ar after @@ -329,9 +329,32 @@ or .Ar high . This option may not be supported by all the device. .It Fl t Ar type -Ignored. -Used for compatibiliy with legacy -.Nm . +Force the interface type of the mouse attached to the port. +You may explicitly specify a type listed below, or use +.Ar auto +to let the +.Nm +utility automatically select an appropriate protocol for the given +character device. +If you entirely omit this option in the command line, +.Fl t Ar auto +is assumed. +.Pp +Valid types for this option are listed below. +.Bl -tag -compact -width systemmouse +.It Ar evdev +Input event device usualy residing in +.Pa /dev/input . +.It Ar sysmouse +Traditional protocol used by e.g. +.Xr ums 4 +and +.Xr psm 4 +drivers. +.El +.Pp +Note that this option restricts usage of the given port rather then gives +a hint. .It Fl q Ar config Path to configuration file. .It Fl Q Ar quirks diff --git a/usr.sbin/moused/moused/moused.c b/usr.sbin/moused/moused/moused.c index 33bcf359a1a0..fa3bfbbf2b3e 100644 --- a/usr.sbin/moused/moused/moused.c +++ b/usr.sbin/moused/moused/moused.c @@ -448,6 +448,7 @@ static const char *config_file = CONFDIR "/moused.conf"; #endif static const char *quirks_path = QUIRKSDIR; static struct quirks_context *quirks; +static enum device_if force_if = DEVICE_IF_UNKNOWN; static int opt_rate = 0; static int opt_resolution = MOUSE_RES_UNKNOWN; @@ -529,7 +530,8 @@ main(int argc, char *argv[]) struct rodent *r; pid_t mpid; int c; - int i; + u_int i; + int n; u_long ul; char *errstr; @@ -552,26 +554,26 @@ main(int argc, char *argv[]) break; case 'a': - i = sscanf(optarg, "%lf,%lf", &opt_accelx, &opt_accely); - if (i == 0) { + n = sscanf(optarg, "%lf,%lf", &opt_accelx, &opt_accely); + if (n == 0) { warnx("invalid linear acceleration argument " "'%s'", optarg); usage(); } - if (i == 1) + if (n == 1) opt_accely = opt_accelx; break; case 'A': opt_exp_accel = true; - i = sscanf(optarg, "%lf,%lf", &opt_expoaccel, + n = sscanf(optarg, "%lf,%lf", &opt_expoaccel, &opt_expoffset); - if (i == 0) { + if (n == 0) { warnx("invalid exponential acceleration " "argument '%s'", optarg); usage(); } - if (i == 1) + if (n == 1) opt_expoffset = 1.0; break; @@ -646,8 +648,19 @@ main(int argc, char *argv[]) break; case 't': - if (strcmp(optarg, "auto") != 0) - warnx("ignore mouse type `%s'", optarg); + if (strcmp(optarg, "auto") == 0) { + force_if = DEVICE_IF_UNKNOWN; + break; + } + for (i = 0; i < nitems(rifs); i++) + if (strcmp(optarg, rifs[i].name) == 0) { + force_if = i; + break; + } + if (i == nitems(rifs)) { + warnx("no such interface type `%s'", optarg); + usage(); + } break; case 'w': @@ -1224,7 +1237,7 @@ usage(void) fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", "usage: moused [-dfg] [-I file] [-F rate] [-r resolution]", " [-VH [-U threshold]] [-a X[,Y]] [-C threshold] [-m N=M] [-w N]", - " [-z N] [-t ] [-l level] [-3 [-E timeout]]", + " [-z N] [-t ] [-l level] [-3 [-E timeout]]", " [-T distance[,time[,after]]] -p [-q config] [-Q quirks]", " moused [-d] -i -p "); exit(1); @@ -1338,9 +1351,11 @@ r_identify_if(int fd) { int dummy; - if (ioctl(fd, EVIOCGVERSION, &dummy) >= 0) + if ((force_if == DEVICE_IF_UNKNOWN || force_if == DEVICE_IF_EVDEV) && + ioctl(fd, EVIOCGVERSION, &dummy) >= 0) return (DEVICE_IF_EVDEV); - if (ioctl(fd, MOUSE_GETLEVEL, &dummy) >= 0) + if ((force_if == DEVICE_IF_UNKNOWN || force_if == DEVICE_IF_SYSMOUSE) && + ioctl(fd, MOUSE_GETLEVEL, &dummy) >= 0) return (DEVICE_IF_SYSMOUSE); return (DEVICE_IF_UNKNOWN); }