XGETDEVICEPROPERTY(3)
π XGETDEVICEPROPERTY(3) π
okay bestie, sit down, hydrate, because today we're learning about device properties in XInput β the XGetDeviceProperty, XChangeDeviceProperty and XDeleteDeviceProperty trio. this is from the XGETDEVICEPROPERTY(3) manual page, and yes we are reading all of it. no skimming. periodt. β¨
πΈ NAME πΈ
XGetDeviceProperty, XChangeDeviceProperty, XDeleteDeviceProperty β get, change, or delete a device's property. that's it, that's the whole vibe: read it, write it, yeet it π
β¨ SYNOPSIS β¨
first, you gotta pull in the header, like so:
#include <X11/extensions/XInput.h>
then here's the three besties in all their glory:
int XGetDeviceProperty( Display *display,
XDevice *device,
Atom property,
long offset,
long length,
Bool delete,
Atom req_type,
Atom *actual_type_return,
int *actual_format_return,
unsigned long *nitems_return,
unsigned long *bytes_after_return,
unsigned char **prop_return)
void XChangeDeviceProperty( Display *display,
XDevice *device,
Atom property,
Atom type,
int format,
int mode,
const unsigned char *data,
int nelements)
void XDeleteDeviceProperty( Display *display,
XDevice *device,
Atom property)
π the arguments, explained with love π
actual_type_returnβ hands you back an atom identifier that defines the actual type of the property. it's giving "surprise, here's what it really is" πactual_format_returnβ returns the actual format of the property. not the format you asked for, the format you got. character development fr fr.bytes_after_returnβ returns how many bytes are still left to read in the property, but only if a partial read happened. the leftovers, basically πdataβ specifies the property data. the actual goods.deleteβ specifies a Boolean value that determines whether the property is deleted. yes, this one is literally calleddelete. iconic naming, no notes.displayβ specifies the connection to the X server. your link to the mothership π₯deviceβ the device to grab. (yes, even though we're not grabbing, the manpage says grab. we respect the manpage.)formatβ specifies whether the data should be viewed as a list of 8-bit, 16-bit, or 32-bit quantities. possible values are8,16, and32. this info is what lets the X server correctly do byte-swap operations when it needs to. β οΈ and heads up: if the format is 16-bit or 32-bit, you must explicitly cast the data pointer to an(unsigned char*)in the call toXChangeDeviceProperty. no skipping that cast, bestie, that's a "trust me" moment πlengthβ specifies the length, in 32-bit multiplies, of the data to be retrieved.modeβ specifies the mode of operation. you can passPropModeReplace,PropModePrepend, orPropModeAppend. replace, prepend, or append β pick your fighter β¨nelementsβ specifies the number of elements indata.nitems_returnβ returns the actual number of 8-bit, 16-bit, or 32-bit items stored in theprop_returnarray.num_valuesβ specifies the number of elements in the values list. (she's here. she's in the list. we include her. π)offsetβ specifies the offset in the specified property (in 32-bit quantities) where the data is to be retrieved. like a little bookmark in the middle of the property πpropertyβ specifies the property to modify or query.prop_returnβ returns the data in the specified format. here's the breakdown so you don't get jumpscared:- if the returned format is
8, the returned data is represented as achararray. - if the returned format is
16, the returned data is represented as an array ofshort inttype and should be cast to that type to obtain the elements. - if the returned format is
32, the property data will be stored as an array oflongs β which, in a 64-bit application, will be 64-bit values that are padded in the upper 4 bytes. yes really. we don't make the rules π
- if the returned format is
req_typeβ specifies the atom identifier associated with the property type, orAnyPropertyType. "any" as in, you're not picky, you'll take what you get π
π¦ DESCRIPTION π¦
so, XGetDeviceProperty β she returns the actual type of the property, the actual format of the property, the number of 8-bit, 16-bit, or 32-bit items transferred, the number of bytes remaining to be read in the property, and a pointer to the data actually returned. five things, one call. multitasking queen. for a detailed description of this function, see the man page to XGetWindowProperty.
then XChangeDeviceProperty β she alters the property for the specified device, and causes the server to generate a XPropertyNotifyEvent event on that device. π£ she's loud, she's noticed, she makes the server send an event. for a detailed description of this function, see the man page to XChangeProperty.
and XDeleteDeviceProperty β she deletes the specified device property. ποΈ but listen: a client cannot delete a property created by a driver or the server. attempting to do so will result in a BadAtom error. so if you try to delete someone else's property, you get a BadAtom in your face. don't do it. it's not your property to delete, bestie π
now the error tea, per function:
XGetDevicePropertycan generate aBadAtom,BadDeviceerror.XChangeDevicePropertycan generate aBadDevice, aBadMatch, aBadAtom, and aBadValueerror.XDeleteDevicePropertycan generate aBadDevice, and aBadAtomerror.
π DIAGNOSIS π
these are the errors and what they actually mean:
BadAtomβ a value does not describe a valid named identifier, or the client attempted to remove a driver-allocated property. (yeah. that second one. that's the one we warned you about. π« )BadDeviceβ an invalid device was specified. the device does not exist. she's not there. she was never there. π
π SEE ALSO π
go read that one next, it's the natural sequel β¨
and that's the whole page, bestie!! this was XGETDEVICEPROPERTY(3), dated 05/18/2026, and the manual page itself lives under the name XGETDEVICEPROPERTY(3). mwah. π go forth and query your devices responsibly. ππ¦πΈ
π¦ 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