Module Name:    src
Committed By:   tsutsui
Date:           Sun Feb  7 16:13:56 UTC 2021

Modified Files:
        src/sys/arch/x68k/dev: ms.c

Log Message:
Remove dumb middle button emulation code from the ms(4) driver.

Also fix leftover comments (derived from the original Sun's "firm_event"
implementation as seen in sys/dev/sun/ms.c) to sync with reality on x68k.

The current implementation the ms(4) driver just checks whether
two (left/right) buttons are changed in the same packet.
This means it cannot handle a release event correctly if two
buttons pressed simultaneously are released in the different timing.

The middle button emulation should be handled in application layer
as other Xservers do, and I'll import Emulate3Buttons support for the
X68k Xorg based monolithic server.

See my post on port-x68k@ for details:
 https://mail-index.netbsd.org/port-x68k/2021/02/05/msg000074.html


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x68k/dev/ms.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x68k/dev/ms.c
diff -u src/sys/arch/x68k/dev/ms.c:1.34 src/sys/arch/x68k/dev/ms.c:1.35
--- src/sys/arch/x68k/dev/ms.c:1.34	Fri Jul 25 08:10:35 2014
+++ src/sys/arch/x68k/dev/ms.c	Sun Feb  7 16:13:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ms.c,v 1.34 2014/07/25 08:10:35 dholland Exp $ */
+/*	$NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.34 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -356,8 +356,8 @@ ms_input(struct ms_softc *ms, int c)
 {
 	struct firm_event *fe;
 	int mb, ub, d, get, put, any;
-	static const char to_one[] = { 1, 2, 3 };
-	static const int to_id[] = { MS_LEFT, MS_RIGHT, MS_MIDDLE };
+	static const char to_one[] = { 1, 2, 2 };
+	static const int to_id[] = { MS_LEFT, MS_RIGHT };
 
 	/*
 	 * Discard input if not ready.  Drop sync on parity or framing
@@ -402,7 +402,7 @@ ms_input(struct ms_softc *ms, int c)
 
 	/*
 	 * We have at least one event (mouse button, delta-X, or
-	 * delta-Y; possibly all three, and possibly three separate
+	 * delta-Y; possibly all three, and possibly two separate
 	 * button events).  Deliver these events until we are out
 	 * of changes or out of room.  As events get delivered,
 	 * mark them `unchanged'.
@@ -430,12 +430,12 @@ ms_input(struct ms_softc *ms, int c)
 	ub = ms->ms_ub;
 	while ((d = mb ^ ub) != 0) {
 		/*
-		 * Mouse button change.  Convert up to three changes
+		 * Mouse button change.  Convert up to two changes
 		 * to the `first' change, and drop it into the event queue.
 		 */
 		NEXT;
-		d = to_one[d - 1];		/* from 1..7 to {1,2,4} */
-		fe->id = to_id[d - 1];		/* from {1,2,4} to ID */
+		d = to_one[d - 1];		/* from 1..3 to {1,2} */
+		fe->id = to_id[d - 1];		/* from {1,2} to ID */
 		fe->value = mb & d ? VKEY_DOWN : VKEY_UP;
 		firm_gettime(fe);
 		ADVANCE;

Reply via email to