From nobody Sun Sep 21 13:16:24 2025 X-Original-To: dev-commits-src-main@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 4cV6Fj2gClz686Pc; Sun, 21 Sep 2025 13:16:25 +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 4cV6Fj212lz3l0H; Sun, 21 Sep 2025 13:16:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758460585; 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=SWDdFQaqXYowrm1062geQhV2Ckjc8usvU3acEeFpsDg=; b=nZWbWAtI1OmxEWMDd3fbDvPQbDQhOkI2DBJ7JRtN8VdFjiGAl28gduF2SweLm65TjBVSqk uin33cVCrr6/3t9+Y3kBneuClnx5fR7uTHK+YZ4epRZDCyrn2/WmSVS6s0qtIglBujqV3j vVjDSAEtST95iB0KXu5g56SpJYBV7PdDP1h38CHOyciaIVyPrqi746v1sJiMOmluXh9WCi jTmIe4a7PVIq3tEsnViQwtu8KKRJ9HzgnIozhF/eVlG5ScQBBDon9L96WpooQjtywr3ZIK 2mRr4nzAOB1S/JGM+cmwiMCMcNYMsetK+/g6nORVafgXzKpH0t0wsg090rmOFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758460585; 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=SWDdFQaqXYowrm1062geQhV2Ckjc8usvU3acEeFpsDg=; b=JDe2NmLGmvDRk1SE3fMSFhpziPF6CaNH/E47NF3hPcDqmseCWxBiR3hrhbIkGtSjHjLT+i qVz81m5r9SGgr7wdAAOIzCUdCbuUys0jw2gHvDmnAoWUNu2UMn3B7J1NnJ0Kdqowyqpydf fEpa7j0IfjjIXPdL3cqd2H/B6bEBpBE92MmIGglPOgXOJsXBzxtoRmMhHSCkwdYfdO4f4s pvZNQg2GcT8zkSNF/eq8FhKm0eN/uS6H1RvxaxfbHdHtImwqvTMZdHexLTBpOvDlJVg7Pr WGphnfm7ZtnnOlvDX+taktEyQ/tic/aN6qkrd1YMgRhA1soMlkDS2FXbpx1x1Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758460585; a=rsa-sha256; cv=none; b=xX+nXv+5llrgmqFIPG/iPfRR/LiDIb5F/ijq2b/B7/VcVNvO/qI4qevlBADuTf00rMsNnu 8X40XwV+F8SCaUHRa6if/FY6AzFfJVe/HzINxV4xqAnJb4hTvCcx0FQSlGc+fIabss+0WI H36D/+s+phPMa4N3yu6pop4LO/9XUOre1x370YEigtynWZgbkZS/h6TZm15wUaMoIeO1IY X/s3Yy3APj/aepFjRof0DJDn5uht/6wDFoz3lwxF7Fx54M653fFAyJHZVM5pn3+Z3jwhFZ sODbgdw3Na0FfNPKGYbufSXrGaJPKQix8tHF62fp/qwZKPzDh89mp9z+CDI8QQ== 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 4cV6Fj16wrz17W; Sun, 21 Sep 2025 13:16:25 +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 58LDGO9L033157; Sun, 21 Sep 2025 13:16:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58LDGOXO033154; Sun, 21 Sep 2025 13:16:24 GMT (envelope-from git) Date: Sun, 21 Sep 2025 13:16:24 GMT Message-Id: <202509211316.58LDGOXO033154@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 1335bf5ce1c9 - main - moused(8): Add command line option to restrict interface type List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 1335bf5ce1c9f0bf15c1fbed502f49e5a4950e32 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=1335bf5ce1c9f0bf15c1fbed502f49e5a4950e32 commit 1335bf5ce1c9f0bf15c1fbed502f49e5a4950e32 Author: Vladimir Kondratyev AuthorDate: 2025-09-21 13:14:48 +0000 Commit: Vladimir Kondratyev CommitDate: 2025-09-21 13:14:48 +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 --- 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 0ef3012892dd..b5482f081ce5 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 acd6e5223685..36cb8cc27eab 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); }