XQueryKeymap() XQueryKeymap()
Name
XQueryKeymap - obtain a bit vector for the current state of the keyboard.
Synopsis
XQueryKeymap(display, keys_return)
Display *display;
char keys_return[32];
Arguments
display Specifies a connection to an X server; returned from XOpenDisplay().
keys_return
Returns an array of bytes that identifies which keys are pressed down. Each bit represents one key of the keyboard.
Description
XQueryKeymap() returns a bit vector for the logical state of the keyboard, where each bit set to 1 indicates that the corresponding key is
currently pressed down. The vector is represented as 32 bytes. Byte N (from 0) contains the bits for keys 8N to 8N+7 with the least sig-
nificant bit in the byte representing key 8N. Note that the logical state may lag the physical state if device event processing is frozen
due to a grab.
See Also
XChangeKeyboardMapping(), XDeleteModifiermapEntry(), XFreeModifiermap(), XGetKeyboardMapping(), XGetModifierMapping(), XInsertModi-
fiermapEntry(), XKeycodeToKeysym(), XKeysymToKeycode(), XKeysymToString(), XLookupKeysym(), XLookupString(), XNewModifiermap(), XRebind-
Keysym(), XRefreshKeyboardMapping(), XSetModifierMapping(), XStringToKeysym().
Xlib - Keyboard XQueryKeymap()
Check Out this Related Man Page
XLookupString() XLookupString()
Name
XLookupString - map a key event to ASCII string, keysym, and ComposeStatus.
Synopsis
int XLookupString(event_structure, buffer_return, bytes_buffer, keysym_return,
status_in_out)
XKeyEvent *event_structure;
char *buffer_return;
int bytes_buffer;
KeySym *keysym_return;
XComposeStatus *status_in_out; /* may not be implemented */
Arguments
event_structure
Specifies the key event to be used.
buffer_return
Returns the resulting string (not NULL-terminated). Returned value of the function is the length of the string.
bytes_buffer
Specifies the length of the buffer. No more than bytes_buffer of translation are returned.
keysym_return
If this argument is not NULL, it specifies the keysym ID computed from the event.
status_in_out
Specifies the XComposeStatus structure that contains compose key state information and that allows the compose key processing to
take place. This can be NULL if the caller is not interested in seeing compose key sequences. Not implemented in X Consortium
Xlib through Release 5.
Returns
Length of string in buffer_return argument.
Description
XLookupString() gets an ASCII string and a keysym that are currently mapped to the keycode in a KeyPress or KeyRelease event, using the
modifier bits in the key event to deal with shift, lock and control. The XLookupString() return value is the length of the translated
string and the string's bytes are copied into buffer_return. The length may be greater than 1 if the event's keycode translates into a
keysym that was rebound with XRebindKeysym().
Note that the string returned in buffer is not NULL-terminated. If you need a NULL-terminated string, copy buffer into another string as
follows:
len = XLookupString((XKeyEvent *)event, buffer, 10, nil, nil);
if (len)
(void) strncat (cmd_buf, buffer, len);
The compose status.in.out is not implemented in any release of the X Consortium version of Xlib through Release 5.
In Release 4, XLookupString() implements the new concept of keyboard groups. Keyboard groups support having two complete sets of keysyms
for a keyboard. Which set will be used can be toggled using a particular key. This is implemented by using the first two keysyms in the
list for a key as one set, and the next two keysyms as the second set. For more information on keyboard groups, see Volume One, Appendix
G, Release Notes.
For more information on using XLookupString() in general, see Volume One, Chapter 9, The Keyboard and Pointer.
Structures
/*
* Compose sequence status.in.out structure, used in calling XLookupString.
*/
typedef struct _XComposeStatus {
char *compose_ptr; /* state table pointer */
int chars_matched; /* match state */
} XComposeStatus;
typedef struct {
int type; /* of event */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window window; /* "event" window it is reported relative to */
Window root; /* root window that the event occured on */
Window subwindow; /* child window */
Time time; /* milliseconds */
int x, y; /* pointer x, y coordinates in event window */
int x_root, y_root; /* coordinates relative to root */
unsigned int state; /* key or button mask */
unsigned int keycode; /* detail */
Bool same_screen; /* same screen flag */
} XKeyEvent;
See Also
XChangeKeyboardMapping(), XDeleteModifiermapEntry(), XFreeModifiermap(), XGetKeyboardMapping(), XGetModifierMapping(), XInsertModi-
fiermapEntry(), XKeycodeToKeysym(), XKeysymToKeycode(), XKeysymToString(), XLookupKeysym(), XNewModifiermap(), XQueryKeymap(), XRebind-
Keysym(), XRefreshKeyboardMapping(), XSetModifierMapping(), XStringToKeysym().
Xlib - Keyboard XLookupString()