1XOpenDevice(3) X FUNCTIONS XOpenDevice(3)
2
3
4
6 XOpenDevice, XCloseDevice - open or close an extension input device
7
9 XDevice *XOpenDevice(Display *display, XID device_id);
10
11 XCloseDevice(Display *display, XDevice *device);
12
13
15 display Specifies the connection to the X server.
16
17 device_id Specifies the id of the device to be opened
18
19 device Specifies the device to be closed
20
22 The XOpenDevice request makes an input device accessible to a client
23 through input extension protocol requests. If successful, it returns a
24 pointer to an XDevice structure.
25
26 The XCloseDevice request makes an input device inaccessible to a client
27 through input extension protocol requests. Before terminating, and
28 client that has opened input devices through the input extension should
29 close them via CloseDevice.
30
31 When a client makes an XCloseDevice request, any active grabs that the
32 client has on the device are released. Any event selections that the
33 client has are deleted, as well as any passive grabs. If the request‐
34 ing client is the last client accessing the device, the server may dis‐
35 able all access by X to the device.
36
37 XOpenDevice and XCloseDevice can generate a BadDevice error.
38
40 The XDevice structure returned by XOpenDevice contains:
41 typedef struct {
42 XID device_id;
43 int num_classes;
44 XInputClassInfo *classes;
45 } XDevice;
46
47 The classes field is a pointer to an array of XInputClassInfo struc‐
48 tures. Each element of this array contains an event type base for a
49 class of input supported by the specified device. The num_classes
50 field indicates the number of elements in the classes array.
51
52 The XInputClassInfo structure contains:
53
54 typedef struct {
55 unsigned char input_class;
56 unsigned char event_type_base;
57 } XInputClassInfo;
58
59 The input_class field identifies one class of input supported by the
60 device. Defined types include KeyClass, ButtonClass, ValuatorClass,
61 ProximityClass, FeedbackClass, FocusClass, and OtherClass. The
62 event_type_base identifies the event type of the first event in that
63 class.
64
65 The information contained in the XInputClassInfo structure is used by
66 macros to obtain the event classes that clients use in making XSe‐
67 lectExtensionEvent requests. Currently defined macros include
68 DeviceKeyPress, DeviceKeyRelease, DeviceButtonPress, DeviceButtonRe‐
69 lese, DeviceMotionNotify, DeviceFocusIn, DeviceFocusOut, ProximityIn,
70 ProximityOut, DeviceStateNotify, DeviceMappiingNotify, ChangeDeviceNo‐
71 tify, DevicePointerMotionHint, DeviceButton1Motion, DeviceBut‐
72 ton2Motion, DeviceButton3Motion, DeviceButton4Motion, DeviceBut‐
73 ton5Motion, DeviceButtonMotion, DeviceOwnerGrabButton, DeviceButton‐
74 PressGrab, and NoExtensionEvent.
75
76 To obtain the proper event class for a particular device, one of the
77 above macros is invoked using the XDevice structure for that device.
78 For example,
79
80 DeviceKeyPress (*device, type, eventclass);
81
82 returns the DeviceKeyPress event type and the eventclass for DeviceKey‐
83 Press events from the specified device.
84
85 This eventclass can then be used in an XSelectExtensionEvent request to
86 ask the server to send DeviceKeyPress events from this device. When a
87 selected event is received via XNextEvent, the type can be used for
88 comparison with the type in the event.
89
91 BadDevice An invalid device was specified. The specified device does
92 not exist, or is the X keyboard or X pointer. This error
93 may also occur if some other client has caused the speci‐
94 fied device to become the X keyboard or X pointer device
95 via the XChangeKeyboardDevice or XChangePointerDevice
96 requests.
97
99 Programming with Xlib
100
101
102
103X Version 11 libXi 1.1.1 XOpenDevice(3)