XkbSetDeviceButtonActions(3)

πŸ’… XkbSetDeviceButtonActions(3)

okay so bestie, we're in the XKB FUNCTIONS section of the manual β€” yes, that XKB, the X KeyBoard extension, and this one is called XkbSetDeviceButtonActions. the way this function is so specific and so cute: it changes only the button actions for an input extension device. nothing else. not the whole device, just the button actions. main character energy fr fr πŸŽ€


✨ NAME ✨

XkbSetDeviceButtonActions β€” change only the button actions for an input extension device πŸ¦‹


✨ SYNOPSIS ✨

Bool XkbSetDeviceButtonActions (Display *dpy, XkbDeviceInfoPtr device,
       unsigned int first_button, unsigned int num_buttons);

✨ ARGUMENTS ✨

  • dpy β€” your connection to the X server, obvs πŸ’–
  • device β€” the structure that defines the device and the modifications you want to make to it
  • first_button β€” the number of the first button to update, and yes it's 0 relative (zero-based, bestie, we start counting at zero here)
  • num_buttons β€” how many buttons you wanna update

✨ DESCRIPTION ✨

so here's the tea β˜• XkbSetDeviceButtonActions assigns actions to the buttons of the device specified in device_info->device_spec. it grabs the actions from device_info->btn_acts and hands them out to num_buttons buttons, starting at first_button. slay. πŸ’…

but like β€” vibe check first, okay? if the server does not support assignment of Xkb actions to extension device buttons, then XkbSetDeviceButtonActions has no effect and returns False. not me getting rejected by the server 😭

same deal if the device has no buttons at all, or if first_button or num_buttons point at buttons outside the valid range as determined by device_info->num_btns β€” the function has no effect and returns False. ngl, nothing happens, no notes. πŸ’€

otherwise?? oh we're so back πŸ¦‹ XkbSetDeviceButtonActions sends a request to the server to change the actions for the specified buttons and returns True. periodt. πŸ”₯

and now the dramatic part, the warnings, listen up πŸ‘‘:

  • if the actual request sent to the server involved illegal button numbers, a BadValue protocol error is generated.
  • if an invalid device identifier is specified in device_info->device_spec, a BadKeyboard protocol error results.
  • if the actual device specified in device_info->device_spec does not contain buttons and a request affecting buttons is made, a BadMatch protocol error is generated.
lowkey these errors are giving "read the docs before you send the request" πŸ™ˆ

✨ DIAGNOSTICS ✨

  • BadKeyboard β€” the device specified was not a valid core or input extension device πŸ’€
  • BadMatch β€” a compatible version of Xkb was not available in the server, or an argument has the correct type and range but is otherwise invalid 😭
  • BadValue β€” an argument is out of range 🚩

and that's the whole page bestie, you ate that 🫢 this iconic lil number comes to you from X Version 11, shipping with libX11 1.8.14 β€” go forth and set those button actions, mwah πŸ’œβœ¨πŸŒΈ

πŸ“¦ where this page comes from