From owner-freebsd-hardware@FreeBSD.ORG Mon Apr 28 10:00:17 2003 Return-Path: Delivered-To: freebsd-hardware@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0151B37B404 for ; Mon, 28 Apr 2003 10:00:17 -0700 (PDT) Received: from dominik.saargate.de (dominik.saargate.de [212.88.133.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 18BBF43FAF for ; Mon, 28 Apr 2003 10:00:15 -0700 (PDT) (envelope-from domi@saargate.de) Received: from localhost (localhost [127.0.0.1]) by dominik.saargate.de (8.12.9/8.12.9) with ESMTP id h3SH0CT7000437 for ; Mon, 28 Apr 2003 19:00:12 +0200 (CEST) (envelope-from domi@saargate.de) Date: Mon, 28 Apr 2003 19:00:12 +0200 (CEST) From: Dominik Brettnacher To: freebsd-hardware@freebsd.org Message-ID: <20030428184356.D372@dominik.saargate.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Nearly solved: Typhoon mouse X-BeenThere: freebsd-hardware@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: General discussion of FreeBSD hardware List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Apr 2003 17:00:17 -0000 Hi, Maybe you remember my mails from the last two weeks on the same topic - I finally got the Typhoon Optical Mouse working with the psm(4) driver, see the patches below. The problem that is left now is the probe function: without my patch, this mouse is recognized as a "4D+ Mouse", which is not compatible with the Typhoon mouse, but returns same device ID. I wrote a probe function, enable_typhoon(), which does pretty much the same thing that enable_4dplus() does. Obviously, with this procedure, using 4D+ mice will not work (I did not try because I don't have one, but I think so). My question now is: does anybody know a method to distinguish these two devices? --- /sys/i386/include/mouse.h.orig Mon Apr 28 14:49:20 2003 +++ /sys/i386/include/mouse.h Mon Apr 28 14:52:58 2003 @@ -119,6 +119,7 @@ #define MOUSE_MODEL_EXPLORER 10 #define MOUSE_MODEL_4D 11 #define MOUSE_MODEL_4DPLUS 12 +#define MOUSE_MODEL_TYPHOON 13 typedef struct mousemode { int protocol; /* MOUSE_PROTO_XXX */ @@ -301,6 +302,9 @@ #define MOUSE_4DPLUS_PACKETSIZE 3 #define MOUSE_4DPLUS_ZNEG 0x04 /* sign bit */ #define MOUSE_4DPLUS_BUTTON4DOWN 0x08 + +/* Typhoon Optical Mouse (PS/2) data packet */ +#define MOUSE_TYPHOON_PACKETSIZE 6 /* sysmouse extended data packet */ /* --- /sys/isa/psm.c.orig Mon Apr 28 14:48:16 2003 +++ /sys/isa/psm.c Mon Apr 28 18:43:01 2003 @@ -275,6 +275,7 @@ static probefunc_t enable_msexplorer; static probefunc_t enable_msintelli; static probefunc_t enable_4dmouse; +static probefunc_t enable_typhoon; static probefunc_t enable_4dplus; static probefunc_t enable_mmanplus; static probefunc_t enable_versapad; @@ -298,6 +299,8 @@ 0x08, MOUSE_PS2_PACKETSIZE, enable_mmanplus, }, { MOUSE_MODEL_EXPLORER, /* Microsoft IntelliMouse Explorer */ 0x08, MOUSE_PS2INTELLI_PACKETSIZE, enable_msexplorer, }, + { MOUSE_MODEL_TYPHOON, /* Typhoon Optical Mouse */ + 0x08, MOUSE_TYPHOON_PACKETSIZE, enable_typhoon, }, { MOUSE_MODEL_4D, /* A4 Tech 4D Mouse */ 0x08, MOUSE_4D_PACKETSIZE, enable_4dmouse, }, { MOUSE_MODEL_4DPLUS, /* A4 Tech 4D+ Mouse */ @@ -578,6 +581,7 @@ { MOUSE_MODEL_VERSAPAD, "VersaPad" }, { MOUSE_MODEL_EXPLORER, "IntelliMouse Explorer" }, { MOUSE_MODEL_4D, "4D Mouse" }, + { MOUSE_MODEL_TYPHOON, "Typhoon Optical Mouse" }, { MOUSE_MODEL_4DPLUS, "4D+ Mouse" }, { MOUSE_MODEL_GENERIC, "Generic PS/2 mouse" }, { MOUSE_MODEL_UNKNOWN, NULL }, @@ -2288,6 +2292,28 @@ } break; + case MOUSE_MODEL_TYPHOON: + /* + * the packet size of the Typhoon Optical Mouse is 6 bytes + * + * packet format *seems* to be as follows + * + * byte 1 - byte 3: PS/2 style, see psm(4) + * byte 4 == byte 1 + * byte 5: z axis movement, either 0x01 or 0xff + * byte 6: 0 + */ + switch(sc->ipacket[4]) + { + case 0x01: + z = 1; + break; + case 0xff: + z = -1; + break; + } + break; + case MOUSE_MODEL_4DPLUS: if ((x < 16 - 256) && (y < 16 - 256)) { /* @@ -2741,6 +2767,31 @@ sc->hw.hwid = id; sc->hw.buttons = 3; /* XXX some 4D mice have 4? */ + + return TRUE; +} + +/* Typhoon Optical Mouse */ +static int +enable_typhoon(struct psm_softc *sc) +{ + KBDC kbdc = sc->kbdc; + int id; + + static unsigned char rate[] = { 200, 100, 80, 60, 40, 20 }; + int i; + + for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i) { + if (set_mouse_sampling_rate(kbdc, rate[i]) != rate[i]) + return FALSE; + } + + id = get_aux_id(kbdc); + if (id != PSM_4DPLUS_ID) /* XXX */ + return FALSE; + + sc->hw.hwid = id; + sc->hw.buttons = 3; return TRUE; } -- Yours, Dominik