Module Name: src Committed By: macallan Date: Sat Aug 31 02:14:51 UTC 2019
Modified Files: src/sys/dev/adb: adb_ms.c Log Message: fix Kensington Turbo Mouse support properly - program the buttons sanely ( as left & right mouse buttons, no toggles and no ridiculous debounce delay either ) - apparently the init values were cargo culted from cthulhu knows where - don't fudge buttons anymore, now that they behave sanely - add comments on what I could figure out the init command actually does - leave in code to find checksum values for init commands, at least until I can figure out what exactly the checksum is Todo: deal with models that have more than 2 buttons, figure out what the rest of the init command does To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/adb/adb_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/dev/adb/adb_ms.c diff -u src/sys/dev/adb/adb_ms.c:1.17 src/sys/dev/adb/adb_ms.c:1.18 --- src/sys/dev/adb/adb_ms.c:1.17 Fri Aug 30 19:24:03 2019 +++ src/sys/dev/adb/adb_ms.c Sat Aug 31 02:14:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: adb_ms.c,v 1.17 2019/08/30 19:24:03 macallan Exp $ */ +/* $NetBSD: adb_ms.c,v 1.18 2019/08/31 02:14:51 macallan Exp $ */ /* * Copyright (C) 1998 Colin Wood @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.17 2019/08/30 19:24:03 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adb_ms.c,v 1.18 2019/08/31 02:14:51 macallan Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -326,18 +326,72 @@ adbms_init_turbo(struct adbms_softc *sc) uint8_t addr; /* Found Kensington Turbo Mouse */ + +/* + * byte 1 assigns what which button does + - 0x08 - button 1 - 1, button 2 - nothing + - 0x09 - both buttons - 1 + - 0x0a - butoon 1 - 1, button 2 - toggle 1 + - 0x0b - button 1 - 1, button 2 - nothing + - 0x0c - button 1 - 1, button 2 - 2 + - 0x0e - button 1 - 1, button 2 - 3 + - 0x0f - button 1 - 1, button 2 - toggle 3 + - 0x10 - button 1 toggle 1, button 2 nothing + - 0x11 - button 1 - toggle 1, button 2 - 1 + - 0x12 - both toggle 1 + - 0x14 - button 1 toggle 1, button 2 - 2 + - 0x21 - button 1 - 2, button 2 - 1 + - 0x31 - button 1 - 3, button 2 - 1 + * byte 4 programs a delay for button presses, apparently in 1/100 seconds + * byte 7 is some sort of checksum, writes will only stick if it's valid + no idea how exactly it works yet, can't be too complicated considering + the device's age + */ + +/* + * XXX + * I doubt the first command is actually necessary. Leave in for now since it + * doesn't do any harm either + */ static u_char data1[] = { 0xe7, 0x8c, 0, 0, 0, 0xff, 0xff, 0x94 }; + + /* this seems to be the most reasonable default */ static u_char data2[] = - { 0xa5, 0x14, 0, 0, 0x69, 0xff, 0xff, 0x27 }; + { 0xa5, 0x0e, 0, 0, 1, 0xff, 0xff, 0x55 }; addr = sc->sc_adbdev->current_addr; +#ifdef ADBMS_DEBUG + { + int i; + adbms_send_sync(sc, ADBTALK(addr, 2), 0, NULL); + printf("reg *"); + for (i = 0; i < sc->sc_msg_len; i++) + printf(" %02x", sc->sc_buffer[i]); + printf("\n"); + } +#endif + adbms_send_sync(sc, ADBFLUSH(addr), 0, NULL); adbms_send_sync(sc, ADBLISTEN(addr, 2), 8, data1); adbms_send_sync(sc, ADBFLUSH(addr), 0, NULL); adbms_send_sync(sc, ADBLISTEN(addr, 2), 8, data2); +#ifdef ADBMS_BRUTEFORCE + sc->sc_buffer[1] = 0; + int y = 0; + while ((sc->sc_buffer[1] != data2[1]) && (y < 0x100)) { + data2[7] = y; + y++; + adbms_send_sync(sc, ADBFLUSH(addr), 0, NULL); + adbms_send_sync(sc, ADBLISTEN(addr, 2), 8, data2); + adbms_send_sync(sc, ADBFLUSH(addr), 0, NULL); + adbms_send_sync(sc, ADBTALK(addr, 2), 0, NULL); + } + printf("y %02x\n", data2[7]); +#endif + #ifdef ADBMS_DEBUG int i, reg; for (reg = 1; reg < 4; reg++) { @@ -607,9 +661,6 @@ adbms_process_event(struct adbms_softc * #ifdef ADBMS_DEBUG printf("%d %d %08x %d\n", dx, dy, smask, shift); #endif - if (sc->sc_adbdev->handler_id == ADBMS_TURBO) { - buttons = (buttons != 0) ? 1 : 0; - } } if (sc->sc_class == MSCLASS_TRACKPAD) {