# Trackball configuration in modular xorg.

## davidgurvich

Update to earlier post: https://forums.gentoo.org/viewtopic-t-414623-highlight-emulatewheelbutton.html

There is no longer a need to makeup fake buttons in order to get scrolling to work.  Xorg-7 starts by assigning 11 buttons, taking 4 5 6 7 as scroll buttons and leaving 7 physical buttons.  There is no need to use xmodmap to modify what buttons point where as there seems to be a new option for that within xorg.conf, "ButtonMapping".  In fact, without any editing xorg.conf seems to have the following default:

Option   "ButtonMapping"  "1 2 3 8 9 10 11"

For my trackball that is overkill,  I have 4 physical buttons and the trackball itself.  Here is the modified mouse section of my xorg.conf.

 *Quote:*   

> Section "InputDevice"
> 
>         Identifier      "Mouse0"
> 
>         Driver          "mouse"
> ...

 

Note that "Buttons" "5" adds an emulated middle click to the physical buttons available.  I will probably modify the ButtonMapping line to read:

 *Quote:*   

>     Option        "ButtonMapping" "1 7 3 6 2"

 

That is so that the small side buttons, 6 and 7, on my trackball will act as the emulatewheelbutton and middle click, respectively.

----------

## davidgurvich

A few side notes.

From the log, it appears that although I have set the buttons value to 5, giving me 7 in xorg-6.x, that I have had 2 buttons added afterwards.

In fact many of the settings in xorg.conf are changed.  Although the setting given work and the trackball will not work properly without them, the log shows me 11 buttons after using my settings.

----------

## davidgurvich

The following configuration allows both vertical and horizontal scrolling, and physical middle-click.

The trackball in question has 2 large side buttons, buttons 1 and 3, and 2 small side buttons, buttons 8 and 9.

The other values are 2 = middle-click, 4 and 5 are vertical up & down, 6 and 7 are horizontal up & down.  Physical button 9 is remapped to 2, and physical button 8 is used as the emulation button for scrolling.

 *Quote:*   

> Section "InputDevice"
> 
>         Identifier      "Mouse0"
> 
>         Driver          "mouse"
> ...

 

----------

## zaiyon

Nice thread, but some people might, like me, prefer a setup where they can use the small buttons as scroll buttons.

I use my logitech marble mouse (4 physical buttons) like this right now:

button 1: left mouse

button 2: right mouse

button 1 + button 2 (pressed together): middle click

button 3: scroll down

button 4: scroll up

Note that you cannot hold a scroll button down to continue scrolling, you have to click it as long as you want to scroll. I would love to change that behaviour.

I have the following xorg.conf section:

```

Section "InputDevice"

  Identifier  "Mouse0"

  Driver      "mouse"

  Option      "CorePointer"

  Option      "Protocol" "auto"

  Option      "Device" "/dev/input/mice"

  Option      "Buttons" "5"

  Option      "ZAxisMapping" "4 5"

  Option      "ButtonMapping" "1 2 3 6 7"

EndSection

```

Scrolling does not work yet with this, I still need to use xmodmap after X startup:

```

xmodmap -e "pointer = 1 2 3 6 7 4 5 8 9 10 11"

```

Now it works, but the button labeld with the upper arrow scrolls down and the down button up. So this is my final xmodmap line:

```

xmodmap -e "pointer = 1 2 3 6 7 5 4 8 9 10 11"

```

I did some strange things. This is probably ugly, unelegant and redundant, but it works fine for me.

----------

## davidgurvich

The configuration that I provided allows scrolling using one side button and the trackball.  It enables vertical and horizonal scrolling, if you don't mind holding a button down while using the trackball.  I actually have trouble using an emulated middle-click, frequently not hitting both buttons in a close enough timespan, so having a physical button mapped to middle-click makes a lot of sense to me.

----------

## clockwork06

Dave,

    Your config works for me, sorta. When I click the little left button I get an 8 event, when I click the little right button I get a 9 and 2 event. This presents an issue since duplicate events cause funny things in certain programs (ie opening a new tab, and loading in a current tab). Is there a way that I can get this function set:

Big Left= left click (1)

Big Right= Right click (3)

little left= middle click ( :Cool: 

little right= scroll with trackball (9 2 )

Currently I have the following:

```
Driver "mouse"

       Option "CorePointer" "false"

       Option "Device" "/dev/input/mouse2"

       Option "Protocol" "auto"

       Option "Buttons" "5"

       Option "EmulateWheel" "true"

       Option "EmulateWheelButton" "9"

       Option "YaxisMapping" "4 5"

       Option "XaxisMapping" "6 7"

       Option "ButtonMapping" "1 8 3 9 2"

EndSection 
```

I would assume that swapping 8 and 9 should work, but I still get duplicate events. Nobody has an explination as to what position coresponds to what on the buttonmapping line. So any help is appreciated.

----------

## Eglathôlion

Hi!

 *clockwork06 wrote:*   

> When I click the little left button I get an 8 event, when I click the little right button I get a 9 and 2 event. This presents an issue since duplicate events cause funny things in certain programs (ie opening a new tab, and loading in a current tab). Is there a way that I can get this function set:
> 
> [...]
> 
> I would assume that swapping 8 and 9 should work, but I still get duplicate events.
> ...

 

I tried nearly every possible combination in the last 8 hours.   :Sad: 

It seems not to be possible, to get the buttons 8 and 9 pressed without sending another event with it.

Most of the time, button 8 acted like button one, so that a link was pressed while scrolling over it (eg. with zaiyons config and IIRC one of daves). Button 3 opened the link in a new tab.

Another behavior was that my browser acted as if I pressed the back or forward button while scrolling. That was with one of daves configs (I cannot remember, if it was the one with or without horizontal scrolling. Can't think no more   :Confused:  ).

If I use a mouse or a trackball with a normal wheel, only 4 and 5 are used - as it should be.  :Rolling Eyes:  And I think that is how it was handled in xorg 6.8 (can someone verify that?).

Why did that change for my beloved Marble Mouse with xorg 7.0?   :Crying or Very sad: 

Best regards...

Ace

----------

## Eglathôlion

I finally solved it:

According to this, the reason for this behaviour is:

 *Quote:*   

> 
> 
> In X.Org 6.9/7.0 RC3, upstream made changes to the mouse button handling. 
> 
> The default ZAxisMapping is "4 5 6 7", accommodating scroll wheels with two 
> ...

 

The solution is to turn off the back/forward functions of buttons 6 and 7 in your browsers.

In Opera you can simply edit the preferences or the config file standard_mouse.ini.

In Mozilla you need to configure via about:config.

I used this wiki for my new values:

http://www.thinkwiki.org/wiki/How_to_configure_the_TrackPoint

Best regards...

Ace

Google Keywords: mouse scroll wheel up browser back button 6 7 x.org xorg 6.9 7.0 7.1 7.x mozilla firefox opera

----------

## Xichekolas

I have a MS Intellimouse Optical. It has a wheel, two main buttons, and a side button on each side. The wheel is also clickable. To get Back and Forward functionality in Firefox with the two side buttons, I use the following mouse config in xorg.conf. 

Section "InputDevice"

    Identifier     "Mouse0"

    Driver         "mouse"

    Option         "Protocol" "auto"

    Option         "Device" "/dev/input/mice"

    Option         "ZAxisMapping" "4 5 8 9"

    Option         "ButtonMapping" "1 2 3 6 7 10 11"

EndSection

Just thought someone out there might enjoy that.

----------

## mezoko

Logitech Marble Mouse - USB (not using the PS/2 adapter)

Middle Click = Press both left and right

Scroll = Press small button on left side, use trackball to move up and down

```

Section "InputDevice"

        Identifier  "Mouse0"

        Driver      "mouse"

        Option "Device" "/dev/input/mice"

        Option "Protocol" "ExplorerPS/2"

        Option "Buttons" "9"

        Option "ZAxisMapping" "4 5"

        Option "EmulateWheel" "1"

        Option "EmulateWheelButton" "8"

EndSection

```

If you want to scroll with the right small button you can change 

```
Option "EmulateWheelButton" "8"
```

 to 

```
Option "EmulateWheelButton" "9"
```

I am using Xorg 7.1

----------

## mackerel

I used this post to get my marble mouse working a long time ago. However, with recent kernel updates (anything past 2.6.18-r6), the scroll no longer works. As long as I boot into the older kernel, it works fine. Has anyone had this issue? Are there any changes (from the beginning of the post) that I need to make for recent kernel changes?

Thanks,

Mack

----------

## mezoko

I am not using gentoo anymore, but using my configuration up above I have not noticed any problems. I am currently running 2.6.22-Arch, though I've also have ran a believe vanilla sources and viper sources with kernels 2.6.18+ and not had any problems.

----------

## mackerel

mezoko - when I use your config instead of the origional post, I do have scroll. Not exactly the same type of scroll. With the old config, when I scroll the pointer remains stationary and the page scrolls. With your config, both the pointer and page scrolls (this is also with the new kernel). I prefer the old settings with newer kernels. I could hang on to my old kernel, but I assume at some point I will have to upgrade.

Thanks,

Mack

----------

## mackerel

For anyone who also has this issue, I was able to fix it.

This apparently was because of my second mouse using the same driver/protocol.

I installed a new mouse to replace the secondary mouse (not the marble mouse). In the configuration wiki, the evdev driver is used. By switching the secondary mouse to another driver it works as expected. -wierd

 *Quote:*   

> 
> 
> Section "InputDevice"
> 
>         identifier "MarbleMouse"
> ...

 

 *Quote:*   

> 
> 
> Section "InputDevice"
> 
>        Identifier  "Cordless Optical Trackman"
> ...

 

----------

## davidgurvich

Are there really 32 button options for your setup?  That's almost a keyboards worth.  Do you think you can take 10 buttons and set up a number pad?

----------

## mackerel

I just copied it from the  guide.

It worked, I didn't notice any issues, so I left it. I also though it was a bit excessive, but I can't complain.

----------

## calande

Hello guys, I have that Kensington Turbo Mouse PRO trackball with a marble and 4 large buttons around it. How can I set them up this way?

  Button #1 -> Click  Button #2 -> Right-Click  Button #3 -> Double-Click Button #4 -> Close active application window 

 :Question: 

Thanks,

----------

## davidgurvich

Cross pollination has occured.  This post was used in http://gentoo-wiki.com/Talk:HOWTO_Advanced_Mouse#No_more_need_for_xmodmap.3F with an addon.

 *Quote:*   

> The EmulateWheelInertia is just about how fast the scroll works. And then that last setting is where it gets interesting.
> 
> "EmulateWheelTimeout" means that if I hold that button down for less than 200 milliseconds then instead of doing the wheel emulation (by sending button 4 or 5 events), it sends a button 8 event. We'll get to that in a sec, for now that's all the xorg.conf settings, save, restart, etc.. Your MarbleFX will now do wheel scroll with the red button. 

 What you want may be there.

xbindkeys and xautomation is used.

----------

## divago

Hi all

some time ago (about one-ona and half year ago) i used this trackball on Fedora first, then on Gentoo when i evolved into Gentoo

i was used to tweak xorg.conf for some reason so i found really useful and easy to configure this trackball just adding few lines into xorg.conf

then i stopped using linux for work and got really low time to use it for pleasure, and i started again working on it one month ago. Yesterday i completed my first gentoo installation "all alone"  :Smile:  (well, technically i'm still emerging something... >.> )

i had really really big problem configuring Trackball: it seems ignoring xorg parameters, and adding this lines to xorg seems useless

btw i discovered problem is hal, so i googled a little more and found this guide: http://www.robmeerman.co.uk/unix/xinput

i followed the steps (you need to create a /etc/hal/fdi/policy/10-marblemouse.fdi file with some hal configuration...)

and now it work!!!  :Smile: 

following step by step the guide i got:

big button: right and left click

small button left: enable scroll vertical and horizontal

small button right: middle click

i hope this could be useful for you too  :Smile: 

Oh and i had to change some opera configuration that caused small button to go back/forward

(in opera you need to go preferences; in firefox i think there are somethint in about:config interface...)

----------

