[Xorg] XInput Hotplug Additions

Kristian Høgsberg krh at bitplanet.net
Mon Aug 2 17:10:36 PDT 2004


Hi,

I've been doing some work on the XInput hotplug functionality that was 
discussed on this list some weeks ago.  I have put a patch in bugzilla, 
http://freedesktop.org/bugzilla/show_bug.cgi?id=971.  At this point, 
I've added two requests to XInput:

	extern int      XAddInputDevice(
	    Display*            /* display */,
	    _Xconst char*       /* name */,
	    _Xconst char*       /* driver */,
	    XDeviceOption*      /* options */,
	    int                 /* nOptions */
	);
 

	extern int      XRemoveInputDevice(
	    Display*            /* display */,
	    _Xconst char*       /* name */
	);

with

	typedef struct {
	    char *name;
	    char *value;
	} XDeviceOption;
 

The idea is that the arguments given to XAddInputDevice() corresponds to 
the options you can give in an xorg.conf InputDevice section, e.g.

	Section "InputDevice"
	        Identifier  "Mouse0"
	        Driver      "mouse"
	        Option      "Protocol" "IMPS/2"
	        Option      "Device" "/dev/input/mice"
	        Option      "ZAxisMapping" "4 5"
	EndSection

could be configured at runtime from an X client as

	XDeviceOption options[] = {
	  { "Protocol", "IMPS/2" },
	  { "Device", "/dev/input/mice" },
	  { "ZAxisMapping", "4 5" },
	};

	XAddInputDevice(dpy, "Mouse0", "mouse", options, 3);

Which will load the "mouse" driver if it's not already present, and add 
the device "Mouse0".

When a new device is added, a DevicePresenceNotify event is sent to 
interested clients.  The event does not contain any information about 
the change, clients should use XListInputDevices() to find out what 
devices are available.

I've also attached a tar-file with a few sample applications: xadddev 
and xrmdev are commandline utils to add and remove input devices, 
get-event demonstrates how to select the DevicePresenceNotify event and 
finally, input-daemon, which is a simple example of how a daemon could 
listen for system hotplug events using HAL and add and remove input 
devices accordingly.

I think it would be cool if we could have this or similar functionality 
in the next release again (i.e. not the one scheduled for August).  At 
the  moment I guess people are busy with the upcoming release, but I 
would greatly appreciate comments and feedback on this stuff.

Kristian



More information about the xorg mailing list