diff options
author | yokota <yokota@FreeBSD.org> | 1998-11-20 11:19:20 +0000 |
---|---|---|
committer | yokota <yokota@FreeBSD.org> | 1998-11-20 11:19:20 +0000 |
commit | 785bd0be95899a9d27713c569fd11329852496ff (patch) | |
tree | 7afac3b526443da49220e10217aee4dba8b3f0ab /usr.sbin/moused/moused.c | |
parent | de32e43436213d1a3c72b982fe785b220558c330 (diff) | |
download | FreeBSD-src-785bd0be95899a9d27713c569fd11329852496ff.zip FreeBSD-src-785bd0be95899a9d27713c569fd11329852496ff.tar.gz |
- Added a new option: -w N. The option makes the button N as the `wheel
mode' button. Mouse movement will be treated as wheel movement while
this button is held down. Useful for mice with many buttons but
without a wheel.
PR: bin/8001
Submitted by: Hideyuki Suzuki
Diffstat (limited to 'usr.sbin/moused/moused.c')
-rw-r--r-- | usr.sbin/moused/moused.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index c56855a..bc8e16f 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: moused.c,v 1.19 1998/06/14 20:05:27 ahasty Exp $"; + "$Id: moused.c,v 1.21 1998/11/20 11:17:59 yokota Exp $"; #endif /* not lint */ #include <err.h> @@ -340,6 +340,7 @@ static struct rodentparam { int rate; /* report rate */ int resolution; /* MOUSE_RES_XXX or a positive number */ int zmap; /* MOUSE_{X|Y}AXIS or a button number */ + int wmode; /* wheel mode button number */ int mfd; /* mouse file descriptor */ int cfd; /* /dev/consolectl file descriptor */ int mremsfd; /* mouse remote server file descriptor */ @@ -356,6 +357,7 @@ static struct rodentparam { rate : 0, resolution : MOUSE_RES_UNKNOWN, zmap: 0, + wmode: 0, mfd : -1, cfd : -1, mremsfd : -1, @@ -407,7 +409,7 @@ main(int argc, char *argv[]) int c; int i; - while((c = getopt(argc,argv,"3C:DF:I:PRS:cdfhi:l:m:p:r:st:z:")) != -1) + while((c = getopt(argc,argv,"3C:DF:I:PRS:cdfhi:l:m:p:r:st:w:z:")) != -1) switch(c) { case '3': @@ -487,6 +489,15 @@ main(int argc, char *argv[]) rodent.baudrate = 9600; break; + case 'w': + i = atoi(optarg); + if ((i <= 0) || (i > MOUSE_MAXBUTTON)) { + warnx("invalid argument `%s'", optarg); + usage(); + } + rodent.wmode = 1 << (i - 1); + break; + case 'z': if (strcmp(optarg, "x") == 0) rodent.zmap = MOUSE_XAXIS; @@ -794,8 +805,8 @@ static void usage(void) { fprintf(stderr, "%s\n%s\n%s\n", - "usage: moused [-3DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate] [-C threshold]", - " [-m N=M] [-z N] [-t <mousetype>] -p <port>", + "usage: moused [-3DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]", + " [-C threshold] [-m N=M] [-w N] [-z N] [-t <mousetype>] -p <port>", " moused [-d] -i -p <port>"); exit(1); } @@ -1620,6 +1631,12 @@ r_map(mousestatus_t *act1, mousestatus_t *act2) lbuttons = 0; act2->obutton = act2->button; + if (pbuttons & rodent.wmode) { + pbuttons &= ~rodent.wmode; + act1->dz = act1->dy; + act1->dx = 0; + act1->dy = 0; + } act2->dx = act1->dx; act2->dy = act1->dy; act2->dz = act1->dz; |