From: Latchesar Ionkov <lucho@gmx.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] VGA and laptops
Date: Fri, 29 Sep 2000 12:50:40 -0400 [thread overview]
Message-ID: <20000929125040.A21356@gmx.net> (raw)
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
[-- Attachment #1: Type: text/plain, Size: 362 bytes --]
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
[-- Attachment #2: mouse.c.diff --]
[-- Type: text/plain, Size: 426 bytes --]
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;
[-- Attachment #3: tms.c --]
[-- Type: text/plain, Size: 2392 bytes --]
#include <u.h>
#include <libc.h>
#include <thread.h>
#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);
}
}
}
next prev parent reply other threads:[~2000-09-29 16:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-26 13:23 jmk
2000-09-26 20:29 ` Christopher Nielsen
2000-09-28 11:21 ` Latchesar Ionkov
2000-09-29 4:01 ` rob pike
2000-09-29 16:50 ` Latchesar Ionkov [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-09-27 0:37 jmk
2000-09-26 20:48 nigel
2000-09-26 18:33 nigel
2000-09-26 18:49 ` Matt
2000-09-26 13:25 jmk
2000-09-26 16:37 ` Latchesar Ionkov
2000-09-26 18:05 ` Matt
2000-09-26 9:13 saroj
2000-09-26 13:29 ` Latchesar Ionkov
2000-09-27 10:52 ` Axel Belinfante
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000929125040.A21356@gmx.net \
--to=lucho@gmx.net \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).