1c27c18e8SmrgXIQUERYDEVICE(libmansuffix) 2c27c18e8Smrg============================ 3c27c18e8Smrg 4c27c18e8SmrgNAME 5c27c18e8Smrg---- 6c27c18e8Smrg 7c27c18e8Smrg XIQueryDevice, XIFreeDeviceInfo - get information about devices. 8c27c18e8Smrg 9c27c18e8SmrgSYNOPSIS 10c27c18e8Smrg-------- 11c27c18e8Smrg 12c27c18e8Smrg #include <X11/extensions/XInput2.h> 13c27c18e8Smrg 1437eb1ca1Smrg XIDeviceInfo* XIQueryDevice( Display *display, 1537eb1ca1Smrg int deviceid, 1637eb1ca1Smrg int *ndevices_return); 17c27c18e8Smrg 18c27c18e8Smrg XIFreeDeviceInfo( XIDeviceInfo *info); 19c27c18e8Smrg 20c27c18e8Smrg deviceid 21c27c18e8Smrg Specifies the device to query or XIAllDevices or 22c27c18e8Smrg XIAllMasterDevices. 23c27c18e8Smrg 24c27c18e8Smrg display 25c27c18e8Smrg Specifies the connection to the X server. 26c27c18e8Smrg 27c27c18e8Smrg ndevices_return 28c27c18e8Smrg Returns the number of devices returned. 29c27c18e8Smrg 30c27c18e8Smrg info 31c27c18e8Smrg A list of device XIDeviceInfo structs to be freed. 32c27c18e8Smrg 33c27c18e8Smrg 34c27c18e8SmrgDESCRIPTION 35c27c18e8Smrg----------- 36c27c18e8Smrg 37c27c18e8Smrg The XIQueryDevice returns information about one or more input 38c27c18e8Smrg devices. If the deviceid specifies a device, ndevices_return is 39c27c18e8Smrg 1 and the returned information describes only the requested 40c27c18e8Smrg device. If deviceid is XIAllDevices or XIAllMasterDevices, 41c27c18e8Smrg ndevices_return is the number of devices or master devices, 42c27c18e8Smrg respectively, and the returned information represents all 43c27c18e8Smrg devices or all master devices, respectively. 44c27c18e8Smrg 45c27c18e8Smrg To free the XIDeviceInfo array returned by XIQueryDevice, use 46c27c18e8Smrg XIFreeDeviceInfo. 47c27c18e8Smrg 48c27c18e8Smrg For each input device requested, the XIQueryDevice returns an 49c27c18e8Smrg XIDeviceInfo structure. Each structure contains information 50c27c18e8Smrg about the capabilities of one input device available to the 51c27c18e8Smrg server. 52c27c18e8Smrg 53c27c18e8Smrg typedef struct 54c27c18e8Smrg { 55c27c18e8Smrg int deviceid; 56c27c18e8Smrg char *name; 57c27c18e8Smrg int use; 58c27c18e8Smrg int attachment; 59c27c18e8Smrg Bool enabled; 60c27c18e8Smrg int num_classes; 61c27c18e8Smrg XIAnyClassInfo **classes; 62c27c18e8Smrg } XIDeviceInfo; 63c27c18e8Smrg 64c27c18e8Smrg The deviceid is the numeric unique id of the device. A deviceid 65c27c18e8Smrg is unique for the life-time of a device but a server may re-use 66c27c18e8Smrg the id once a device has been removed. 67c27c18e8Smrg 68c27c18e8Smrg The name points to a null-terminated string specifying the 69c27c18e8Smrg identifier of the device. 70c27c18e8Smrg 71c27c18e8Smrg The use and attachment fields specify the type of the device 72c27c18e8Smrg and the current attachment or pairing. 73c27c18e8Smrg - If use is XIMasterPointer, the device is a master pointer and 74c27c18e8Smrg attachment specifies the deviceid of the paired master 75c27c18e8Smrg keyboard. 76c27c18e8Smrg - If use is XIMasterKeyboard, the device is a master keyboard, 77c27c18e8Smrg and the attachment field specifies the paired master pointer. 78c27c18e8Smrg - If use is XISlavePointer, the device is a slave device and 79c27c18e8Smrg currently attached to the master pointer specified in 8087404ef7Smrg attachment. 81c27c18e8Smrg - If use is XISlaveKeyboard, the device is a slave device an 82c27c18e8Smrg currently attached to the master keyboard specified in 83c27c18e8Smrg attachment. 84c27c18e8Smrg - If use is XIFloatingSlave, the device is a slave device 85c27c18e8Smrg currently not attached to any master device. The value of the 86c27c18e8Smrg attachment field for floating slave devices is undefined. 87c27c18e8Smrg 88c27c18e8Smrg The enabled field specifies if the device is currently enabled 89c27c18e8Smrg and can send events. Disabled devices will not send events. 90c27c18e8Smrg 91c27c18e8Smrg The num_classes field specifies the number of input classes 92c27c18e8Smrg pointed to by classes. The first two fields of all input 93c27c18e8Smrg classes are identical. 94c27c18e8Smrg 95c27c18e8Smrg typedef struct 96c27c18e8Smrg { 97c27c18e8Smrg int type; 98c27c18e8Smrg int sourceid; 99c27c18e8Smrg } XIAnyClassInfo; 100c27c18e8Smrg 101c27c18e8Smrg The type field specifies the type of the input class. 102c27c18e8Smrg Currently, the following types are defined: 103f1ee322dSmrg XIKeyClass, XIButtonClass, XIValuatorClass, XIScrollClass, 10487404ef7Smrg XITouchClass, XIGestureClass. 105c27c18e8Smrg 106c27c18e8Smrg In the future, additional types may be added. Clients are 107c27c18e8Smrg required to ignore unknown input classes. 108c27c18e8Smrg 109c27c18e8Smrg The sourceid is the deviceid this class originated from. For 110c27c18e8Smrg master devices, the sourceid is typically the id of the slave 111c27c18e8Smrg device currently sending events. For slave devices, the 112c27c18e8Smrg sourceid is typically the device's id. 113c27c18e8Smrg 114c27c18e8Smrg A device may have zero or one XIButtonClass, denoting the 115c27c18e8Smrg device's capability to send button events. 116c27c18e8Smrg 117c27c18e8Smrg typedef struct { 118c27c18e8Smrg int mask_len; 119c27c18e8Smrg unsigned char *mask; 120c27c18e8Smrg } XIButtonState; 121c27c18e8Smrg 122c27c18e8Smrg typedef struct 123c27c18e8Smrg { 124c27c18e8Smrg int type; 125c27c18e8Smrg int sourceid; 126c27c18e8Smrg int num_buttons; 127c27c18e8Smrg Atom *labels; 128c27c18e8Smrg XIButtonState state; 129c27c18e8Smrg } XIButtonClassInfo; 130c27c18e8Smrg 131c27c18e8Smrg The num_buttons field specifies the number of buttons available 132c27c18e8Smrg on this device. A device that has an XIButtonClass must have at 133c27c18e8Smrg least one button. 134c27c18e8Smrg 135c27c18e8Smrg labels is a list of num_buttons Atoms specifying the button 136c27c18e8Smrg labels for this device. If the label is not None, then the 137c27c18e8Smrg label specifies the type of button in physical device order 138c27c18e8Smrg (i.e. as the buttons are numbered on the physical input 139c27c18e8Smrg device). 140c27c18e8Smrg 141c27c18e8Smrg The state is the current button state as seen by clients (i.e. 142c27c18e8Smrg after button mapping is applied). The mask_len field specifies 143c27c18e8Smrg the length of mask in bytes. For each button on the device, the 144c27c18e8Smrg respective bit in mask is set if the button is currently 145c27c18e8Smrg logically down. 146c27c18e8Smrg 147c27c18e8Smrg A device may have zero or one XIKeyClass, denoting the device's 148c27c18e8Smrg capability to send key events. 149c27c18e8Smrg 150c27c18e8Smrg typedef struct 151c27c18e8Smrg { 152c27c18e8Smrg int type; 153c27c18e8Smrg int sourceid; 154c27c18e8Smrg int num_keycodes; 155c27c18e8Smrg int *keycodes; 156c27c18e8Smrg } XIKeyClassInfo; 157c27c18e8Smrg 158c27c18e8Smrg The num_keycodes field specifies the number of keycodes 159c27c18e8Smrg available on this device. A device that has an XIKeyClass must 160c27c18e8Smrg have at least one keycode. 161c27c18e8Smrg 162c27c18e8Smrg keycodes is a list of num_keycodes keycodes the device may 163c27c18e8Smrg send. 164c27c18e8Smrg 165c27c18e8Smrg A device may have zero or more XIValuatorClass, denoting the 166c27c18e8Smrg device's capability to send coordinates. 167c27c18e8Smrg 168c27c18e8Smrg typedef struct 169c27c18e8Smrg { 170c27c18e8Smrg int type; 171c27c18e8Smrg int sourceid; 172c27c18e8Smrg int number; 173c27c18e8Smrg Atom label; 174c27c18e8Smrg double min; 175c27c18e8Smrg double max; 176c27c18e8Smrg double value; 177c27c18e8Smrg int resolution; 178c27c18e8Smrg int mode; 179f1ee322dSmrg } XIValuatorClassInfo; 180c27c18e8Smrg 181c27c18e8Smrg The number field specifies the number of the axis on the 182c27c18e8Smrg physical device. 183c27c18e8Smrg 184c27c18e8Smrg If the label field is not None, the value of label is an Atom 185c27c18e8Smrg describing the axis. 186c27c18e8Smrg 187c27c18e8Smrg min and max are the minimum and maximum values allowed on this 18887404ef7Smrg axis. If both are zero, no minimum or maximum values are set on 189c27c18e8Smrg this device. value is the current value of this axis. 190c27c18e8Smrg 191c27c18e8Smrg The resolution field specifies the resolution of the device in 192c27c18e8Smrg units/m. 193c27c18e8Smrg 194c27c18e8Smrg The mode specifies the mode of this axis. If the mode is 195c27c18e8Smrg XIModeAbsolute this axis sends absolute coordinates. If the 196c27c18e8Smrg mode is XIModeRelative, this device sends relative coordinates. 197c27c18e8Smrg 198f1ee322dSmrg typedef struct 199f1ee322dSmrg { 200f1ee322dSmrg int type; 201f1ee322dSmrg int sourceid; 202f1ee322dSmrg int number; 203f1ee322dSmrg int scroll_type; 204f1ee322dSmrg double increment; 205f1ee322dSmrg int flags; 206f1ee322dSmrg } XIScrollClassInfo; 207f1ee322dSmrg 208f1ee322dSmrg This class describes scrolling capability on a valuator. For 209f1ee322dSmrg each XIScrollClassInfo, an XIValuatorClassInfo with the same 210f1ee322dSmrg number is present on the device. 211f1ee322dSmrg 212f1ee322dSmrg The number field specifies the valuator number on the physical 213f1ee322dSmrg device that this scroll information applies to. See the 214f1ee322dSmrg respective XIValuatorClassInfo for detailed information on this 215f1ee322dSmrg valuator. 216f1ee322dSmrg 217f1ee322dSmrg The scroll_type field specifies the type of scrolling, either 218f1ee322dSmrg XIScrollTypeVertical or XIScrollTypeHorizontal. 219f1ee322dSmrg 220f1ee322dSmrg The increment specifies the value change considered one unit of 221f1ee322dSmrg scrolling down. 222f1ee322dSmrg 223f1ee322dSmrg The flags field specifies flags that apply to this scrolling 224f1ee322dSmrg information: 225f1ee322dSmrg 226f1ee322dSmrg If XIScrollFlagNoEmulation is set, the server will not 227f1ee322dSmrg emulate legacy button events for valuator changes on this 228f1ee322dSmrg valuator. 229f1ee322dSmrg 230f1ee322dSmrg If XIScrollFlagPreferred is set, this axis is the 231f1ee322dSmrg preferred axis for this scroll type and will be used for 232f1ee322dSmrg the emulation of XI_Motion events when the driver submits 233f1ee322dSmrg legacy scroll button events. 234f1ee322dSmrg 235f1ee322dSmrg typedef struct 236f1ee322dSmrg { 237f1ee322dSmrg int type; 238f1ee322dSmrg int sourceid; 239f1ee322dSmrg int mode; 240f1ee322dSmrg int num_touches; 241f1ee322dSmrg } XITouchClassInfo; 242f1ee322dSmrg 243f1ee322dSmrg A device may have zero or one XITouchClassInfo, denoting 244f1ee322dSmrg multi-touch capability on the device. A device with a XITouchClassInfo 245f1ee322dSmrg may send TouchBegin, TouchUpdate, TouchEnd and TouchOwnership events. 246f1ee322dSmrg 247f1ee322dSmrg The mode field is either XIDirectTouch for direct-input touch devices 248f1ee322dSmrg such as touchscreens or XIDependentTouch for indirect input devices such 249f1ee322dSmrg as touchpads. For XIDirectTouch devices, touch events are sent to window 25087404ef7Smrg at the position the touch occurred. For XIDependentTouch devices, touch 251f1ee322dSmrg events are sent to the window at the position of the device's sprite. 252f1ee322dSmrg 253f1ee322dSmrg The num_touches field defines the maximum number of simultaneous touches 254f1ee322dSmrg the device supports. A num_touches of 0 means the maximum number of 255f1ee322dSmrg simultaneous touches is undefined or unspecified. This field should be 256f1ee322dSmrg used as a guide only, devices will lie about their capabilities. 257f1ee322dSmrg 258f1ee322dSmrg A device with an XITouchClassInfo may still send pointer events. The 259f1ee322dSmrg valuators must be defined with the respective XIValuatorClass 260f1ee322dSmrg classes. A valuator may send both pointer and touch-events. 261f1ee322dSmrg 26287404ef7Smrg typedef struct 26387404ef7Smrg { 26487404ef7Smrg int type; 26587404ef7Smrg int sourceid; 26687404ef7Smrg int num_touches; 26787404ef7Smrg } XIGestureClassInfo; 26887404ef7Smrg 26987404ef7Smrg A device may have zero or one XIGestureClassInfo, denoting 27087404ef7Smrg touchpad gesture capability on the device. A device with a XIGestureClassInfo 27187404ef7Smrg may send GestureSwipeBegin, GestureSwipeUpdate, GestureSwipeEnd, 27287404ef7Smrg GesturePinchBegin, GesturePinchUpdate, GesturePinchEnd. 27387404ef7Smrg 27487404ef7Smrg The num_touches field defines the maximum number of simultaneous touches 27587404ef7Smrg the device supports. A num_touches of 0 means the maximum number of 27687404ef7Smrg simultaneous touches is undefined or unspecified. This field should be 27787404ef7Smrg used as a guide only, devices will lie about their capabilities. 27887404ef7Smrg 279c27c18e8Smrg XIQueryDevice can generate a BadDevice error. 280c27c18e8Smrg 281c27c18e8Smrg XIFreeDeviceInfo frees the information returned by 282c27c18e8Smrg XIQueryDevice. 283c27c18e8Smrg 284c27c18e8SmrgDIAGNOSTICS 285c27c18e8Smrg----------- 286c27c18e8Smrg 287c27c18e8Smrg BadDevice 288c27c18e8Smrg An invalid device was specified. The device does not 289c27c18e8Smrg exist or is not a pointer device. 290c27c18e8Smrg 291