It seems the Linux guys have come up with evdev, a universal interface to mouse drivers.
For more information on evdev, refer to the Gentoo wiki page here.
On the FreeBSD side, it's also very simple, to set up both the synpatics touchpad of my Dell Inspiron 600m, and my Microsoft IntelliMouse Optical.
Synaptics touchpad is supported thru /dev/psm0, and can be easily enabled by putting moused_enable="YES" into /etc/rc.conf.
After making this change, a moused process will be taking care of your touchpad.
Another moused process will start when you plug in a USB mouse.
Below is a typical section to go into /etc/X11/xorg.conf:
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/sysmouse"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons"
EndSection
Besides the basic three buttons, the IntelliMouse Optical has two more buttons, which are defined as button 8 and 9 according to the xev output.
After knowing their codes, we can assign them to any functions we want, as described here.
The idea is to use xbindkeys to bind keys to programs, and to use xvkbd to send virtual keys.
For example, I want the fourth button to send Ctrl-C and the fifth button to send Ctrl-V.
I had the following lines in my ~/.xbindkeysrc:
"xvkbd -text "\Cc""
b:8
"xvkbd -text "\Cv""
b:9
Of course do not forget to make xbindkeys auto-start with X.
UPDATE: keytouch is a solution to complex keyboard shortcuts. I'll have to check it out.