XGETDEVICEMOTIONEVEN(3)
π NAME π
XGetDeviceMotionEvents, XDeviceTimeCoord β bestie, this is how you pull up the motion history of a device. Like a little replay reel of where it's been. π¦
β¨ SYNOPSIS β¨
#include <X11/extensions/XInput.h>
XDeviceTimeCoord *XGetDeviceMotionEvents( Display *display,
XDevice *device,
Time start,
Time stop,
int *nevents_return,
int *mode_return,
int *axis_count_return);
π the arguments, one by one π
displayβ the connection to the X server. your lil phone line to the server, basically. πdeviceβ the device whose motion history you're tryna look up. yes that one. πstart,stopβ the time interval you want the events handed back from the motion history buffer. you can pass an actual timestamp orCurrentTime. so flexible, love that for you. β°nevents_returnβ comes back with the number of events from the motion history buffer. it's giving "here's your count, queen." π’mode_returnβ comes back with the mode of the device (AbsoluteorRelative). pick a lane, device. πaxis_count_returnβ comes back with the count of axes being reported. axes are having a moment. π
πΈ DESCRIPTION πΈ
okay so. the server may keep a recent history of the device motion, and when it does, it keeps it at a finer granularity than what DeviceMotionNotify events report. no cap. the XGetDeviceMotionEvents request is literally just how you get at that history. β¨
The XGetDeviceMotionEvents request returns all events in the motion history buffer that fall between the specified start and stop times, inclusive. π«Ά
If thestarttime is later than thestoptime, or if thestarttime is in the future β no events are returned. nothing. nada. empty. π
If thestoptime is in the future, it's equivalent to specifyingCurrentTime. cute lil shortcut.
The mode tells you whether the device is reporting absolute positional data (mode = Absolute) or relative motion data (mode = Relative). Some devices let you change their mode via the XSetDeviceMode request β main character energy, honestly. These constants are defined in the file XI.h. The axis_count gives you the number of axes or valuators being reported by the device. π
XGetDeviceMotionEvents can generate a BadDevice, or BadMatch error. π
π§ Structures π§
The XDeviceTimeCoord structure contains:
typedef struct {
Time time;
int *data;
} XDeviceTimeCoord;
The time member is set to the time, in milliseconds. β The data member is a pointer to an array of integers. These integers are set to the values of each valuator or axis reported by the device. There is one element in the array per axis of motion reported by the device. π«
The value of the array elements depends on the mode of the device:
- If the mode is
Absolute, the values are the raw values generated by the device. These may be scaled by client programs using the maximum values that the device can generate. The maximum value for each axis of the device is reported in themax_valfield of theXAxisInforeturned by theXListInputDevicesrequest. π - If the mode is
Relative, the data values are the relative values generated by the device. π
You should use XFreeDeviceMotionEvents to free the data returned by this request. don't forget or it's lowkey a leak bestie π
Errors returned by this request: BadDevice, BadMatch. periodt.
π DIAGNOSTICS π
BadDeviceβ an invalid device was specified. The specified device does not exist or has not been opened by this client viaXOpenInputDevice. This error may also occur if the specified device is the X keyboard or X pointer device. not those two, bestie, they're built different. π«BadMatchβ this error may occur if anXGetDeviceMotionEventsrequest is made specifying a device that has no valuators and reports no axes of motion. it's giving nothing to report. π
and that's the whole page!! this came out of the XGETDEVICEMOTIONEVEN(3) manual, dated 05/18/2026, so if anyone asks where you got your info, that's the receipts. stay iconic, go read some more manpages, mwah πβ¨π
π¦ 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