libxkbcommon 1.7.0
|
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <xkbcommon/xkbcommon-names.h>
#include <xkbcommon/xkbcommon-keysyms.h>
#include <xkbcommon/xkbcommon-compat.h>
Data Structures | |
struct | xkb_rule_names |
Macros | |
#define | XKB_KEYCODE_INVALID (0xffffffff) |
#define | XKB_LAYOUT_INVALID (0xffffffff) |
#define | XKB_LEVEL_INVALID (0xffffffff) |
#define | XKB_MOD_INVALID (0xffffffff) |
#define | XKB_LED_INVALID (0xffffffff) |
#define | XKB_KEYCODE_MAX (0xffffffff - 1) |
#define | XKB_KEYSYM_MAX 0x1fffffff |
#define | xkb_keycode_is_legal_ext(key) (key <= XKB_KEYCODE_MAX) |
#define | xkb_keycode_is_legal_x11(key) (key >= 8 && key <= 255) |
#define | XKB_KEYMAP_USE_ORIGINAL_FORMAT ((enum xkb_keymap_format) -1) |
Typedefs | |
typedef uint32_t | xkb_keycode_t |
typedef uint32_t | xkb_keysym_t |
typedef uint32_t | xkb_layout_index_t |
typedef uint32_t | xkb_layout_mask_t |
typedef uint32_t | xkb_level_index_t |
typedef uint32_t | xkb_mod_index_t |
typedef uint32_t | xkb_mod_mask_t |
typedef uint32_t | xkb_led_index_t |
typedef uint32_t | xkb_led_mask_t |
Functions | |
int | xkb_keysym_get_name (xkb_keysym_t keysym, char *buffer, size_t size) |
xkb_keysym_t | xkb_keysym_from_name (const char *name, enum xkb_keysym_flags flags) |
int | xkb_keysym_to_utf8 (xkb_keysym_t keysym, char *buffer, size_t size) |
uint32_t | xkb_keysym_to_utf32 (xkb_keysym_t keysym) |
xkb_keysym_t | xkb_utf32_to_keysym (uint32_t ucs) |
xkb_keysym_t | xkb_keysym_to_upper (xkb_keysym_t ks) |
xkb_keysym_t | xkb_keysym_to_lower (xkb_keysym_t ks) |
Main libxkbcommon API.
#define xkb_keycode_is_legal_ext | ( | key | ) | (key <= XKB_KEYCODE_MAX) |
Test whether a value is a valid extended keycode.
#define xkb_keycode_is_legal_x11 | ( | key | ) | (key >= 8 && key <= 255) |
Test whether a value is a valid X11 keycode.
typedef uint32_t xkb_keycode_t |
A number used to represent a physical key on a keyboard.
A standard PC-compatible keyboard might have 102 keys. An appropriate keymap would assign each of them a keycode, by which the user should refer to the key throughout the library.
Historically, the X11 protocol, and consequentially the XKB protocol, assign only 8 bits for keycodes. This limits the number of different keys that can be used simultaneously in a single keymap to 256 (disregarding other limitations). This library does not share this limit; keycodes beyond 255 ('extended keycodes') are not treated specially. Keymaps and applications which are compatible with X11 should not use these keycodes.
The values of specific keycodes are determined by the keymap and the underlying input system. For example, with an X11-compatible keymap and Linux evdev scan codes (see linux/input.h), a fixed offset is used:
The keymap defines a canonical name for each key, plus possible aliases. Historically, the XKB protocol restricts these names to at most 4 (ASCII) characters, but this library does not share this limit.
typedef uint32_t xkb_layout_index_t |
Index of a keyboard layout.
The layout index is a state component which detemines which keyboard layout is active. These may be different alphabets, different key arrangements, etc.
Layout indices are consecutive. The first layout has index 0.
Each layout is not required to have a name, and the names are not guaranteed to be unique (though they are usually provided and unique). Therefore, it is not safe to use the name as a unique identifier for a layout. Layout names are case-sensitive.
Layout names are specified in the layout's definition, for example "English (US)". These are different from the (conventionally) short names which are used to locate the layout, for example "us" or "us(intl)". These names are not present in a compiled keymap.
If the user selects layouts from a list generated from the XKB registry (using libxkbregistry or directly), and this metadata is needed later on, it is recommended to store it along with the keymap.
Layouts are also called "groups" by XKB.
typedef uint32_t xkb_level_index_t |
Index of a shift level.
Any key, in any layout, can have several shift levels. Each shift level can assign different keysyms to the key. The shift level to use is chosen according to the current keyboard state; for example, if no keys are pressed, the first level may be used; if the Left Shift key is pressed, the second; if Num Lock is pressed, the third; and many such combinations are possible (see xkb_mod_index_t).
Level indices are consecutive. The first level has index 0.
typedef uint32_t xkb_mod_index_t |
Index of a modifier.
A modifier is a state component which changes the way keys are interpreted. A keymap defines a set of modifiers, such as Alt, Shift, Num Lock or Meta, and specifies which keys may activate which modifiers (in a many-to-many relationship, i.e. a key can activate several modifiers, and a modifier may be activated by several keys. Different keymaps do this differently).
When retrieving the keysyms for a key, the active modifier set is consulted; this detemines the correct shift level to use within the currently active layout (see xkb_level_index_t).
Modifier indices are consecutive. The first modifier has index 0.
Each modifier must have a name, and the names are unique. Therefore, it is safe to use the name as a unique identifier for a modifier. The names of some common modifiers are provided in the xkbcommon/xkbcommon-names.h header file. Modifier names are case-sensitive.
typedef uint32_t xkb_led_index_t |
Index of a keyboard LED.
LEDs are logical objects which may be active or inactive. They typically correspond to the lights on the keyboard. Their state is determined by the current keyboard state.
LED indices are non-consecutive. The first LED has index 0.
Each LED must have a name, and the names are unique. Therefore, it is safe to use the name as a unique identifier for a LED. The names of some common LEDs are provided in the xkbcommon/xkbcommon-names.h header file. LED names are case-sensitive.
LEDs are also called "indicators" by XKB.