From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 29 Sep 2000 12:50:40 -0400 From: Latchesar Ionkov To: 9fans@cse.psu.edu Subject: Re: [9fans] VGA and laptops Message-ID: <20000929125040.A21356@gmx.net> References: <20000926132304.A7D67199CC@mail> <20000928072111.A15227@gmx.net> <000401c029cb$e1162a40$97036887@cs.belllabs.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <000401c029cb$e1162a40$97036887@cs.belllabs.com>; from rob@plan9.bell-labs.com on Fri, Sep 29, 2000 at 12:01:58AM -0400 Topicbox-Message-UUID: 12dfe7b8-eac9-11e9-9e20-41e7f4b1d025 --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Sep 29, 2000 at 12:01:58AM -0400, rob pike said: > I would like to see the code that enables on the buttons on the intellimouse. This is the code that I wrote to make the small buttons of the mouse of Toshiba Portege 3480CT to work as button 2. It is not tested anywhere else. mouse.c.diff is patch for /sys/src/9/pc/mouse.c. Thanks, Lucho --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="mouse.c.diff" 24a25 > static int intellimouse; 60c61 < static short msg[3]; --- > static short msg[4]; 63c64 < int buttons, dx, dy; --- > int buttons, dx, dy, dz; 72c73,76 < if(++nb == 3){ --- > if (++nb >= 3) { > if ((intellimouse) && (nb < 4)) > return; > 79a84,91 > > if (intellimouse) { > dz = (char) msg[3]; > > if (dz) > buttons |= 2; > } > 104d115 < static int intellimouse; --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="tms.c" #include #include #include #define TEMP "/n/temp" #define STACKSIZE 4096 struct { QLock; int mfd; int rfd, wfd; QLock prs; int pressed; int b; int x; int y; long t; vlong nsec; } b2; static void tproc(void *); static void wproc(void *); void threadmain(int argc, char *argv[]) { char *file = "/dev/mouse"; int n, b, x, y; long t; char buf[50]; b2.mfd = open("/dev/mouse", ORDWR|OCEXEC); if (b2.mfd < 0) sysfatal("open /dev/mouse: %r"); if (bind("#|", TEMP, MREPL) < 0) sysfatal("bind pipe %s: %r", TEMP); if (bind(TEMP "/data", "/dev/mouse", MREPL) < 0) sysfatal("bind %s /dev/mouse: %r", TEMP "/data"); b2.rfd = open(TEMP "/data1", OREAD); if (b2.rfd < 0) sysfatal("open %s: %r", TEMP "/data1"); b2.wfd = open(TEMP "/data1", OWRITE); if (b2.wfd < 0) sysfatal("open %s: %r", TEMP "/data1"); qlock(&b2.prs); proccreate(wproc, 0, STACKSIZE); proccreate(tproc, 0, STACKSIZE); while (1) { n = read(b2.mfd, buf, 49); x = atoi(buf + 1 + 0*12); y = atoi(buf + 1 + 1*12); b = atoi(buf + 1 + 2*12); t = atoi(buf + 1 + 3*12); qlock(&b2); if (b & 0x02) { if (b2.pressed == 0) { qunlock(&b2.prs); b2.pressed = 1; } b2.t = t; b2.x = x; b2.y = y; b2.b = b; b2.nsec = nsec(); } if (b2.pressed) b |= 0x02; sprint(buf, "m%11d %11d %11d %11lud", x, y, b, t); write(b2.wfd, buf, 49); qunlock(&b2); } } static void wproc(void *) { int n; char buf[50]; while (1) { n = read(b2.rfd, buf, sizeof(buf)); if (n < 0) break; write(b2.mfd, buf, n); } } static void tproc(void *) { vlong t1, t2; char buf[50]; while (1) { qlock(&b2.prs); qlock(&b2); sprint(buf, "m%11d %11d %11d %11lud", b2.x, b2.y, b2.b | 0x02, b2.t); write(b2.wfd, buf, 49); qunlock(&b2); /* delay between first and second event (400ms) */ sleep(400); qlock(&b2); b2.nsec = nsec(); qunlock(&b2); while (1) { /* delay between events (150ms) */ sleep(80); qlock(&b2); t2 = nsec(); if ((t2 - b2.nsec) > 150000000L) { b2.nsec = t2; b2.pressed = 0; sprint(buf, "m%11d %11d %11d %11lud", b2.x, b2.y, b2.b & ~0x02, b2.t); write(b2.wfd, buf, 49); qunlock(&b2); break; } qunlock(&b2); } } } --envbJBWh7q8WU6mo--