XGETDEVICEMODIFIERMA(3)
π XGetDeviceModifierMapping, XSetDeviceModifierMapping β the manual page (section 3) π
okay bestie, sit down, grab a boba, because today we're talking about device modifier mappings β and yes it's exactly as iconic as it sounds π
β¨ NAME β¨
XGetDeviceModifierMapping, XSetDeviceModifierMapping β query or change device modifier mappings. that's it, that's the whole vibe π¦
β¨ SYNOPSIS β¨
#include <X11/extensions/XInput.h>
int XSetDeviceModifierMapping( Display *display,
XDevice *device,
XModifierKeymap *modmap);
XModifierKeymap *XGetDeviceModifierMapping( Display *display,
XDevice *device);
so like, the arguments, let me introduce you:
displayβ the connection to the X server. your lil hotline to the server, fr fr πdeviceβ the device whose modifier mapping is gonna get queried or modified. yes, that device πmodmapβ a pointer to theXModifierKeymapstructure. just a pointer, bestie, it's giving "I know a guy" π
β¨ DESCRIPTION β¨
okay so the XSetDeviceModifierMapping request specifies the KeyCodes of the keys (if any, no pressure) that are to be used as modifiers for the specified device. if it succeeds, the X server generates a DeviceMappingNotify event, and XSetDeviceModifierMapping returns MappingSuccess. slay π
X permits at most eight modifier keys. if more than eight are specified in the XModifierKeymap structure, a BadLength error results. eight is the limit, babe, that's the ceiling, periodt π«
the modifiermap member of the XModifierKeymap structure contains eight sets of max_keypermod KeyCodes, one for each modifier in the order Shift, Lock, Control, Mod1, Mod2, Mod3, Mod4, and Mod5. memorize that order, it's giving choreography π
only nonzero KeyCodes have meaning in each set, and zero KeyCodes are ignored (they're just there, existing, minding their business π). in addition, all of the nonzero KeyCodes must be in the range specified by min_keycode and max_keycode as returned by XListInputDevices, or a BadValue error results. no KeyCode may appear twice in the entire map, or a BadValue error results. no duplicates, bestie, this is not a group chat, everyone gets one seat π
an X server can impose restrictions on how modifiers can be changed β for example, if certain keys do not generate up transitions in hardware, if auto-repeat cannot be disabled on certain keys, or if multiple modifier keys are not supported. if some such restriction is violated, the status reply is MappingFailed, and none of the modifiers are changed. if the new KeyCodes specified for a modifier differ from those currently defined and any (current or new) keys for that modifier are in the logically down state, XSetDeviceModifierMapping returns MappingBusy, and none of the modifiers is changed. so basically: it's all or nothing, no halfsies, no crumbs π
XSetDeviceModifierMapping can generate BadLength, BadDevice, BadMatch, BadAlloc, and BadValue errors.
πΈ Structures πΈ
the XGetDeviceModifierMapping request returns a pointer to a newly created XModifierKeymap structure that contains the keys being used as modifiers. that structure should be freed after use by calling XFreeModifierMapping β yes bestie, you have to clean up after yourself, it's called being a responsible main character π§
if only zero values appear in the set for any modifier, that modifier is disabled. it's not broken, it's just not participating π
XGetDeviceModifierMapping can generate BadDevice and BadMatch errors.
the XModifierKeymap structure contains:
typedef struct {
int max_keypermod;
KeyCode *modifiermap;
} XModifierKeymap;
β¨ DIAGNOSTICS β¨
the receipts, the errors, the "what went wrong" section π
BadLengthβ more than eight keys were specified in theXModifierKeymapstructure. bestie you were told eight. EIGHT. π¨BadAllocβ the server failed to allocate the requested resource or server memory. the server is going through it, give it a sec π«Ά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. so like, wrong device, or a device that's literally the core keyboard/pointer and doesn't play that game π ββοΈBadMatchβ this error may occur if anXGetDeviceModifierMappingorXChangeDeviceModifierMappingrequest was made specifying a device that has no keys. no keys?? on a keyboard request?? it's giving empty vibes πBadValueβ some numeric value falls outside the range of values accepted by the request. unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. any argument defined as a set of alternatives can generate this error. basically: out of bounds, off the map, not on the guest list π
β¨ SEE ALSO β¨
XSetDeviceKeyMapping(3)XSetDeviceButtonMapping(3)
go read those next, bestie, they're lowkey part of the same cinematic universe π
okay that's the whole page!! sending you so much love from the XGetDeviceModifierMapping(3) manual, this was version dated 05/18/2026 β go forth and map your modifiers correctly, ily, bye πβ¨π
π¦ 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