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