bin/175556: [PATCH] moused(8) virtual scrolling on alternate buttons
Wayne Galen
wayne.galen at gmail.com
Fri Jan 25 06:50:00 UTC 2013
>Number: 175556
>Category: bin
>Synopsis: [PATCH] moused(8) virtual scrolling on alternate buttons
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Jan 25 06:50:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: Wayne Galen
>Release: 9.1-RELEASE
>Organization:
N/A
>Environment:
>Description:
Attached is a patch that adds a new flag to moused(8), -b. This option allows the user to choose a button other than MOUSE_BUTTON3 to trigger virtual scrolling. The manpage has also been updated to reflect the change.
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
diff -rupN moused.orig/moused.8 moused/moused.8
--- moused.orig/moused.8 2013-01-24 22:16:17.994604268 -0800
+++ moused/moused.8 2013-01-24 22:30:13.674634226 -0800
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 15, 2008
+.Dd Jan 24, 2011
.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 Fl L Ar distance
+.Op Fl VH Op Fl U Ar distance Fl L Ar distance Fl b Ar vscrollbtn
.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
@@ -230,6 +230,15 @@ mode is activated.
The default
.Ar distance
is 3 pixels.
+.It Fl b Ar vscrollbutton
+When
+.Dq Virtual Scrolling
+is enabled, the
+.Fl b
+option can be used to set the button used to trigger scrolling.
+The default
+.Ar vscrollbutton
+is 3.
.It Fl A Ar exp Ns Op , Ns Ar offset
Apply exponential (dynamic) acceleration to mouse movements:
the faster you move the mouse, the more it will be accelerated.
@@ -824,6 +833,10 @@ This manual page was written by
.An Mike Pritchard Aq mpp at FreeBSD.org .
The command and manual page have since been updated by
.An Kazutaka Yokota Aq yokota at FreeBSD.org .
+The
+.Fl b
+flag was added by
+.An Wayne Galen Aq wayne.galen at gmail.com .
.Sh CAVEATS
Many pad devices behave as if the first (left) button were pressed if
the user
diff -rupN moused.orig/moused.c moused/moused.c
--- moused.orig/moused.c 2013-01-24 22:15:58.934600200 -0800
+++ moused/moused.c 2013-01-24 22:28:16.114623671 -0800
@@ -29,6 +29,8 @@
** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
+ ** Modified on 1/24/13 by Wayne Galen:
+ ** added -b flag so virtual scroll can be on any button
**/
/**
@@ -396,6 +398,7 @@ static unsigned short rodentcflags[] =
static struct rodentparam {
int flags;
+ int vscrollbtn;
const char *portname; /* /dev/XXX */
int rtype; /* MOUSE_PROTO_XXX */
int level; /* operation level: 0 or greater */
@@ -423,6 +426,7 @@ static struct rodentparam {
int scrollspeed; /* Movement distance to rate of scrolling */
} rodent = {
.flags = 0,
+ .vscrollbtn = MOUSE_BUTTON3DOWN,
.portname = NULL,
.rtype = MOUSE_PROTO_UNKNOWN,
.level = -1,
@@ -576,7 +580,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:L: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:VUb:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
switch(c) {
case '3':
@@ -835,7 +839,16 @@ main(int argc, char *argv[])
usage();
}
break;
-
+ case 'b':
+ rodent.vscrollbtn = atoi(optarg);
+ if (rodent.vscrollbtn > MOUSE_MAXBUTTON || rodent.vscrollbtn < 1) {
+ warnx("invalid button number `%s'", optarg);
+ usage();
+ }
+ else {
+ rodent.vscrollbtn = 1 << (rodent.vscrollbtn - 1); //turn the button number into a bitmask ala mouse.h
+ }
+ break;
case 'h':
case '?':
default:
@@ -1116,23 +1129,23 @@ moused(void)
continue;
if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) {
- /* Allow middle button drags to scroll up and down */
- if (action0.button == MOUSE_BUTTON2DOWN) {
+ /* Allow vscroll button drags to scroll up and down */
+ if (action0.button == rodent.vscrollbtn) {
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",
+ debug("[VSCROLLBTN] flags:%08x buttons:%08x obuttons:%08x",
action.flags, action.button, action.obutton);
} else {
- debug("[NOTBUTTON2] flags:%08x buttons:%08x obuttons:%08x",
+ debug("[NOTVSCROLLBTN] flags:%08x buttons:%08x obuttons:%08x",
action.flags, action.button, action.obutton);
/* This isn't a middle button down... move along... */
if (scroll_state == SCROLL_SCROLLING) {
/*
- * We were scrolling, someone let go of button 2.
+ * We were scrolling, someone let go of the button.
* Now turn autoscroll off.
*/
scroll_state = SCROLL_NOTSCROLLING;
@@ -1146,11 +1159,11 @@ moused(void)
A(newaction.button & MOUSE_BUTTON1DOWN,
action0.button & MOUSE_BUTTON3DOWN));
- /* Send middle down */
- newaction.button = MOUSE_BUTTON2DOWN;
+ /* Send button down */
+ newaction.button = rodent.vscrollbtn;
r_click(&newaction);
- /* Send middle up */
+ /* Send button up */
r_timestamp(&newaction);
newaction.obutton = newaction.button;
newaction.button = action0.button;
@@ -1178,11 +1191,11 @@ moused(void)
if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) {
/*
- * If *only* the middle button is pressed AND we are moving
+ * If *only* the vscroll button is pressed AND we are moving
* the stick/trackpoint/nipple, scroll!
*/
if (scroll_state == SCROLL_PREPARE) {
- /* Middle button down, waiting for movement threshold */
+ /* VScroll button down, waiting for movement threshold */
if (action2.dy || action2.dx) {
if (rodent.flags & VirtualScroll) {
scroll_movement += action2.dy;
@@ -1371,9 +1384,9 @@ usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
- " [-VH [-U threshold]] [-a X[,Y]] [-C threshold] [-m N=M] [-w N]",
- " [-z N] [-t <mousetype>] [-l level] [-3 [-E timeout]]",
- " [-T distance[,time[,after]]] -p <port>",
+ " [-VH [-U threshold][-b vscrollbtn] [-a X[,Y]] [-C threshold]",
+ " [-m N=M] [-w N] [-z N] [-t <mousetype>] [-l level]",
+ " [-3 [-E timeout]] [-T distance[,time[,after]]] -p <port>",
" moused [-d] -i <port|if|type|model|all> -p <port>");
exit(1);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list