From owner-FreeBSD-users-jp@jp.freebsd.org  Sat Mar 27 21:39:18 1999
Received: (from daemon@localhost)
	by jaz.jp.freebsd.org (8.9.2+3.1W/8.7.3) id VAA27283;
	Sat, 27 Mar 1999 21:39:18 +0900 (JST)
	(envelope-from owner-FreeBSD-users-jp@jp.FreeBSD.org)
Received: from onion.ish.org (onion.ish.org [210.145.219.202])
	by jaz.jp.freebsd.org (8.9.2+3.1W/8.7.3) with ESMTP id VAA27278
	for <FreeBSD-users-jp@jp.freebsd.org>; Sat, 27 Mar 1999 21:39:16 +0900 (JST)
	(envelope-from ishizuka@ish.org)
Received: from localhost (localhost [127.0.0.1])
	by onion.ish.org (8.9.3/3.7Wpl1-08/27/98) with ESMTP id VAA18780
	for <FreeBSD-users-jp@jp.freebsd.org>; Sat, 27 Mar 1999 21:39:15 +0900 (JST)
To: FreeBSD-users-jp@jp.freebsd.org
X-Mailer: Mew version 1.94b11 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
X-PGP-Fingerprint20: 276D 697A C2CB 1580 C683  8F18 DA98 1A4A 50D2 C4CB
X-PGP-Fingerprint16: C6 DE 46 24 D7 9F 22 EB  79 E2 90 AB 1B 9A 35 2E
X-PGP-Public-Key: http://www.ish.org/pgp-public-key.txt
X-URL: http://www.ish.org/
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
	boundary="--Next_Part(Sat_Mar_27_21:39:11_1999_518)--"
Content-Transfer-Encoding: 7bit
Message-Id: <19990327213915O.ishizuka@onion.ish.org>
Date: Sat, 27 Mar 1999 21:39:15 +0900
From: Masachika ISHIZUKA <ishizuka@ish.org>
X-Dispatcher: imput version 990227(IM108)
Lines: 205
Reply-To: FreeBSD-users-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+981115
X-Sequence: FreeBSD-users-jp 40236
Subject: [FreeBSD-users-jp 40236] psm.c patch for VAIO 505 series
Errors-To: owner-FreeBSD-users-jp@jp.freebsd.org
Sender: owner-FreeBSD-users-jp@jp.freebsd.org
X-Originator: ishizuka@ish.org

----Next_Part(Sat_Mar_27_21:39:11_1999_518)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

  $B@PDM!w?yJB$G$9!#(B

  SONY VAIO 505 $B%7%j!<%:$G;H$o$l$F$$$k%?%C%A%Q%C%I$G$9$,!"(B
tapping $B$,;_$a$i$l$J$/$FHs>o$KITJX$JA[$$$r$7$F$*$j$^$7$?(B
$B$,!"(Bvaio ML $B$G$3$N%?%C%A%Q%C%I$N%3%^%s%I;EMM$r65$($F$b$i(B
$B$C$?$N$G!"(Bpsm.c $B$X$N%Q%C%A$r:n$C$F$_$^$7$?!#(B
  3.1R $BMQ$N%Q%C%A$G$9$,!"(Bcvsup $B$GF~<j$7$?(B 4.0 $B$N(B psm.c $B$b(B
$BF1$8$G$7$?$N$G!"(B4.0-current $B$G$b;HMQ$G$-$k$+$b$7$l$^$;$s!#(B
  $B$3$N%Q%C%A$rEv$F$F(B kernel $B$r:n$jD>$9$H!"5/F0;~$K(B

psm0: model VersaPad, device ID 0

$B$HG'<1$5$l$kH&$G$9!#(Btaping $B$r9T$&$H(B button4 $B$r2!$7$?$h$&$K(B
$B8+$($^$9$N$G!"(Bmoused $B$r;H$C$F(B tapping $B$rM-8z$K$9$k$K$O(B

# moused -p /dev/psm0 -3 -m 1=4
                         ~~~~~~
$B$K$h$&$K;XDj$7$F2<$5$$!#;d$O$b$A$m$s(B tapping $B$O;_$a$F$$$^(B
$B$9!#(B(-m hoge $B$r;XDj$7$J$1$l$P(B button4 $B$OL5;k$5$l$k$N$G(B tapping
$B$OF0:n$7$^$;$s!#!K(B

  $B;d$O(B VAIO 505-RX + FreeBSD 3.1R + PAO3 $B$N4D6-$GF0$+$7$F(B
$B$$$^$9!#(B

----Next_Part(Sat_Mar_27_21:39:11_1999_518)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="versapad.diff"

--- sys/i386/isa/psm.c.orig	Tue Jan 12 09:36:33 1999
+++ sys/i386/isa/psm.c	Sat Mar 27 21:09:12 1999
@@ -264,6 +264,7 @@
 static probefunc_t enable_kmouse;
 static probefunc_t enable_msintelli;
 static probefunc_t enable_mmanplus;
+static probefunc_t enable_versapad;
 static int tame_mouse __P((struct psm_softc *, mousestatus_t *, unsigned char *));
 
 static struct {
@@ -284,6 +285,8 @@
       0x80, MOUSE_PS2_PACKETSIZE, enable_kmouse, },
     { MOUSE_MODEL_INTELLI,		/* Microsoft IntelliMouse */
       0xc8, MOUSE_INTELLI_PACKETSIZE, enable_msintelli, },
+    { MOUSE_MODEL_VERSAPAD,            /* VersaPad */
+      0xc8, MOUSE_PS2_PACKETSIZE, enable_versapad, },
     { MOUSE_MODEL_GENERIC,
       0xc0, MOUSE_PS2_PACKETSIZE, NULL, },
 };
@@ -517,6 +520,7 @@
         { MOUSE_MODEL_THINK,		"ThinkingMouse" },
         { MOUSE_MODEL_INTELLI,		"IntelliMouse" },
         { MOUSE_MODEL_MOUSEMANPLUS,	"MouseMan+" },
+        { MOUSE_MODEL_VERSAPAD,	"VersaPad" },
         { MOUSE_MODEL_GENERIC,		"Generic PS/2 mouse" },
         { MOUSE_MODEL_UNKNOWN,		NULL },
     };
@@ -1726,11 +1730,23 @@
 	MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN,
         MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN
     };
+    static int butmap_versapad[8] = {
+	0, 
+	MOUSE_BUTTON3DOWN, 
+	MOUSE_BUTTON4DOWN, 
+	MOUSE_BUTTON3DOWN | MOUSE_BUTTON4DOWN, 
+	MOUSE_BUTTON1DOWN, 
+	MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN, 
+	MOUSE_BUTTON1DOWN | MOUSE_BUTTON4DOWN,
+	MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN | MOUSE_BUTTON4DOWN
+    };
     register struct psm_softc *sc = psm_softc[unit];
     mousestatus_t ms;
     int x, y, z;
     int c;
     int l;
+    static int x0, y0, x00, y00;
+    static int touch = FALSE;
 
     /* read until there is nothing to read */
     while((c = read_aux_data_no_wait(sc->kbdc)) != -1) {
@@ -1763,15 +1779,6 @@
 
 	c = sc->ipacket[0];
 
-        /* 
-	 * A kludge for Kensington device! 
-	 * The MSB of the horizontal count appears to be stored in 
-	 * a strange place. This kludge doesn't affect other mice 
-	 * because the bit is the overflow bit which is, in most cases, 
-	 * expected to be zero when we reach here. XXX 
-	 */
-        sc->ipacket[1] |= (c & MOUSE_PS2_XOVERFLOW) ? 0x80 : 0;
-
         /* ignore the overflow bits... */
         x = (c & MOUSE_PS2_XNEG) ?  sc->ipacket[1] - 256 : sc->ipacket[1];
         y = (c & MOUSE_PS2_YNEG) ?  sc->ipacket[2] - 256 : sc->ipacket[2];
@@ -1818,10 +1825,60 @@
 	    break;
 
 	case MOUSE_MODEL_THINK:
+	    /* 
+	     * A kludge for Kensington device! 
+	     * The MSB of the horizontal count appears to be stored in 
+	     * a strange place. This kludge doesn't affect other mice 
+	     * because the bit is the overflow bit which is, in most cases, 
+	     * expected to be zero when we reach here. XXX 
+	     */
+	    sc->ipacket[1] |= (c & MOUSE_PS2_XOVERFLOW) ? 0x80 : 0;
+
 	    /* the fourth button state in the first byte */
 	    ms.button |= (c & MOUSE_PS2_TAP) ? MOUSE_BUTTON4DOWN : 0;
 	    break;
 
+	case MOUSE_MODEL_VERSAPAD:
+	    ms.button = butmap_versapad[c & MOUSE_PS2_BUTTONS];
+	    x = y = 0;
+	    switch (c & 0x30) {
+		case 0x10:
+		    x0 = sc->ipacket[1];
+		    y0 = sc->ipacket[2];
+		    break;
+
+		case 0x30:
+		    x0 |= ((sc->ipacket[1]) & 0xf) << 8;
+		    y0 |= ((sc->ipacket[1]) & 0xf0) << 4;
+		    if (x0 & 0x800)
+			x0 |= 0xfffff000;
+		    if (y0 & 0x800)
+			y0 |= 0xfffff000;
+		    if (touch) {
+			x = x00 - x0;
+			y = y0 - y00;
+			if (x * x + y * y < 25) {
+			    x /= 2;
+			    y /= 2;
+			}
+			else if (x * x + y * y > 100) {
+			    x <<= 1;
+			    y <<= 1;
+			}
+		    }
+		    else
+			touch = TRUE;
+		    x00 = x0;
+		    y00 = y0;
+		    break;
+
+		default:
+		    touch = FALSE;
+		    break;
+	    }
+	    c = 0;
+	    break;
+
 	case MOUSE_MODEL_GENERIC:
 	default:
 	    break;
@@ -2145,6 +2202,31 @@
 
     sc->hw.hwid = id;
     sc->hw.buttons = 3;
+
+    return TRUE;
+}
+
+/* VersaPad */
+static int
+enable_versapad(struct psm_softc *sc)
+{
+    KBDC kbdc = sc->kbdc;
+    int data[3];
+
+    reset_aux_dev(kbdc);
+    if (get_mouse_status(kbdc, data, 0, 3) < 3)
+	return FALSE;
+    if (data[2] != 0x64 || data[1] != 2 )
+	return FALSE;
+    set_mouse_scaling(kbdc, 1);
+    set_mouse_scaling(kbdc, 1);
+    set_mouse_scaling(kbdc, 1);
+    set_mouse_scaling(kbdc, 1);
+    if (get_mouse_status(kbdc, data, 0, 3) < 3)
+	return FALSE;
+    if (data[2] != 0xa || data[1] != 0 )
+	return FALSE;
+    set_mouse_scaling(kbdc, 1);
 
     return TRUE;
 }
--- sys/i386/include/mouse.h.orig	Mon Feb 22 01:08:43 1999
+++ sys/i386/include/mouse.h	Sat Mar 27 21:13:31 1999
@@ -115,6 +115,7 @@
 #define MOUSE_MODEL_EASYSCROLL		6
 #define MOUSE_MODEL_MOUSEMANPLUS	7
 #define MOUSE_MODEL_KIDSPAD		8
+#define MOUSE_MODEL_VERSAPAD		9
 
 typedef struct mousemode {
 	int protocol;		/* MOUSE_PROTO_XXX */

----Next_Part(Sat_Mar_27_21:39:11_1999_518)----
