Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/wsmoused Add a new flag, -l, which swaps mouse butt...



details:   https://anonhg.NetBSD.org/src/rev/c35dc407aba2
branches:  trunk
changeset: 540826:c35dc407aba2
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Wed Dec 25 19:13:53 2002 +0000

description:
Add a new flag, -l, which swaps mouse buttons; this is useful for left
handed users.

Patch provided in my own PR bin/19143 with some minor changes as suggested
by wiz.

diffstat:

 usr.sbin/wsmoused/events.c   |  18 +++++++++---------
 usr.sbin/wsmoused/wsmoused.8 |   6 ++++--
 usr.sbin/wsmoused/wsmoused.c |  16 ++++++++++++----
 usr.sbin/wsmoused/wsmoused.h |   6 +++++-
 4 files changed, 30 insertions(+), 16 deletions(-)

diffs (152 lines):

diff -r 44374d6c6b31 -r c35dc407aba2 usr.sbin/wsmoused/events.c
--- a/usr.sbin/wsmoused/events.c        Wed Dec 25 19:04:27 2002 +0000
+++ b/usr.sbin/wsmoused/events.c        Wed Dec 25 19:13:53 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: events.c,v 1.3 2002/07/04 20:50:29 christos Exp $ */
+/* $NetBSD: events.c,v 1.4 2002/12/25 19:13:53 jmmv Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: events.c,v 1.3 2002/07/04 20:50:29 christos Exp $");
+__RCSID("$NetBSD: events.c,v 1.4 2002/12/25 19:13:53 jmmv Exp $");
 #endif /* not lint */
 
 #include <sys/ioctl.h>
@@ -101,27 +101,27 @@
 {
        switch (evt->type) {
        case WSCONS_EVENT_MOUSE_UP:
-               if (evt->value == 0) {
+               if (evt->value == m->but_select) {
+                       /* End selection */
                        mouse_sel_end(m);
                        mouse_sel_hide(m);
                }
                break;
 
        case WSCONS_EVENT_MOUSE_DOWN:
-               switch (evt->value) {
-               case 0: /* Button 1 */
+               if (evt->value == m->but_select) {
+                       /* Start selection */
                        mouse_sel_start(m);
                        mouse_cursor_hide(m);
                        mouse_sel_show(m);
-                       break;
-               case 2: /* Button 2 */
+               } else if (evt->value == m->but_paste) {
+                       /* Paste selection */
                        mouse_sel_paste(m);
                        break;
                }
-               break;
 
        default:
-               warnx("unknown event");
+               warnx("unknown button event");
        }
 }
 
diff -r 44374d6c6b31 -r c35dc407aba2 usr.sbin/wsmoused/wsmoused.8
--- a/usr.sbin/wsmoused/wsmoused.8      Wed Dec 25 19:04:27 2002 +0000
+++ b/usr.sbin/wsmoused/wsmoused.8      Wed Dec 25 19:13:53 2002 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: wsmoused.8,v 1.6 2002/10/25 21:02:45 wiz Exp $
+.\" $NetBSD: wsmoused.8,v 1.7 2002/12/25 19:13:53 jmmv Exp $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -37,7 +37,7 @@
 .Nm
 .Op Fl d Ar device
 .Op Fl f Ar fifo
-.Op Fl n
+.Op Fl ln
 .Op Fl X Ar number
 .Op Fl x Ar number
 .Op Fl y Ar number
@@ -56,6 +56,8 @@
 .It Fl f Ar fifo
 is used to specify an optional fifo where to redirect all mouse events
 (even if they have been processed). By default, no fifo is used.
+.It Fl l
+swaps mouse buttons, specially useful for left handed users.
 .It Fl n
 do not fork in the background (for debugging purposes).
 .It Fl X Ar number
diff -r 44374d6c6b31 -r c35dc407aba2 usr.sbin/wsmoused/wsmoused.c
--- a/usr.sbin/wsmoused/wsmoused.c      Wed Dec 25 19:04:27 2002 +0000
+++ b/usr.sbin/wsmoused/wsmoused.c      Wed Dec 25 19:13:53 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmoused.c,v 1.5 2002/08/20 16:55:28 christos Exp $ */
+/* $NetBSD: wsmoused.c,v 1.6 2002/12/25 19:13:53 jmmv Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: wsmoused.c,v 1.5 2002/08/20 16:55:28 christos Exp $");
+__RCSID("$NetBSD: wsmoused.c,v 1.6 2002/12/25 19:13:53 jmmv Exp $");
 #endif /* not lint */
 
 #include <sys/ioctl.h>
@@ -72,7 +72,7 @@
 usage(void)
 {
        (void)fprintf(stderr,
-           "Usage: %s [-d device] [-f fifo] [-n] [-X number] [-x number] "
+           "Usage: %s [-d device] [-f fifo] [-ln] [-X number] [-x number] "
            "[-y number]\n",
            getprogname());
        exit(EXIT_FAILURE);
@@ -314,8 +314,12 @@
        mouse.slowdown_x = 0;
        mouse.slowdown_y = 3;
 
+       /* Right handed by default */
+       mouse.but_select = 0;
+       mouse.but_paste = 2;
+
        /* Parse command line options */
-       while ((opt = getopt(argc, argv, "nf:d:X:x:y:")) != -1) {
+       while ((opt = getopt(argc, argv, "d:f:lny:X:x:")) != -1) {
                switch (opt) {
                case 'd': /* Mouse device name */
                        mouse.device_name = strdup(optarg);
@@ -323,6 +327,10 @@
                case 'f': /* FIFO file name */
                        mouse.fifo_name = strdup(optarg);
                        break;
+               case 'l': /* Left handed */
+                       mouse.but_select = 2;
+                       mouse.but_paste = 0;
+                       break;
                case 'n': /* No daemon */
                        NoDaemon = 1;
                        break;
diff -r 44374d6c6b31 -r c35dc407aba2 usr.sbin/wsmoused/wsmoused.h
--- a/usr.sbin/wsmoused/wsmoused.h      Wed Dec 25 19:04:27 2002 +0000
+++ b/usr.sbin/wsmoused/wsmoused.h      Wed Dec 25 19:13:53 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsmoused.h,v 1.1 2002/06/26 23:13:11 christos Exp $ */
+/* $NetBSD: wsmoused.h,v 1.2 2002/12/25 19:13:53 jmmv Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -52,6 +52,10 @@
        int cursor;
        int selecting;
        int disabled;
+
+       /* Button configuration */
+       int but_select;
+       int but_paste;
 };
 
 /* Prototypes for wsmoused.c */



Home | Main Index | Thread Index | Old Index