Improve the virtual scrolling mechanism to make middle clicking less
difficult. Add a -L option (yet another option, indeed!) which changes the speed of scrolling and change -U to only affect the scroll threshold. This should make middle-clicking a much more pleasant experience. PR: bin/120186 Submitted by: Aragon Gouveia <aragon -at- phat.za.net> MFC after: 3 days
This commit is contained in:
parent
7e54279b42
commit
3e95467ca0
@ -30,7 +30,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd November 12, 2004
|
.Dd May 15, 2008
|
||||||
.Dt MOUSED 8
|
.Dt MOUSED 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -43,7 +43,7 @@
|
|||||||
.Op Fl F Ar rate
|
.Op Fl F Ar rate
|
||||||
.Op Fl r Ar resolution
|
.Op Fl r Ar resolution
|
||||||
.Op Fl S Ar baudrate
|
.Op Fl S Ar baudrate
|
||||||
.Op Fl VH Op Fl U Ar distance
|
.Op Fl VH Op Fl U Ar distance Fl L Ar distance
|
||||||
.Op Fl A Ar exp Ns Op , Ns Ar offset
|
.Op Fl A Ar exp Ns Op , Ns Ar offset
|
||||||
.Op Fl a Ar X Ns Op , Ns Ar Y
|
.Op Fl a Ar X Ns Op , Ns Ar Y
|
||||||
.Op Fl C Ar threshold
|
.Op Fl C Ar threshold
|
||||||
@ -139,6 +139,18 @@ simultaneously.
|
|||||||
The default timeout is 100 msec.
|
The default timeout is 100 msec.
|
||||||
.It Fl F Ar rate
|
.It Fl F Ar rate
|
||||||
Set the report rate (reports/sec) of the device if supported.
|
Set the report rate (reports/sec) of the device if supported.
|
||||||
|
.It Fl L Ar distance
|
||||||
|
When
|
||||||
|
.Dq Virtual Scrolling
|
||||||
|
is enabled, the
|
||||||
|
.Fl L
|
||||||
|
option can be used to set the
|
||||||
|
.Ar distance
|
||||||
|
(in pixels) that the mouse must move before a scroll event
|
||||||
|
is generated. This effectively controls the scrolling speed.
|
||||||
|
The default
|
||||||
|
.Ar distance
|
||||||
|
is 2 pixels.
|
||||||
.It Fl H
|
.It Fl H
|
||||||
Enable
|
Enable
|
||||||
.Dq Horizontal Virtual Scrolling .
|
.Dq Horizontal Virtual Scrolling .
|
||||||
@ -148,7 +160,9 @@ horizontal scrolling.
|
|||||||
Use the
|
Use the
|
||||||
.Fl U
|
.Fl U
|
||||||
option to set the distance the mouse must move before the scrolling mode is
|
option to set the distance the mouse must move before the scrolling mode is
|
||||||
activated.
|
activated and the
|
||||||
|
.Fl L
|
||||||
|
option to set the scrolling speed.
|
||||||
This option may be used with or without the
|
This option may be used with or without the
|
||||||
.Fl V
|
.Fl V
|
||||||
option.
|
option.
|
||||||
@ -201,7 +215,9 @@ button down will cause motion to be interpreted as scrolling.
|
|||||||
Use the
|
Use the
|
||||||
.Fl U
|
.Fl U
|
||||||
option to set the distance the mouse must move before the scrolling mode is
|
option to set the distance the mouse must move before the scrolling mode is
|
||||||
activated.
|
activated and the
|
||||||
|
.Fl L
|
||||||
|
option to set the scrolling speed.
|
||||||
.It Fl U Ar distance
|
.It Fl U Ar distance
|
||||||
When
|
When
|
||||||
.Dq Virtual Scrolling
|
.Dq Virtual Scrolling
|
||||||
|
@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define DFLT_CLICKTHRESHOLD 500 /* 0.5 second */
|
#define DFLT_CLICKTHRESHOLD 500 /* 0.5 second */
|
||||||
#define DFLT_BUTTON2TIMEOUT 100 /* 0.1 second */
|
#define DFLT_BUTTON2TIMEOUT 100 /* 0.1 second */
|
||||||
#define DFLT_SCROLLTHRESHOLD 3 /* 3 pixels */
|
#define DFLT_SCROLLTHRESHOLD 3 /* 3 pixels */
|
||||||
|
#define DFLT_SCROLLSPEED 2 /* 2 pixels */
|
||||||
|
|
||||||
/* Abort 3-button emulation delay after this many movement events. */
|
/* Abort 3-button emulation delay after this many movement events. */
|
||||||
#define BUTTON2_MAXMOVE 3
|
#define BUTTON2_MAXMOVE 3
|
||||||
@ -418,6 +419,7 @@ static struct rodentparam {
|
|||||||
float remainx; /* Remainder on X and Y axis, respectively... */
|
float remainx; /* Remainder on X and Y axis, respectively... */
|
||||||
float remainy; /* ... to compensate for rounding errors. */
|
float remainy; /* ... to compensate for rounding errors. */
|
||||||
int scrollthreshold; /* Movement distance before virtual scrolling */
|
int scrollthreshold; /* Movement distance before virtual scrolling */
|
||||||
|
int scrollspeed; /* Movement distance to rate of scrolling */
|
||||||
} rodent = {
|
} rodent = {
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.portname = NULL,
|
.portname = NULL,
|
||||||
@ -441,6 +443,7 @@ static struct rodentparam {
|
|||||||
.remainx = 0.0,
|
.remainx = 0.0,
|
||||||
.remainy = 0.0,
|
.remainy = 0.0,
|
||||||
.scrollthreshold = DFLT_SCROLLTHRESHOLD,
|
.scrollthreshold = DFLT_SCROLLTHRESHOLD,
|
||||||
|
.scrollspeed = DFLT_SCROLLSPEED,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* button status */
|
/* button status */
|
||||||
@ -574,7 +577,7 @@ main(int argc, char *argv[])
|
|||||||
for (i = 0; i < MOUSE_MAXBUTTON; ++i)
|
for (i = 0; i < MOUSE_MAXBUTTON; ++i)
|
||||||
mstate[i] = &bstate[i];
|
mstate[i] = &bstate[i];
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "3A:C:DE:F:HI:PRS:T:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
|
while ((c = getopt(argc, argv, "3A:C:DE:F:HI:L:PRS:T:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
|
||||||
case '3':
|
case '3':
|
||||||
@ -760,6 +763,14 @@ main(int argc, char *argv[])
|
|||||||
pidfile = optarg;
|
pidfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
rodent.scrollspeed = atoi(optarg);
|
||||||
|
if (rodent.scrollspeed < 0) {
|
||||||
|
warnx("invalid argument `%s'", optarg);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
rodent.flags |= NoPnP;
|
rodent.flags |= NoPnP;
|
||||||
break;
|
break;
|
||||||
@ -1121,6 +1132,7 @@ moused(void)
|
|||||||
if (action0.button == MOUSE_BUTTON2DOWN) {
|
if (action0.button == MOUSE_BUTTON2DOWN) {
|
||||||
if (scroll_state == SCROLL_NOTSCROLLING) {
|
if (scroll_state == SCROLL_NOTSCROLLING) {
|
||||||
scroll_state = SCROLL_PREPARE;
|
scroll_state = SCROLL_PREPARE;
|
||||||
|
scroll_movement = hscroll_movement = 0;
|
||||||
debug("PREPARING TO SCROLL");
|
debug("PREPARING TO SCROLL");
|
||||||
}
|
}
|
||||||
debug("[BUTTON2] flags:%08x buttons:%08x obuttons:%08x",
|
debug("[BUTTON2] flags:%08x buttons:%08x obuttons:%08x",
|
||||||
@ -1182,21 +1194,36 @@ moused(void)
|
|||||||
* the stick/trackpoint/nipple, scroll!
|
* the stick/trackpoint/nipple, scroll!
|
||||||
*/
|
*/
|
||||||
if (scroll_state == SCROLL_PREPARE) {
|
if (scroll_state == SCROLL_PREPARE) {
|
||||||
/* Ok, Set we're really scrolling now.... */
|
/* Middle button down, waiting for movement threshold */
|
||||||
if (action2.dy || action2.dx)
|
if (action2.dy || action2.dx) {
|
||||||
scroll_state = SCROLL_SCROLLING;
|
if (rodent.flags & VirtualScroll) {
|
||||||
}
|
scroll_movement += action2.dy;
|
||||||
if (scroll_state == SCROLL_SCROLLING) {
|
if (scroll_movement < -rodent.scrollthreshold) {
|
||||||
|
scroll_state = SCROLL_SCROLLING;
|
||||||
|
} else if (scroll_movement > rodent.scrollthreshold) {
|
||||||
|
scroll_state = SCROLL_SCROLLING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rodent.flags & HVirtualScroll) {
|
||||||
|
hscroll_movement += action2.dx;
|
||||||
|
if (hscroll_movement < -rodent.scrollthreshold) {
|
||||||
|
scroll_state = SCROLL_SCROLLING;
|
||||||
|
} else if (hscroll_movement > rodent.scrollthreshold) {
|
||||||
|
scroll_state = SCROLL_SCROLLING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scroll_state == SCROLL_SCROLLING) scroll_movement = hscroll_movement = 0;
|
||||||
|
}
|
||||||
|
} else if (scroll_state == SCROLL_SCROLLING) {
|
||||||
if (rodent.flags & VirtualScroll) {
|
if (rodent.flags & VirtualScroll) {
|
||||||
scroll_movement += action2.dy;
|
scroll_movement += action2.dy;
|
||||||
debug("SCROLL: %d", scroll_movement);
|
debug("SCROLL: %d", scroll_movement);
|
||||||
|
if (scroll_movement < -rodent.scrollspeed) {
|
||||||
if (scroll_movement < -rodent.scrollthreshold) {
|
|
||||||
/* Scroll down */
|
/* Scroll down */
|
||||||
action2.dz = -1;
|
action2.dz = -1;
|
||||||
scroll_movement = 0;
|
scroll_movement = 0;
|
||||||
}
|
}
|
||||||
else if (scroll_movement > rodent.scrollthreshold) {
|
else if (scroll_movement > rodent.scrollspeed) {
|
||||||
/* Scroll up */
|
/* Scroll up */
|
||||||
action2.dz = 1;
|
action2.dz = 1;
|
||||||
scroll_movement = 0;
|
scroll_movement = 0;
|
||||||
@ -1206,11 +1233,11 @@ moused(void)
|
|||||||
hscroll_movement += action2.dx;
|
hscroll_movement += action2.dx;
|
||||||
debug("HORIZONTAL SCROLL: %d", hscroll_movement);
|
debug("HORIZONTAL SCROLL: %d", hscroll_movement);
|
||||||
|
|
||||||
if (hscroll_movement < -rodent.scrollthreshold) {
|
if (hscroll_movement < -rodent.scrollspeed) {
|
||||||
action2.dz = -2;
|
action2.dz = -2;
|
||||||
hscroll_movement = 0;
|
hscroll_movement = 0;
|
||||||
}
|
}
|
||||||
else if (hscroll_movement > rodent.scrollthreshold) {
|
else if (hscroll_movement > rodent.scrollspeed) {
|
||||||
action2.dz = 2;
|
action2.dz = 2;
|
||||||
hscroll_movement = 0;
|
hscroll_movement = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user