XGETDEVICECONTROL(3)
π XGETDEVICECONTROL π
okay bestie, sit down, hydrate, because today we're learning about XGetDeviceControl and XChangeDeviceControl β the iconic duo that lets you query and change input device controls. yes, that's the whole name, we're not being mysterious. it's giving "ask the device a question, then tell it what to do" and honestly? slay. π
β¨ SYNOPSIS β¨
#include <X11/extensions/XInput.h>
XDeviceControl *XGetDeviceControl( Display *display,
XDevice *device,
int *controlType);
int XChangeDeviceControl( Display *display,
XDevice *device,
int controlType,
XDeviceControl *control);
now the little arguments, one by one, no skipping (i would never) πΈ
displayβ the connection to the X server. your lil phone line to the server, basically.deviceβ the device whose control is getting interrogated or modified. yes, interrogated. it did nothing wrong but here we are πcontrolTypeβ the type of control being interrogated or changed.controlβ the address of anXDeviceControlstructure holding the new values for the Device.
π DESCRIPTION π
so these requests exist to manipulate those input devices that support device control. and here's the tea: a BadMatch error gets generated if the device you're asking about does not support any device controls. so rude of it, but okay.
the valid device control types that play nice with these requests are:
DEVICE_RESOLUTIONβ queries or changes the resolution of valuators on input devices. that's the one, that's the list, periodt. β¨
the XGetDeviceControl request returns a pointer to an XDeviceControl structure. and heads up β XGetDeviceControl can generate a BadDevice or BadMatch error. π
the XChangeDeviceControl request modifies the values of one control on the specified device. that control is identified by the id field of the XDeviceControl structure that you pass along with the request. iykyk.
and XChangeDeviceControl can generate a BadDevice, BadMatch, or BadValue error. three whole errors, main character energy fr fr.
π§ STRUCTURES π§
every control is described by a structure that's specific to that control, and these structures are defined in the file XInput.h. no cap.
XDeviceControl is a generic structure β it holds two fields that sit at the beginning of each class of control:
typedef struct {
XID class;
int length;
} XDeviceControl;
the XDeviceResolutionState structure defines the information returned for device resolution, for devices with valuators:
typedef struct {
XID control;
int length;
int num_valuators;
int* resolutions;
int* min_resolutions;
int* max_resolutions;
} XDeviceResolutionState;
and the XDeviceResolutionControl structure defines the attributes that can be controlled for keyboard Devices:
typedef struct {
XID control;
int length;
int first_valuator;
int num_valuators;
int* resolutions;
} XDeviceResolutionControl;
π DIAGNOSTICS π
BadDeviceβ an invalid device was specified. the specified device doesn't exist, or it hasn't been opened by this client viaXOpenInputDevice. this error may also happen if some other client has caused the specified device to become the X keyboard or X pointer device via theXChangeKeyboardDeviceorXChangePointerDevicerequests. (so basically, someone else stole your device and now you're in your flop era. π)BadMatchβ this error may occur if anXGetDeviceControlrequest was made specifying a device that has no controls, or if anXChangeDeviceControlrequest was made with anXDeviceControlstructure that contains an invalid Device type. it may also occur if an invalid combination of mask bits is specified (DvKeybut noDvAutoRepeatModefor keyboard Devices), or if an invalidKeySymis specified for a string Device. πBadValueβ some numeric value falls outside the range of values accepted by theXChangeDeviceControlrequest. unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. and any argument defined as a set of alternatives can generate this error. watch those numbers bestie, the server is NOT flexible.
fr fr reminder: BadMatch can pop off just from the device not supporting controls at all β always vibe check before you send the request. π
okay that's the whole page, you ate that, i'm obsessed. π«Ά this was pulled from the XGetDeviceControl(3) page, dated 05/18/2026 β go forth and control your devices, but like, consensually. bye bestie!! πβ¨
π¦ where this page comes from
- fedora 44: libXi-devel 1.8.3-1.fc44 Β· MIT-open-group AND SMLNJ AND MIT
- fedora 44: libXi-devel 1.8.3-1.fc44 Β· MIT-open-group AND SMLNJ AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms