summaryrefslogtreecommitdiffstats
path: root/usr.sbin/moused
diff options
context:
space:
mode:
authorphilip <philip@FreeBSD.org>2008-05-15 15:05:02 +0000
committerphilip <philip@FreeBSD.org>2008-05-15 15:05:02 +0000
commite628a9c99a36bc5602bd67c5b1d059edd8f75990 (patch)
tree9921a3351933bef178f15026e9af28822ebec2f6 /usr.sbin/moused
parent664e023b090c85aa49494361ed2774e64696736e (diff)
downloadFreeBSD-src-e628a9c99a36bc5602bd67c5b1d059edd8f75990.zip
FreeBSD-src-e628a9c99a36bc5602bd67c5b1d059edd8f75990.tar.gz
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
Diffstat (limited to 'usr.sbin/moused')
-rw-r--r--usr.sbin/moused/moused.824
-rw-r--r--usr.sbin/moused/moused.c49
2 files changed, 58 insertions, 15 deletions
diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8
index c78086e..333b247 100644
--- a/usr.sbin/moused/moused.8
+++ b/usr.sbin/moused/moused.8
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 12, 2004
+.Dd May 15, 2008
.Dt MOUSED 8
.Os
.Sh NAME
@@ -43,7 +43,7 @@
.Op Fl F Ar rate
.Op Fl r Ar resolution
.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 X Ns Op , Ns Ar Y
.Op Fl C Ar threshold
@@ -139,6 +139,18 @@ simultaneously.
The default timeout is 100 msec.
.It Fl F Ar rate
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
Enable
.Dq Horizontal Virtual Scrolling .
@@ -148,7 +160,9 @@ horizontal scrolling.
Use the
.Fl U
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
.Fl V
option.
@@ -201,7 +215,9 @@ button down will cause motion to be interpreted as scrolling.
Use the
.Fl U
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
When
.Dq Virtual Scrolling
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c
index 2f6a2a9..f647f43 100644
--- a/usr.sbin/moused/moused.c
+++ b/usr.sbin/moused/moused.c
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
#define DFLT_CLICKTHRESHOLD 500 /* 0.5 second */
#define DFLT_BUTTON2TIMEOUT 100 /* 0.1 second */
#define DFLT_SCROLLTHRESHOLD 3 /* 3 pixels */
+#define DFLT_SCROLLSPEED 2 /* 2 pixels */
/* Abort 3-button emulation delay after this many movement events. */
#define BUTTON2_MAXMOVE 3
@@ -418,6 +419,7 @@ static struct rodentparam {
float remainx; /* Remainder on X and Y axis, respectively... */
float remainy; /* ... to compensate for rounding errors. */
int scrollthreshold; /* Movement distance before virtual scrolling */
+ int scrollspeed; /* Movement distance to rate of scrolling */
} rodent = {
.flags = 0,
.portname = NULL,
@@ -441,6 +443,7 @@ static struct rodentparam {
.remainx = 0.0,
.remainy = 0.0,
.scrollthreshold = DFLT_SCROLLTHRESHOLD,
+ .scrollspeed = DFLT_SCROLLSPEED,
};
/* button status */
@@ -574,7 +577,7 @@ main(int argc, char *argv[])
for (i = 0; i < MOUSE_MAXBUTTON; ++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) {
case '3':
@@ -760,6 +763,14 @@ main(int argc, char *argv[])
pidfile = optarg;
break;
+ case 'L':
+ rodent.scrollspeed = atoi(optarg);
+ if (rodent.scrollspeed < 0) {
+ warnx("invalid argument `%s'", optarg);
+ usage();
+ }
+ break;
+
case 'P':
rodent.flags |= NoPnP;
break;
@@ -1121,6 +1132,7 @@ moused(void)
if (action0.button == MOUSE_BUTTON2DOWN) {
if (scroll_state == SCROLL_NOTSCROLLING) {
scroll_state = SCROLL_PREPARE;
+ scroll_movement = hscroll_movement = 0;
debug("PREPARING TO SCROLL");
}
debug("[BUTTON2] flags:%08x buttons:%08x obuttons:%08x",
@@ -1182,21 +1194,36 @@ moused(void)
* the stick/trackpoint/nipple, scroll!
*/
if (scroll_state == SCROLL_PREPARE) {
- /* Ok, Set we're really scrolling now.... */
- if (action2.dy || action2.dx)
- scroll_state = SCROLL_SCROLLING;
- }
- if (scroll_state == SCROLL_SCROLLING) {
+ /* Middle button down, waiting for movement threshold */
+ if (action2.dy || action2.dx) {
+ if (rodent.flags & VirtualScroll) {
+ scroll_movement += action2.dy;
+ 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) {
scroll_movement += action2.dy;
debug("SCROLL: %d", scroll_movement);
-
- if (scroll_movement < -rodent.scrollthreshold) {
+ if (scroll_movement < -rodent.scrollspeed) {
/* Scroll down */
action2.dz = -1;
scroll_movement = 0;
}
- else if (scroll_movement > rodent.scrollthreshold) {
+ else if (scroll_movement > rodent.scrollspeed) {
/* Scroll up */
action2.dz = 1;
scroll_movement = 0;
@@ -1206,11 +1233,11 @@ moused(void)
hscroll_movement += action2.dx;
debug("HORIZONTAL SCROLL: %d", hscroll_movement);
- if (hscroll_movement < -rodent.scrollthreshold) {
+ if (hscroll_movement < -rodent.scrollspeed) {
action2.dz = -2;
hscroll_movement = 0;
}
- else if (hscroll_movement > rodent.scrollthreshold) {
+ else if (hscroll_movement > rodent.scrollspeed) {
action2.dz = 2;
hscroll_movement = 0;
}
OpenPOWER on IntegriCloud