I figured out how to do this.
First use xev to find out the "button numbers". Type xev in the terminal, and click on the buttons of your mouse in the newly opened white window. Many lines appear in the terminal, such as these:
ButtonPress event, serial 36, synthetic NO, window 0x3c00001,
root 0x15d, subw 0x3c00002, time 10181966, (30,51), root:(1208,104),
state 0x10, button 1, same_screen YES
The "button 1" is the number, in my case, for left-click.
I wanted to switch left scroll with middle button, which were 6 and 2 respectively.
The next step is to learn the id of the input device:
Mine had such an entry for the Logitech mouse:
Logitech Unifying Device. Wireless PID:101d id=10 [slave pointer (2)]
Then, I type the following to map button 2 to 6, and vice versa, for the input device with id 10:
xinput set-button-map 10 1 6 3 4 5 2 7
This is only going to be temporary, and be gone when you reboot.
To make it permanent, you could edit the xorg.conf file, but doing so caused problems for me, and the system did not boot. Instead, I created an entry in startup applications, writing the last xinput command as the command.
This has one drawback -- the id has to stay the same. However, I do not know when and why it changes, as mine seem to stay the same. If I was to guess, I'd say that plugging the usb receiver in another usb port could change the id. I am not sure.