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 the XModifierKeymap structure. 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 the XModifierKeymap structure. 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 via XOpenInputDevice. 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 an XGetDeviceModifierMapping or XChangeDeviceModifierMapping request 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 ✨

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