XGetDeviceKeyMapping(), XChangeDeviceKeyMapping() - query or change device key mappings
XChangeDeviceKeyMapping (Display *display, XDevice *device,
int first_keycode, int keysyms_per_keycode,
KeySym *keysyms, int keycode_count,
KeySym *XGetDeviceKeyMapping (Display *display, XDevice *device,
KeyCode first_keycode,
int keycode_count,
int *keysyms_per_keycode_return )
For the specified device, the XGetDeviceKeyMapping(3) request returns the symbols for the specified number of KeyCodes starting with first_keycode. The value specified in first_keycode must be greater than or equal to min_keycode as returned by XListInputDevices(3), or a BadValue error results. In addition, the following expression must be less than or equal to max_keycode as returned by XListInputDevices(3):
first_keycode + keycode_count - 1
If this is not the case, a BadValue error results. The number of elements in the KeySyms list is:
keycode_count * keysyms_per_keycode_return
KeySym number N, counting from zero, for KeyCode K has the following index in the list, counting from zero: (K - first_code) * keysyms_per_code_return + N
The X server arbitrarily chooses the keysyms_per_keycode_return value to be large enough to report all requested symbols. A special KeySym value of NoSymbol is used to fill in unused elements for individual KeyCodes. To free the storage returned by XGetDeviceKeyMapping(3), use XFree(3).
If the specified device does not support input class keys, a BadMatch error will result.
XGetDeviceKeyMapping(3) can generate a BadDevice, BadMatch, or BadValue error.
For the specified device, the XChangeDeviceKeyMapping(3) request defines the symbols for the specified number of KeyCodes starting with first_keycode. The symbols for KeyCodes outside this range remain unchanged. The number of elements in keysyms must be:
num_codes * keysyms_per_keycode
The specified first_keycode must be greater than or equal to min_keycode returned by XListInputDevices(3), or a BadValue error results. In addition, the following expression must be less than or equal to max_keycode as returned by XListInputDevices(3), or a BadValue error results:
first_keycode + num_codes - 1
KeySym number N, counting from zero, for KeyCode K has the following index in keysyms, counting from zero:
(K - first_keycode) * keysyms_per_keycode + N
The specified keysyms_per_keycode can be chosen arbitrarily by the client to be large enough to hold all desired symbols. A special KeySym value of NoSymbol should be used to fill in unused elements for individual KeyCodes. It is legal for NoSymbol to appear in nontrailing positions of the effective list for a KeyCode. XChangeDeviceKeyMapping(3) generates a DeviceMappingNotify event that is sent to all clients that have selected that type of event.
There is no requirement that the X server interpret this mapping. It is merely stored for reading and writing by clients.
If the specified device does not support input class keys, a BadMatch error results.
XChangeDeviceKeyMapping(3) can generate a BadDevice, BadMatch, BadAlloc, or BadValue error.
Programming With Xlib