diff options
author | philip <philip@FreeBSD.org> | 2005-07-19 19:30:49 +0000 |
---|---|---|
committer | philip <philip@FreeBSD.org> | 2005-07-19 19:30:49 +0000 |
commit | bba20555e072aabcf0d33ac0ba362d31dbd983e4 (patch) | |
tree | 4ce00d6c4f63db4eb685a808c43f73c3eff80258 /usr.sbin/moused | |
parent | 9cfb6018bfa46e346267530be64ef2a282b11c85 (diff) | |
download | FreeBSD-src-bba20555e072aabcf0d33ac0ba362d31dbd983e4.zip FreeBSD-src-bba20555e072aabcf0d33ac0ba362d31dbd983e4.tar.gz |
Add a -H option to enable horizontal virtual scrolling, much like -V for
vertical virtual scrolling. This also respects -U for the distance.
PR: bin/82762
Submitted by: Eric Kjeldergaard <kjelderg -at- gmail.com>
MFC after: 1 month
Diffstat (limited to 'usr.sbin/moused')
-rw-r--r-- | usr.sbin/moused/moused.8 | 14 | ||||
-rw-r--r-- | usr.sbin/moused/moused.c | 55 |
2 files changed, 51 insertions, 18 deletions
diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8 index 1d2ef88..ae53087 100644 --- a/usr.sbin/moused/moused.8 +++ b/usr.sbin/moused/moused.8 @@ -43,7 +43,7 @@ .Op Fl F Ar rate .Op Fl r Ar resolution .Op Fl S Ar baudrate -.Op Fl V Op Fl U Ar distance +.Op Fl VH Op Fl U Ar distance .Op Fl a Ar X Ns Op , Ns Ar Y .Op Fl C Ar threshold .Op Fl m Ar N=M @@ -128,6 +128,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 H +Enable +.Dq Horizontal Virtual Scrolling . +With this option set, holding the middle mouse +button down will cause motion to be interpreted as +horizontal scrolling. +Use the +.Fl U +option to set the distance the mouse must move before the scrolling mode is +activated. This option may be used with or without the +.Fl V +option. .It Fl I Ar file Write the process id of the .Nm diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index 45f05c9..617ae37 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$"); #define ClearRTS 0x0008 #define NoPnP 0x0010 #define VirtualScroll 0x0020 +#define HVirtualScroll 0x0040 #define ID_NONE 0 #define ID_PORT 1 @@ -167,6 +168,7 @@ char *pidfile = "/var/run/moused.pid"; static int scroll_state; static int scroll_movement; +static int hscroll_movement; /* local variables */ @@ -523,7 +525,7 @@ main(int argc, char *argv[]) for (i = 0; i < MOUSE_MAXBUTTON; ++i) mstate[i] = &bstate[i]; - while ((c = getopt(argc, argv, "3C:DE:F:I:PRS:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1) + while ((c = getopt(argc, argv, "3C:DE:F:HI:PRS:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1) switch(c) { case '3': @@ -688,6 +690,10 @@ main(int argc, char *argv[]) } break; + case 'H': + rodent.flags |= HVirtualScroll; + break; + case 'I': pidfile = optarg; break; @@ -993,7 +999,7 @@ moused(void) if ((flags = r_protocol(b, &action0)) == 0) continue; - if (rodent.flags & VirtualScroll) { + if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) { /* Allow middle button drags to scroll up and down */ if (action0.button == MOUSE_BUTTON2DOWN) { if (scroll_state == SCROLL_NOTSCROLLING) { @@ -1053,7 +1059,7 @@ moused(void) debug("activity : buttons 0x%08x dx %d dy %d dz %d", action2.button, action2.dx, action2.dy, action2.dz); - if (rodent.flags & VirtualScroll) { + if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) { /* * If *only* the middle button is pressed AND we are moving * the stick/trackpoint/nipple, scroll! @@ -1064,19 +1070,34 @@ moused(void) scroll_state = SCROLL_SCROLLING; } if (scroll_state == SCROLL_SCROLLING) { - scroll_movement += action2.dy; - debug("SCROLL: %d", scroll_movement); - - if (scroll_movement < -rodent.scrollthreshold) { - /* Scroll down */ - action2.dz = -1; - scroll_movement = 0; - } - else if (scroll_movement > rodent.scrollthreshold) { - /* Scroll up */ - action2.dz = 1; - scroll_movement = 0; - } + if (rodent.flags & VirtualScroll) { + scroll_movement += action2.dy; + debug("SCROLL: %d", scroll_movement); + + if (scroll_movement < -rodent.scrollthreshold) { + /* Scroll down */ + action2.dz = -1; + scroll_movement = 0; + } + else if (scroll_movement > rodent.scrollthreshold) { + /* Scroll up */ + action2.dz = 1; + scroll_movement = 0; + } + } + if (rodent.flags & HVirtualScroll) { + hscroll_movement += action2.dx; + debug("HORIZONTAL SCROLL: %d", hscroll_movement); + + if (hscroll_movement < -rodent.scrollthreshold) { + action2.dz = -2; + hscroll_movement = 0; + } + else if (hscroll_movement > rodent.scrollthreshold) { + action2.dz = 2; + hscroll_movement = 0; + } + } /* Don't move while scrolling */ action2.dx = action2.dy = 0; @@ -1158,7 +1179,7 @@ usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", "usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]", - " [-V [-U threshold]] [-a X [,Y]] [-C threshold] [-m N=M] [-w N]", + " [-VH [-U threshold]] [-a X [,Y]] [-C threshold] [-m N=M] [-w N]", " [-z N] [-t <mousetype>] [-l level] [-3 [-E timeout]] -p <port>", " moused [-d] -i <port|if|type|model|all> -p <port>"); exit(1); |