For Windows, there's very useful software: EitherMouse by Steffen Software:
http://www.eithermouse.com/
GitHub project page:Leave multiple mice on a pc and automatically swap buttons on each mouse.
Have a left-handed and a right-handed mouse always connected and ready to use.
Match speeds across different mice, ie touchpad and mouse with different speeds.
https://github.com/gwarble/EitherMouse
AHK forum tread:
https://www.autohotkey.com/boards/viewtopic.php?t=3648