Overview
Metro: LL Redux does not recognize all of mouse buttons on Linux. Middle scrolling wheel as iron-sights? Phyyah! Let’s use THUMB button.
Foreword & problem description
Metro:LL Redux does not recognize all of the mouse buttons. At least under Linux. I don’t know why it is hard for developers to read all of the mouse button presses, but let’s try to fix this oversight.
In the following guide you will learn to swap your mouse buttons around with X-tools.
We’ll use Logitech MX518 mouse as example, but this method should work for any pointer device (not just mouses but for all input devices like Wii-controllers and lightsabers). Normally “iron-sights” is bound to middle mouse button, but that’s really bad place for it on MX518 so we’ll swap it to thumb button.
We’ll do lots of command line stuff here in old-fashioned way, so I’ll assume you know how to use terminal. It’s konsole on KDE, gnome-terminal on Gnome or you can just use xterm but it’s sort of hard for new users.
If you’re completely new on this, search for “shell” or “terminal” on your program menu. After that do some learning and reading before doing anything so you know the basics. There is wealth of information on the Internet, use the knowledge, Luke.
This is for 25.01.2015 Metro: LL Redux. This problem might be fixed on later versions.
Also we use Ubuntu for this guide as that’s what Valve is supporting. However it’s extremely easy to do same things on another Linux systems.
Requirements & installation
You need X-programs for this. Some of them are most likely already installed, but anyways we’ll go through the installation step.
We will need following programs:
- xev — reads ‘events’ from the test window and outputs them as human readable text
- xmodmap — modifies X input device layout
I’ll instruct briefly how you can install new programs. You’ll need x11-utils and x11-xserver-utils packages. Very likely these are already installed!
Using xev: listen your input devices
Let’s swap around two mouse buttons so your thumb button works as middle mouse button!
Open terminal and start xev.
Small white window with black square appears. When you move your mouse over it, terminal console starts to spew all kinds of debug info. You can also press keyboard keys here. If you have some other types of input devices they will also show up here.
Press your middle mouse button. Now press thumb button. You should see output which is similar to following:
Look at the third line. Now press middle mouse button and thumb button again. These are codes for your mouse buttons. You will notice that even scroll wheels are “buttons” when you rotate the scroll wheel.
In this example MX518 middle mouse button is marked with bold text:
In this example MX518 thumb button is marked with bold text:
Mark down the results.
Using xmodmap: swapping mouse buttons
As we now know the button codes, it’s quite straightforward to swap them temporarily around.
We can do it with xmodmap one-liner:
As you can see, there are 16 mapped pointer events defined and button numbers 2 and 8 are swapped. You have to specify all of the mappings you currently have.
This modification will persist until you log out from your computer.
Now Metro: LL Redux will think you are pressing middle mouse button when actually you’re using thumb button.
Also you can save command in the file and add that file to Steam game launch options (e.g, /path/buttonscript; %command% ; /path/restorebuttons ).
I reckon there are usually 16 around, but you can check them with this:
X gives you a warning if you try to re-define wrong number if entries than you already have and pointer maps are not changed.
If you want to disable some buttons, you can define those buttons to zero. For example, you’ll get Apple mouse by mapping the first button to one and all other buttons to zeroes.
- 1: left button
- 2: middle button
- 3: right button
- 4: wheel up
- 5: wheel down
- 8: thumb button #1
- 9: thumb button #2
- 10: top button
Mouse resolution changers do not generate an input.
Automatic swap
Let’s change button order only while running the game. Create two script files. You can name them to whatever you want. Save them to some directory.
thumb-middle-button.sh:
mouse-button-restore.sh:
Set them as executable:
Add them to Steam game launch options with this line:
Above line assumes you saved them to scripts-directory. %command% comes from Steam and launches the game. $HOME means your home directory and usually adds /home/yourname/ to the path.
Additional info
Actually you can bind mouse buttons to keys with xbindkeys and xte. It’s quite easy, works with most applications but some games like Metro LL seem to work differently.
For example, you can use thumb button #2 to run xte with xbindkeys:
Alas, this input won’t register on Metro LL. However, it may work in other games.
As changing all of the mouse buttons to actually work in Metro LL is non-trivial and may lead to non-working setups, I’ll just add some links here and you may decide if you want to try it (you have been warned:-). Also you might want to check out if evrouter works for you (it’s not packaged with Ubuntu).
[link] [link] [link]