In Windows, there is a Win32 system call SwapMouseButton to swap the primary button of the mouse. Now, I need such system call or way to swap mouse button on Linux and MacOS.
By this, I want to make one-click mouse button swapping application.
How would you do this in C?
I don’t think there is a system call to do this. The mouse is operated by the X system, not by the kernel.
You can run this shell command
xmodmap -e "pointer = 3 2 1"to swap the left and right buttons, and runxmodmap -e "pointer = 1 2 3"to restore the original settings..You can also use
execveto execute the above command from C.EDIT
The
systemfunction is actually more easy to use: