2

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?

goocreations
  • 2,938
  • 8
  • 37
  • 59

1 Answers1

1

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.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • Ahh, thanks, somehow missed that function. I'll dig into the code. Do you by any chance have a link to an example that uses this to disable a device? I found a couple of examples, but none of them properly explain the parameters or illustrate how to enable/disable devices. If not, I'll just go through the code in the xinput program. – goocreations Oct 03 '14 at 12:22
  • Nope, I rarely program X11 directly so I don't have anything. I'm more of a GTK+ beard. :) The `xinput` source was short, you should easily be able to figure it out. Don't forget the documentation, either. – unwind Oct 03 '14 at 12:23
  • Thanks. I'll do that. – goocreations Oct 03 '14 at 12:31
  • As a addition, ltrace command would be very useful to debug xinput and find what is executed when you enable/disable a mouse. – RaFD Oct 03 '14 at 17:01