- 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
This commit is contained in:
yokota 1998-11-20 11:19:20 +00:00
parent a9a815f9f2
commit 09ad04dc89
2 changed files with 32 additions and 5 deletions

View File

@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $Id: moused.8,v 1.15 1998/06/14 20:05:26 ahasty Exp $
.\" $Id: moused.8,v 1.16 1998/09/17 09:51:15 dwhite Exp $
.\"
.Dd December 3, 1997
.Dt MOUSED 8
@ -45,6 +45,7 @@
.Op Fl S Ar baudrate
.Op Fl C Ar threshold
.Op Fl m Ar N=M
.Op Fl w Ar N
.Op Fl z Ar target
.Op Fl t Ar mousetype
.Fl p Ar port
@ -275,6 +276,15 @@ For the PS/2 mouse:
This is the only protocol type available for the PS/2 mouse
and should be specified for any PS/2 mice, regardless of the brand.
.El
.It Fl w Ar N
Make the physical button
.Ar N
act as the wheel mode button.
While this button is pressed, X and Y axis movement is reported to be zero
and the Y axis movement is mapped to Z axis.
You may further map the Z axis movement to virtual buttons by the
.Fl z
option below.
.It Fl z Ar target
Map Z axis (roller/wheel) movement to another axis or to virtual buttons.
Valid

View File

@ -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;