XkbGetDeviceInfo(3)

πŸ’… XkbGetDeviceInfo(3) β€” from the XKB FUNCTIONS manual ✨

okay so bestie, sit down, because this one is a chef's kiss little function from the XKB FUNCTIONS section and it's about to make you feel so smart πŸŽ€

🌸 NAME 🌸

XkbGetDeviceInfo β€” the icon that figures out whether the X server even lets Xkb touch particular capabilities of input devices other than the core X keyboard, or checks the vibe (status, if we're being technical πŸ’€) of indicator maps, indicator names, or button actions on a non-KeyClass extension device. no cap.

✨ SYNOPSIS ✨

XkbDeviceInfoPtr XkbGetDeviceInfo (Display *dpy, unsigned int which,
       unsigned int device_spec, unsigned int ind_class, unsigned int
       ind_id);

🫢 ARGUMENTS 🫢

  • dpy β€” your connection to the X server, bestie. the whole lifeline.
  • which β€” a mask saying which info you want back. inclusive OR energy only πŸ’…
  • device_spec β€” the device ID, or XkbUseCoreKbd if you're feeling basic (lovingly).
  • ind_class β€” the feedback class, for when you're asking about indicators.
  • ind_id β€” the feedback ID, same deal β€” indicator requests only.

πŸ’– DESCRIPTION πŸ’–

So the whole point: to determine whether the X server allows Xkb access to particular capabilities of input devices other than the core X keyboard, or to determine the status of indicator maps, indicator names, or button actions on a non-KeyClass extension device β€” you call XkbGetDeviceInfo. that's the move. periodt.

XkbGetDeviceInfo returns information about the input device specified by device_spec. And here's the slay: unlike the device_spec parameter of most Xkb functions, device_spec does not need to be a keyboard device. it does, however, have to indicate either the core keyboard or a valid X Input Extension device. no random devices, bestie, we have standards 🌈

The which parameter is a mask specifying optional information to be returned. It's an inclusive OR of one or more of the values from Table 1, and it makes the returned XkbDeviceInfoRec contain values for the corresponding fields specified in the table. iykyk.

πŸ¦‹ Table 1 β€” XkbDeviceInfoRec Mask Bits πŸ¦‹

okay this is the big one, don't skip it, it's literally the whole personality of the function:

  • XkbXI_KeyboardsMask
    • XkbDeviceInfoRec fields effected: (none listed)
    • Value: (1L <<0)
    • Capability if set: Clients can use all Xkb requests and events with KeyClass devices supported by the input device extension.
  • XkbXI_ButtonActionsMask
    • XkbDeviceInfoRec fields effected: num_btns, btn_acts
    • Value: (1L <<1)
    • Capability if set: Clients can assign key actions to buttons non-KeyClass input extension devices.
  • XkbXI_IndicatorNamesMask
    • XkbDeviceInfoRec fields effected: leds->names
    • Value: (1L <<2)
    • Capability if set: Clients can assign names to indicators on non-KeyClass input extension devices.
  • XkbXI_IndicatorMapsMask
    • XkbDeviceInfoRec fields effected: leds->maps
    • Value: (1L <<3)
    • Capability if set: Clients can assign indicator maps to indicators on non-KeyClass input extension devices.
  • XkbXI_IndicatorStateMask
    • XkbDeviceInfoRec fields effected: leds->state
    • Value: (1L <<4)
    • Capability if set: Clients can request the status of indicators on non-KeyClass input extension devices.
  • XkbXI_IndicatorsMask
    • XkbDeviceInfoRec fields effected: sz_leds, num_leds, leds->*
    • Value: (0x1c)
    • Capability if set: XkbXI_IndicatorNamesMask | XkbXI_IndicatorMapsMask | XkbXI_IndicatorStateMask
  • XkbXI_UnsupportedFeaturesMask
    • XkbDeviceInfoRec fields effected: unsupported
    • Value: (1L <<15)
    • Capability if set: (nothing listed)
  • XkbXI_AllDeviceFeaturesMask
    • XkbDeviceInfoRec fields effected: Those selected by Value Column masks
    • Value: (0x1e)
    • Capability if set: XkbXI_IndicatorsMask | XkbSI_ButtonActionsMask
  • XkbXI_AllFeaturesMask
    • XkbDeviceInfoRec fields effected: Those selected by Value Column masks
    • Value: (0x1f)
    • Capability if set: XkbSI_AllDeviceFeaturesMask | XkbSI_KeyboardsMask
  • XkbXI_AllDetailsMask
    • XkbDeviceInfoRec fields effected: Those selected by Value column masks
    • Value: (0x801f)
    • Capability if set: XkbXI_AllFeaturesMask | XkbXI_UnsupportedFeaturesMask

The XkbDeviceInfoRec returned by XkbGetDeviceInfo always has values for name (may be a null string, ""), type, supported, unsupported, has_own_state, dflt_kbd_fd, and dflt_kbd_fb. Everything else gets filled in as specified by which. main character fields only 😌

Upon return, the supported field will be set to the inclusive OR of zero or more bits from Table 1. each bit that's set means an optional Xkb extension device feature is supported by the server implementation, and a client may modify the associated behavior. slay.

If the XkbButtonActionsMask bit is set in which, the XkbDeviceInfoRec returned will have the button actions (btn_acts field) filled in for all buttons. all of them. no crumbs.

If which includes one of the bits in XkbXI_IndicatorsMask, the feedback class of the indicators must be specified in ind_class, and the feedback ID of the indicators must be specified in ind_id. and if the request does not include any of the bits in XkbXI_IndicatorsMask, then ind_class and ind_id are just ignored (ghosted, honestly πŸ™ˆ). You can grab the class and ID via the input device extension XListInputDevices request.

If any of the XkbXI_IndicatorsMask bits are set in which, the XkbDeviceInfoRec returned will have filled in the portions of the leds structure corresponding to the indicator feedback identified by ind_class and ind_id. The leds vector of the XkbDeviceInfoRec is allocated if necessary, and sz_leds and num_leds get filled in. The led_class, led_id, and phys_indicators fields of the leds entry corresponding to ind_class and ind_id are always filled in. Then:

  • If which contains XkbXI_IndicatorNamesMask, the names_present and names fields of the leds structure corresponding to ind_class and ind_id are returned. πŸ’–
  • If which contains XkbXI_IndicatorStateMask, the corresponding state field is updated.
  • If which contains XkbXI_IndicatorMapsMask, the maps_present and maps fields are updated.

Xkb also provides convenience functions to request subsets of the information available via XkbGetDeviceInfo. These convenience functions mirror some of the mask bits. They all take an XkbDeviceInfoPtr as an input argument and operate on the X Input Extension device specified by the device_spec field of the structure. Only the parts of the structure indicated in the function description are updated. And the XkbDeviceInfoRec structure used in the function call can be obtained by calling XkbGetDeviceInfo, or can be allocated by calling XkbAllocDeviceInfo. either way, valid. 🫢

🧚 STRUCTURES 🧚

Information about X Input Extension devices is transferred between a client program and the Xkb extension in an XkbDeviceInfoRec structure. here she is in all her glory πŸ‘‘

typedef struct {
    char *               name;          /* name for device */
    Atom                 type;          /* name for class of devices */
    unsigned short       device_spec;   /* device of interest */
    Bool                 has_own_state; /* True=>this device has its own state */
    unsigned short       supported;     /* bits indicating supported capabilities */
    unsigned short       unsupported;   /* bits indicating unsupported capabilities */
    unsigned short       num_btns;      /* number of entries in btn_acts */
    XkbAction *          btn_acts;      /* button actions */
    unsigned short       sz_leds;       /* total number of entries in LEDs vector */
    unsigned short       num_leds;      /* number of valid entries in LEDs vector */
    unsigned short       dflt_kbd_fb;   /* input extension ID of default (core kbd) indicator */
    unsigned short       dflt_led_fb;   /* input extension ID of default indicator feedback */
    XkbDeviceLedInfoPtr  leds;          /* LED descriptions */
} XkbDeviceInfoRec, *XkbDeviceInfoPtr;

🌈 SEE ALSO 🌈


bestie reminder: supported and unsupported are literally telling you what the server can and can't do β€” don't go modifying behavior on a bit that isn't set, or it's giving undefined chaos πŸ’€

okay that's the whole page, you ate it up, I'm so proud πŸ“πŸ’œ

β€” signed off with love: X Version 11, from libX11 1.8.14, and yes, this whole thing is literally XkbGetDeviceInfo(3) πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from