This page is out of date and its content is provided for historic reasons only. Some of the features below is superfluous, others have been implemented already. This is not a guide to the future of input development.
This page is intended as a place to evolve the design specifications for the next version of the XINPUT for the X.org server. This includes a long needed update to the XINPUT specification to improve support for better device controls, hotplugging, and multiple core devices. This page focuses on the XInput protocol. The implementation in the XOrg server should be documented in XOrgInputDriverSpec.
First, an important question: Should the XInput improvements all be part of XInput 2.0? XInput includes several commands that resemble a general purpose interface to extension events. Furthermore, many of the needed improvements for managing and configuring input devices are applicable to output devices, including something as substantial as a hot-pluggable PCMCIA video card.
So, in addition to the much-needed update to the XInput protocol, should there also be another extension called (perhaps) XDevice, that defines all of the runtime device configuration and management issues that are not part of the existing XInput?
Or, should we just extend XInput, and not worry that it is really applicable to more than just input devices, despite the name? This is already true for XInput because Feedback events are a form of output. (In a way, a graphical display is just a very elaborate central Feedback device.) Besides, HID is similarly misnamed.
The HID design is a verbose and inflexible, rather than a simple but extensible design. This does not really fit the overall X design concept very well, so it does not make sense to incorporate the actual HID spec into X. However, most modern input devices are designed around HID, so XInput should attempt to be HID compatible. In otherwords, XInput should be able to include device and control attributes that correspond to HID names, but these should all conveyed by name rather than using all of the HID enum values.
One useful aspect of HID is Device and Control Usages. XInput has some support for Device Usage by including a type Atom in the XDeviceInfo structure, although it has not been adequately implemented. It is reasonable to define the standard type Atoms with the corresponding HID Usage names, which already include several common type names typically used in X, such as Pointer, Keyboard, Joystick.
Individual controls do not have a similar type identifier, but one should be incorporated into the various control Info structures. Each info structure includes a length value. That means it is possible to extend these structures and keep backwards compatibility. The extended structures should also include additional details about each control. For example, buttons can be described as momentary or toggle switches.
Rather than trying to define a few additional specific properties, it is probably best to support a variable number of parameter+value pairs for each device and each control. This allows for extensibility, and can work similar to Window properties.
Device event handling has important security implications. Currently, security is handled with global Display access, and temporary Device Grabs. With the possibility of multiple input devices, multiple servers, and even multiple users on the same Display, event access control needs to be more explicit. So, devices need security attributes, which probably need to be implemented in a similar way for explicit access to/from individual windows.
A straightforward method of implementing extensible and diverse device properties is to provide each device with a set of properties that is accessible in a manner similar to Window properties. This allows for a variety of data formats and sizes, and would use the existing Window Property infrastructure. Device Properties can relay all of the information about input usages, advanced pointer-acceleration curves, etc.
This function is important, but drastically incomplete. The Device Property interface could probably work as a complete replacement for these functions, but it is useful to have separate interface for active commands that affect the hardware. However, note that the single defined device control, DEVICE_RESOLUTION, is more of a property than a hardware command.
Rather than adding a new data structure for each new control type, it is better to use an approach similar to window properties, except that control data is interpreted rather than simply being saved in a database.
Some undecided issues:
This approach is completely compatible with the existing XInput protocol, but is not really using the control type argument as originally intended, and adds unnecessary complexity.
There should be a formal mechanism for multiple Pointer and Keyboard devices capable of sending core events. Question: how will these functions interoperate with XChangePointerDevice and XChangeKeyboardDevice? Should X retain the concept of a single "primary" mouse and keyboard, and have the new functions enable/disable devices to emit core events in addition to the core devices? Or, should the old functions be considered obsolete and just have them always return BadDevice? Any other ideas?
This function assumes that devices can only emit relative or absolute events for all clients listening to the device. This probably should not be true for any device. Therefore, it may be reasonable to always return BadMode, which is the proper response for devices not supporting XSetDeviceMode requests.
The problem is that no other mechanism is defined to select relative versus absolute events. Therefore, it would probably be necessary to add RelativeMotionNotify and AbsoluteMotionNotify event types. It may also be acceptable to use the existing MotionNotify to handle Absolute events, which are more common. On the other hand, a new Absolute event type would also add an opportunity to support fractional motion events.
Absolute events should also be better defined. Most drivers are pointer oriented, and consider absolute motion events to mean screen coordinates, rather than device coordinates. Perhaps Absolute events should always be in device coordinates, and only be converted to screen coordinates for core pointer events. Note that MotionEvents also send x_root and y_root, so clients will always get pointer coordinates.
There are also some problems with the definition of Absolute versus Relative events. Many input devices send control data that is intended to be used for relative motion, even though the device state is actually an absolute position. For example, a centering joystick is intended to direct relative motion, but a non-centering joystick is accurately represented by an absolute position. Consider how you would would want to use these two joystick types to direct pointer motion. Although the control state is absolute in both cases, the data for the centering joystick should (arguably) be defined as Relative data, partly because the derivative is fairly useless but integrating from Relative to Absolute could be useful.
A device driver can be automatically associated with a device, depending on the device type, or otherwise controlled at the OS level. However, it may be useful to allow some client control, especially if more than one driver can handle the same device.
Get a list of available device drivers; information format not yet defined. It is probably useful to include information about supported hardware, but that can be quite complex. Perhaps just a list of driver names and versions is sufficient.
Just an idea for now: Should it be possible to add/remove drivers in a running server? If so, should it be managed by a formal X event, or should this be managed simply by adding or removing driver binaries from the module directory?
These functions add or remove a device instance from the server. These are similar to the internal dix functions AddInputDevice() and RemoveDevice().
In the current server design, a newly added device but uninitialized device is in the off_devices
list, and not available in XListInputDevices(). Before the device is initialized and made available to clients, it needs to be configured, presumably by the client that sent the request to add the device. Here are possibilities for handling the initial configuration.
The off_devices
list may be considered an obsolete feature when proper hotplugging is implemented. However, there are a few cases where it may still be useful. First, if a device fails initialization, it remains in the off_devices
list. The list could be used to give devices another opportunity to attempt initialization. Secondly, if a device is opened by a client, but the hardware becomes unavailable, it may be useful to keep the off_devices
instance around until all clients have closed the device.
How does one get a list of the "off devices"? XListInputDevices() has no option flags, so the current design would best handle this by listing all devices, and defining an DeviceInfo.use=IsOffline type.
These functions move a device from/to the off_devices list, and succeed depending on the result from the drivers response to DEVICE_INIT and DEVICE_CLOSE.
The XEvent structure was designed with a fixed size to simplify memory management. Events are passed to the client by passing an entire XEvent structure, rather than passing an event pointer. This limits possibilities for defining Event types with larger data sizes.
One approach for handling large event types would be to include a data pointer in the XEvent structure. The extended data can be automatically freed by Xlib upon the next event retrieval.
The ClassInfo
structures include a length element, which means that extending existing structures can be backwards compatible. The XDeviceInfo structure does not have a length field, so changes will be incompatible. However, a much more versatile approach to extended device properties is to support property attributes similar to window properties, and to leave much of the current data structures unchanged.
A new event is added to XInput to notify clients that the device list has changed.
The event structure could be similar to XChangeDeviceNotifyEvent, where the XID is identifies the lost or gained device. This would require an event for each lost or gained device, but could be useful for clients that only want to monitor the status of one device.
typedef struct {
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window; /* Root Window, or unused ? */
XID deviceid; /* ID of new or lost device */
Time time;
int state; /* DeviceNew, DeviceLost. Maybe also: DeviceEnabled, DeviceDisabled? */
} XDeviceListChangeEvent;
One possible solution for generalizing Device Controls. This uses existing XInput functions, with a generic, extensible control type:
typedef struct {
XID control = DEVICE_CONFIGURE;
int length = sizeof(XDeviceConfigureControl);
Atom name;
int format;
unsigned char *value;
int length;
} XDeviceConfigureControl;
This is a listing of generalized device properties to consider. These would be available via a DeviceControl function that returns a string given a parameter named by a string or associated Atom.
It may be good to always include numeric product and vendor ID's, to avoid ambiguities for cases where names are unknown, or have changed. Should these be a separate field, or grouped with the text name? In addition to user name, devices should probably include support for security (authentication, access-control) features.
The following HID properties are not so useful for XClients, but might be needed for devices calibration, which should probably be handled by the X Client Input Device Manager:
Non-linear input should probably be converted to linear at the server level. Acceleration is probably best handled by the server, with all devices set for linear output, in order to provide uniform acceleration parameters for all devices. (Q: Are there cases where acceleration at the device level is really an advantage?)