Search code examples
clinuxmousex11xinput

C/C++: Disable mouse in Linux (X11 - xinput)


I want to programmatically enable and disable the mouse in Linux using C/C++. There is the input extension for X11 that allows you to do it using the terminal command:

xinput set-int-prop "<device name>" "Device Enabled" 8 0

This works perfectly, but I'm looking to do this directly using a library. I can't find any proper documentation on libxi (X11 input extension library) and the header files in /usr/include/X11 also don't provide any useful functions. Can anyone help me with this?


Solution

  • You do realize that xinput is open source, right? :) Here's the source tree.

    It seems to boil down to a call to XIChangeProperty().

    You can probably read the code a bit more closely than I did, and the manual page of course, to figure out the required arguments.