LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Map Back Button on Mouse (https://www.linuxquestions.org/questions/slackware-14/map-back-button-on-mouse-940779/)

bassmadrigal 04-19-2012 11:45 PM

Map Back Button on Mouse
 
I have been running Slack current on my machine for a while now after installing 13.37 from a complete wipe (finally decided to switch my main desktop over to Linux since it was basically acting as a fileserver and I never play games on it anymore). Everything has been working great and I love the built-in support for Radeon cards (which was a huge step up from 13.0 when it took me a few weeks to get hardware acceleration working).

Anyway, things have been working great except for one extremely annoying problem. My back button on the mouse doesn't work. I did a lot of research online, and while I know I can map it using xmodmap or something similar, I thought there had to be an easier way by now. I have been using Slack since 10.2, so I am used to modifying xorg.conf files and all sorts of other things, but things have progressed so far in plug and play support that I feel there HAS to be an easier way to do this that I am just somehow overlooking.

I am running a Microsoft Comfort Optical Mouse 3000. My left, right, and center clicks all work along with my scrolling. The mouse also supports clicking the mousewheel to the right and left, but I always found them awkward and I never used either. So with all those buttons, it makes my back (thumb/side) button number 9 (according to xev).

What is the suggested/proper way to configure the mouse for these more modern distributions?

polyph 04-20-2012 11:12 AM

Hi,
I have Microsoft Comfort Optical Mouse 4500 and I'm using it with 3.2.13 kernel from current. I configured 2,6,7,8 and 9 buttons with xte (from xautomation) and xbindkey.
I think with kernel 2.6.37.6 you will need to apply some patch to hid-microsoft.c module to make 8-9 buttons works but I don't know where you could find it.
I hope it help...

hpfeil 04-20-2012 11:28 AM

You no longer need xorg.conf. If something goes wacky, you can add a custom segment in xorg.conf.d.
For example, in my box with the nvidia.com driver I've added one file for the video driver and another for my monitor (xorg doesn't like its EDID).

#20-nv.conf
Section "Device"
Identifier "Device0"
Driver "nvidia"
EndSection

#30-monitor.conf
Section "Monitor"
Identifier "Monitor0"
VendorName "HP"
ModelName "w2338h"
DisplaySize 508 286
HorizSync 24-83
VertRefresh 48-76
EndSection

The default evdev driver finds my mouse and keyboard.
/usr/share/X11/xorg.conf.d/10-evdev.conf

Like you, I have to use xinput to make the side buttons work the way I like (Intellimouse Explorer 2). This file in my ~/bin directory (xinput is easier than xmodmap):

#! /bin/bash
## Called from ~/.config/autostart/mouse_buttons.desktop
export Mouse_Id="$(xinput list --short | grep Optical | awk '{ print $9 }' | awk -F"=" '{ print $2 }')"
/usr/bin/xinput set-button-map $Mouse_Id 1 2 3 4 5 6 7 2 1 10 11 12 13

bassmadrigal 04-20-2012 04:15 PM

Quote:

Originally Posted by polyph (Post 4658472)
Hi,
I have Microsoft Comfort Optical Mouse 4500 and I'm using it with 3.2.13 kernel from current. I configured 2,6,7,8 and 9 buttons with xte (from xautomation) and xbindkey.
I think with kernel 2.6.37.6 you will need to apply some patch to hid-microsoft.c module to make 8-9 buttons works but I don't know where you could find it.
I hope it help...

I guess I wasn't as clear as I thought I was with my post. I am running Slackware64-current up-to-date as of the 19th, so I am running KDE 4.8 with the latest Slack kernel (not at home, and I am too lazy to find out what the standard kernel version is with Slack current).

And @hpfeil, I already looked through my xorg log and it did autoload the evdev module, so I know I don't need to worry about an xorg.conf.d. But I will check out the xinput option and possibly borrow your little file. Still, it seems that there would be an easier way to configure it. I was actually really surprised to not see any option in the KDE input devices section to go more in depth with your mouse configuration.

bassmadrigal 04-20-2012 11:22 PM

So, once I got home from work I dug into things again and checked with xinput. My mouse was being recognized, and all my buttons registered as being pressed. What I ended up finding out is that my back button was mapped as button 9, and apparently, by default, button 8 is what acts as the back button. So I changed my xinput for the mouse to

Code:

xinput set-button-map 8 1 2 3 4 5 6 7 9 8
(I swapped the last 8 and 9)

For those who aren't familiar with xinput, the first number (in mine, 8) is the device id, which can be found by running xinput list. The rest is the buttons and how they are registered. If you use xinput test you can find out what buttons on the mouse equal what buttons that xinput reads. If something doesn't match up, you just change it.

As to the proper way to do this, I believe it would be done by using hal. So I created a file called msoptical-x11-input.fdi in /etc/hal/fdi/policy that read

Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.product" string="Microsoft Microsoft Optical Mouse with Tilt Wheel">
<merge key="input.x11_driver" type="string">evdev</merge>
<merge key="input.x11_options.ButtonMapping" type="string">1 2 3 4 5 6 7 9 8</merge>
<merge key="input.x11_options.EmulateWheel" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelButton" type="string">8</merge>
<merge key="input.x11_options.Emulate3Buttons" type="string">false</merge>
</match>
</device>
</deviceinfo>

I am not going to mark this topic solved for a little while to see if anyone pops in with the "recommended" way to handle this. If no one chimes in within a few days, I will mark as solved.

shadowsnipes 09-30-2012 04:34 PM

bassmadrigal, did you follow -current up to Slackware 14.0? There is no hal in Slackware anymore, so you will probably have to put your mouse configuration under a .conf file under /etc/X11/xorg.conf.d/

Something similar to this might be what you want:
Code:

Section "InputDevice"
    Identifier    "Mouse1"
    Driver        "mouse"
    Option        "Protocol" "Auto"
    Option        "Device" "/dev/mouse"
    Option        "Name" "Microsoft Microsoft Optical Mouse with Tilt Wheel"
    Option        "ButtonMapping" "1 2 3 4 5 6 7 9 8"
EndSection

Logical 8 is for the browser back button and Logical 9 is for the browser forward button. It would seem there is no physical button 8 since the red side button is 9.

I'm actually having a little trouble having buttons 6 and 7 (scroll left/right) detected in Slackware 14.0. xev does not show the buttons when I tilt the wheel side to side like it does with Slackware 13.37. Is this the same for you or anyone else?

I'm not sure what is the cause of this right now (new kernel driver, no hal, other configuration difference, etc)...

hpfeil 10-02-2012 10:08 AM

You really don't need anything in /etc/X11/xorg.conf.d/, at least I don't. Meeses and keyboards are now running under evdev.
Just about all the documentation you'll need is in
http://docs.slackware.com/start

There's lots of new stuff to get smart on with 14:

http://mirrors.slackware.com/slackwa..._AND_HINTS.TXT

http://mirrors.slackware.com/slackwa....0/UPGRADE.TXT
and, of course,
http://mirrors.slackware.com/slackwa.../ANNOUNCE.14_0
as well as the readme files in the top level.

This still works for me
=-=-=--=-snip=-=-==-
#!/bin/bash
## Called from ~/.config/autostart/mouse_buttons.desktop

export Mouse_Id="$(xinput list --short | grep Optical | awk '{ print $9 }' | awk -F"=" '{ print $2 }')"

/usr/bin/xinput set-button-map $Mouse_Id 1 2 3 4 5 6 7 2 1 10 11 12 13
=-=-=-=-snip=-=-=-=-=-

The canonical way, of course, is to add a udev rule under /etc/udev/rules.d that overrides the mouse-button rule in /lib/udev/rules.d/. Suffering from frequent bouts of congenital indolence (born lazy), as I oftentimes do, if it works, put the job to figure out the elegant solution back into the IN box, where it may languish for quite some time. ;->

David the H. 10-04-2012 09:30 AM

Code:

export Mouse_Id="$(xinput list --short | grep Optical | awk '{ print $9 }' | awk -F"=" '{ print $2 }')"
If I could make a recommendation, a simple sed expression would be more efficient here:

Code:

export Mouse_Id="$( xinput list --short | sed -rn '/Optical/ s/.*id=([0-9]+).*/\1/p' )
And just for fun, it's also possible to do it entirely in bash (outside of xinput, of course).

Code:

Mouse_Id=$( xinput list -- short )
re='Optical[^=]+=([0-9]+)'
[[ $Mouse_Id =~ $re ]] && export Mouse_Id=${BASH_REMATCH[1]}

And please use ***[code][/code] tags*** around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.


All times are GMT -5. The time now is 05:14 PM.