XQUERYDEVICESTATE(3)
π XQUERYDEVICESTATE π
okay bestie, gather round, because we're reading the XQUERYDEVICESTATE(3) page together and honestly? it's giving "short and powerful". this one is literally about querying the state of an extension input device. so like, "what's my keyboard doing right now", "is that button pressed", "where's the valuator at". obsessed. β¨
β¨ NAME β¨
XQueryDeviceState β query the state of an extension input device. π
πΈ SYNOPSIS πΈ
#include <X11/extensions/XInput.h>
XDeviceState* XQueryDeviceState( Display *display,
XDevice *device);
displayβ bestie, this is the connection to the X server. that's it, that's the whole thing.deviceβ the device whose state we're about to go snooping on. π
π¦ DESCRIPTION π¦
so the XQueryDeviceState request queries the state of an input device. the current state of keys and buttons (up or down, no in-between, we love a binary) and valuators (their current value) on the device gets reported by this request. π
every key or button is represented by a bit in the XDeviceState structure that gets returned. and the valuators on the device report 0 if they're reporting relative information, and the current value if they're reporting absolute information. periodt.
XQueryDeviceState can generate a BadDevice error. (more on that below, don't panic π«Ά)
Structures π§
the XDeviceState structure contains:
typedef struct {
XID device_id;
int num_classes;
XInputClass *data;
} XDeviceState;
the XValuatorState structure contains:
typedef struct {
unsigned char class;
unsigned char length;
unsigned char num_valuators;
unsigned char mode;
int *valuators;
} XValuatorState;
the XKeyState structure contains:
typedef struct {
unsigned char class;
unsigned char length;
short num_keys;
char keys[32];
} XKeyState;
the XButtonState structure contains:
typedef struct {
unsigned char class;
unsigned char length;
short num_buttons;
char buttons[32];
} XButtonState;
π DIAGNOSTICS π
BadDeviceβ an invalid device was specified π. the specified device does not exist, or it has not been opened by this client viaXOpenInputDevice. this error may also occur if some other client has caused the specified device to become the X keyboard or X pointer device via theXChangeKeyboardDeviceorXChangePointerDevicerequests. so basically, somebody else snatched it. rude. π
lowkey the whole vibe of this page is "ask the device how it's feeling, get structs back". no cap.
and that's the tea, bestie π this was XQUERYDEVICESTATE(3), dated 05/18/2026 β main character energy from start to finish, slay πβ¨π
π¦ 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