On Tue, Feb 21, 2012 at 01:17:34AM +0600, Alexandr Shadchin wrote:
> On Sun, Feb 19, 2012 at 05:09:06PM -0800, Bryan Linton wrote:
> > On 2012-02-19 17:23:18, Matthieu Herrb <[email protected]> wrote:
> > > On Sat, Feb 18, 2012 at 06:21:12PM -0800, Bryan Linton wrote:
> > >> >Synopsis:       Mouse forward/back buttons no longer work in new snap
> > >> >Category:       system
> > >> >Environment:
> > >>  System      : OpenBSD 5.1
> > >>  Details     : OpenBSD 5.1 (GENERIC) #157: Fri Feb 10 11:07:41 MST 2012
> > >>                   
> > >> [email protected]:/usr/src/sys/arch/i386/compile/GENERIC
> > >> 
> > >>  Architecture: OpenBSD.i386
> > >>  Machine     : i386
> > >> >Description:
> > >> 
> > >> I upgraded from a December 15ish snapshot to a February 2nd
> > >> snapshot and again to a February 10th snapshot to see if the
> > >> problem had been resolved in a newer snap. 
> > >> 
> > >> The forward/back buttons on my mouse do not cause either Midori,
> > >> XXXTerm, or Firefox to go to the next/previous page like they used
> > >> to.
> > >> 
> > >> They seem to function the same as the up/down buttons on my
> > >> keyboard in that they cause the screen to scroll up or down by one
> > >> line.  Scrolling with the mouse wheel is normal and unchanged.
> > >> 
> > >> I am not using an /etc/X11/xorg.conf file.  I have updated all
> > >> packages with pkg_add and run sysmerge.  The only commit I could
> > >> find in source-changes@ that may have affected this was:
> > >> 
> > >> ---8<---
> > >> 
> > >> CVSROOT:        /cvs
> > >> Module name:    xenocara
> > >> Changes by:     [email protected]        2012/01/08
> > >> 10:15:52
> > >> 
> > >> Modified files:
> > >>         xserver/config : wscons.c
> > >> 
> > >> Log message:
> > >> Switch to the xf86-input-ws input driver for mouse by
> > >> default.
> > >> 
> > >> ok shadchin@.
> > >> 
> > >> ---8<---
> > >> 
> > >> Reverting this commit restores the original behavior of the mouse
> > >> forward/back keys.
> > > 
> > > Thanks for the detailled report. We'll need to figure out why the
> > > xf86-input-ws driver doesn't handle all buttons on your mouse.
> > > 
> > > In the mean time, rather than reverting the commit, you can use a
> > > simple /etc/X11/xorg.conf file like the one below to force the
> > > xf86-input-mouse driver to be used instead of xf86-input-ws:
> > > 
> > > --- cut ---
> > > Section "InputClass"
> > >         Identifier      "mouse driver"
> > >         MatchIsPointer  "on"    
> > >         Driver          "mous?
> > > EndSection
> > > --- cut --- 
> > > 
> > > Also, can you check with xev or "xinput test-xi2" which events are
> > > returned by the forward/back buttons with both drivers and send me and
> > > shadchin@ the result ?
> > > 
> > 
> > Here is the information you requested.  With the "mouse" driver
> > they read as 8 and 9.  
> > 
> > With the "ws" driver the buttons read as 4 and 5 which is the same
> > as the mouse wheel up/down which would explain why the screen
> > scrolls up or down by one line when they are pressed.
> 
> Thanks for the report.
> 
> Indeed:
> 
> ButtonMapping for
> mouse - 1 2 3 8 9 10 11 12 ... (user can change)
> ws - 1 2 3 4 5 6 7 8 ... (user can't chahge)
> 
> for reference evdev also 1 2 3 4 5 6 7 ...
> 
> I will prepare diff - for add handler option ButtonMapping.
> 
> Also need elect behavior on default - ws or mouse. Your suggestions?
> 

Add handler option ButtonMapping.

The behavior of as mouse(4) driver:

Section "InputClass"
    Identifier "mouse defaults"
    MatchIsPointer "on"

    Option "ButtonMapping" "1 2 3 8 9"
EndSection

Comments ? OK ?

-- 
Alexandr Shadchin

Index: man/ws.man
===================================================================
RCS file: /cvs/xenocara/driver/xf86-input-ws/man/ws.man,v
retrieving revision 1.12
diff -u -p -w -r1.12 ws.man
--- man/ws.man  28 Nov 2011 23:49:59 -0000      1.12
+++ man/ws.man  26 Feb 2012 16:15:11 -0000
@@ -53,6 +53,16 @@ Please refer to __xconfigfile__(__filema
 details and for options that can be used with all input drivers.
 This section only covers configuration details specific to this driver.
 .TP 4
+.BI "Option \*qButtonMapping\*q \*q" string \*q
+Sets the button mapping for this device. The mapping is a space-separated list
+of button mappings that correspond in order to the physical buttons on the
+device (i.e. the first number is the mapping for button 1, etc.). The default
+mapping is "1 2 3 ... 32". A mapping of 0 deactivates the button. Multiple
+buttons can have the same mapping.
+For example, a left-handed mouse with deactivated scroll-wheel would use a
+mapping of "3 2 1 0 0". Invalid mappings are ignored and the default mapping
+is used. Buttons not specified in the user's mapping use the default mapping.
+.TP 4
 .BI "Option \*qButtons\*q \*q" integer \*q
 Specifies the number of mouse buttons.
 In cases where the number of buttons cannot be auto-detected, the
Index: src/ws.c
===================================================================
RCS file: /cvs/xenocara/driver/xf86-input-ws/src/ws.c,v
retrieving revision 1.51
diff -u -p -w -r1.51 ws.c
--- src/ws.c    29 Dec 2011 13:48:05 -0000      1.51
+++ src/ws.c    26 Feb 2012 16:15:11 -0000
@@ -120,7 +120,7 @@ wsPreInit(InputDriverPtr drv, InputInfoP
        WSDevicePtr priv;
        MessageType buttons_from = X_CONFIG;
        char *s;
-       int rc = BadValue;
+       int i, phy_btn = 1, rc = BadValue;
 
        priv = (WSDevicePtr)calloc(1, sizeof(WSDeviceRec));
        if (priv == NULL) {
@@ -145,6 +145,31 @@ wsPreInit(InputDriverPtr drv, InputInfoP
                buttons_from = X_DEFAULT;
        }
 
+       /* Check for user-defined button mapping */
+       s = xf86SetStrOption(pInfo->options, "ButtonMapping", NULL);
+       if (s) {
+               char *map = s, *end;
+               int btn;
+
+               do {
+                       btn = strtol(map, &end, 10);
+
+                       if (end == map || btn < 0 || btn > NBUTTONS) {
+                               xf86IDrvMsg(pInfo, X_ERROR,
+                                   "Invalid button mapping. Using defaults\n");
+                               phy_btn = 1; /* ensure defaults start at 1 */
+                               break;
+                       }
+
+                       priv->btnmap[phy_btn++] = btn;
+                       map = end;
+               } while (end && *end != '\0' && phy_btn <= NBUTTONS);
+               free(s);
+       }
+
+       for (i = phy_btn; i <= NBUTTONS; i++)
+               priv->btnmap[i] = i;
+
        wsWheelHandleButtonMap(pInfo, &(priv->Z), "ZAxisMapping", "4 5");
        wsWheelHandleButtonMap(pInfo, &(priv->W), "WAxisMapping", "6 7");
 
@@ -295,8 +320,7 @@ wsDeviceInit(DeviceIntPtr pWS)
 {
        InputInfoPtr pInfo = (InputInfoPtr)pWS->public.devicePrivate;
        WSDevicePtr priv = (WSDevicePtr)pInfo->private;
-       unsigned char map[NBUTTONS + 1];
-       int i, xmin, xmax, ymin, ymax;
+       int xmin, xmax, ymin, ymax;
        Atom btn_labels[NBUTTONS] = {0};
        Atom axes_labels[NAXES] = {0};
 
@@ -305,12 +329,10 @@ wsDeviceInit(DeviceIntPtr pWS)
        btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
        btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
        btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
-       for (i = 0; i < NBUTTONS; i++)
-               map[i + 1] = i + 1;
        if (!InitButtonClassDeviceStruct(pWS,
                min(priv->buttons, NBUTTONS),
                btn_labels,
-               map))
+               priv->btnmap))
                return !Success;
 
        if (priv->type == WSMOUSE_TYPE_TPANEL) {
Index: src/ws.h
===================================================================
RCS file: /cvs/xenocara/driver/xf86-input-ws/src/ws.h,v
retrieving revision 1.9
diff -u -p -w -r1.9 ws.h
--- src/ws.h    28 Nov 2011 23:49:59 -0000      1.9
+++ src/ws.h    26 Feb 2012 16:15:11 -0000
@@ -43,7 +43,6 @@ typedef struct {
 typedef struct WSDevice {
        char *devName;          /* device name */
        int type;               /* ws device type */
-       unsigned int buttons;   /* # of buttons */
        unsigned int lastButtons; /* last state of buttons */
        int old_ax, old_ay;
        int min_x, max_x, min_y, max_y; /* coord space */
@@ -56,6 +55,10 @@ typedef struct WSDevice {
        WheelAxis W;
        struct wsmouse_calibcoords coords; /* mirror of the kernel values */
 
+       /* # of buttons and config-file specified button mapping */
+       unsigned int buttons;
+       unsigned char btnmap[NBUTTONS + 1];
+
        /* Middle mouse button emulation */
        struct {
                BOOL enabled;

Reply via email to