libxkbcommon  0.3.0
xkbcommon.h
Go to the documentation of this file.
1 /*
2  * Copyright 1985, 1987, 1990, 1998 The Open Group
3  * Copyright 2008 Dan Nicholson
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Except as contained in this notice, the names of the authors or their
23  * institutions shall not be used in advertising or otherwise to promote the
24  * sale, use or other dealings in this Software without prior written
25  * authorization from the authors.
26  */
27 
28 /************************************************************
29  * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
30  *
31  * Permission to use, copy, modify, and distribute this
32  * software and its documentation for any purpose and without
33  * fee is hereby granted, provided that the above copyright
34  * notice appear in all copies and that both that copyright
35  * notice and this permission notice appear in supporting
36  * documentation, and that the name of Silicon Graphics not be
37  * used in advertising or publicity pertaining to distribution
38  * of the software without specific prior written permission.
39  * Silicon Graphics makes no representation about the suitability
40  * of this software for any purpose. It is provided "as is"
41  * without any express or implied warranty.
42  *
43  * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
44  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
45  * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
46  * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
47  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
48  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
49  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
50  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
51  *
52  ********************************************************/
53 
54 /*
55  * Copyright © 2009-2012 Daniel Stone
56  * Copyright © 2012 Intel Corporation
57  * Copyright © 2012 Ran Benita
58  *
59  * Permission is hereby granted, free of charge, to any person obtaining a
60  * copy of this software and associated documentation files (the "Software"),
61  * to deal in the Software without restriction, including without limitation
62  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
63  * and/or sell copies of the Software, and to permit persons to whom the
64  * Software is furnished to do so, subject to the following conditions:
65  *
66  * The above copyright notice and this permission notice (including the next
67  * paragraph) shall be included in all copies or substantial portions of the
68  * Software.
69  *
70  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
73  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
75  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
76  * DEALINGS IN THE SOFTWARE.
77  *
78  * Author: Daniel Stone <daniel@fooishbar.org>
79  */
80 
81 #ifndef _XKBCOMMON_H_
82 #define _XKBCOMMON_H_
83 
84 #include <stdint.h>
85 #include <stdio.h>
86 #include <stdarg.h>
87 
89 #include <xkbcommon/xkbcommon-keysyms.h>
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
111 struct xkb_context;
112 
123 struct xkb_keymap;
124 
134 struct xkb_state;
135 
161 typedef uint32_t xkb_keycode_t;
162 
191 typedef uint32_t xkb_keysym_t;
192 
211 typedef uint32_t xkb_layout_index_t;
213 typedef uint32_t xkb_layout_mask_t;
214 
220 typedef uint32_t xkb_level_index_t;
221 
245 typedef uint32_t xkb_mod_index_t;
247 typedef uint32_t xkb_mod_mask_t;
248 
272 typedef uint32_t xkb_led_index_t;
274 typedef uint32_t xkb_led_mask_t;
275 
276 #define XKB_KEYCODE_INVALID (0xffffffff)
277 #define XKB_LAYOUT_INVALID (0xffffffff)
278 #define XKB_LEVEL_INVALID (0xffffffff)
279 #define XKB_MOD_INVALID (0xffffffff)
280 #define XKB_LED_INVALID (0xffffffff)
281 
282 #define XKB_KEYCODE_MAX (0xffffffff - 1)
283 
288 #define xkb_keycode_is_legal_ext(key) (key <= XKB_KEYCODE_MAX)
289 
294 #define xkb_keycode_is_legal_x11(key) (key >= 8 && key <= 255)
295 
307  const char *rules;
309  const char *model;
312  const char *layout;
315  const char *variant;
319  const char *options;
320 };
321 
349 int
350 xkb_keysym_get_name(xkb_keysym_t keysym, char *buffer, size_t size);
351 
356 };
357 
378 xkb_keysym_t
379 xkb_keysym_from_name(const char *name, enum xkb_keysym_flags flags);
380 
392 int
393 xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size);
394 
402 uint32_t
403 xkb_keysym_to_utf32(xkb_keysym_t keysym);
404 
423 };
424 
438 struct xkb_context *
440 
448 struct xkb_context *
449 xkb_context_ref(struct xkb_context *context);
450 
458 void
459 xkb_context_unref(struct xkb_context *context);
460 
469 void
470 xkb_context_set_user_data(struct xkb_context *context, void *user_data);
471 
483 void *
484 xkb_context_get_user_data(struct xkb_context *context);
485 
507 int
508 xkb_context_include_path_append(struct xkb_context *context, const char *path);
509 
517 int
519 
530 int
532 
538 void
540 
546 unsigned int
548 
557 const char *
558 xkb_context_include_path_get(struct xkb_context *context, unsigned int index);
559 
576 };
577 
591 void
592 xkb_context_set_log_level(struct xkb_context *context,
593  enum xkb_log_level level);
594 
600 enum xkb_log_level
601 xkb_context_get_log_level(struct xkb_context *context);
602 
622 void
623 xkb_context_set_log_verbosity(struct xkb_context *context, int verbosity);
624 
630 int
632 
653 void
654 xkb_context_set_log_fn(struct xkb_context *context,
655  void (*log_fn)(struct xkb_context *context,
656  enum xkb_log_level level,
657  const char *format, va_list args));
658 
672 };
673 
695 struct xkb_keymap *
696 xkb_keymap_new_from_names(struct xkb_context *context,
697  const struct xkb_rule_names *names,
698  enum xkb_keymap_compile_flags flags);
699 
704 };
705 
724 struct xkb_keymap *
725 xkb_keymap_new_from_file(struct xkb_context *context, FILE *file,
726  enum xkb_keymap_format format,
727  enum xkb_keymap_compile_flags flags);
728 
738 struct xkb_keymap *
739 xkb_keymap_new_from_string(struct xkb_context *context, const char *string,
740  enum xkb_keymap_format format,
741  enum xkb_keymap_compile_flags flags);
742 
752 struct xkb_keymap *
753 xkb_keymap_new_from_buffer(struct xkb_context *context, const char *buffer,
754  size_t length, enum xkb_keymap_format format,
755  enum xkb_keymap_compile_flags flags);
756 
764 struct xkb_keymap *
765 xkb_keymap_ref(struct xkb_keymap *keymap);
766 
774 void
775 xkb_keymap_unref(struct xkb_keymap *keymap);
776 
781 #define XKB_KEYMAP_USE_ORIGINAL_FORMAT ((enum xkb_keymap_format) -1)
782 
801 char *
802 xkb_keymap_get_as_string(struct xkb_keymap *keymap,
803  enum xkb_keymap_format format);
804 
820 xkb_mod_index_t
821 xkb_keymap_num_mods(struct xkb_keymap *keymap);
822 
831 const char *
832 xkb_keymap_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx);
833 
843 xkb_mod_index_t
844 xkb_keymap_mod_get_index(struct xkb_keymap *keymap, const char *name);
845 
852 xkb_layout_index_t
853 xkb_keymap_num_layouts(struct xkb_keymap *keymap);
854 
864 const char *
865 xkb_keymap_layout_get_name(struct xkb_keymap *keymap, xkb_layout_index_t idx);
866 
876 xkb_layout_index_t
877 xkb_keymap_layout_get_index(struct xkb_keymap *keymap, const char *name);
878 
889 xkb_layout_index_t
890 xkb_keymap_num_layouts_for_key(struct xkb_keymap *keymap, xkb_keycode_t key);
891 
902 xkb_level_index_t
903 xkb_keymap_num_levels_for_key(struct xkb_keymap *keymap, xkb_keycode_t key,
904  xkb_layout_index_t layout);
905 
934 int
936  xkb_keycode_t key,
937  xkb_layout_index_t layout,
938  xkb_level_index_t level,
939  const xkb_keysym_t **syms_out);
940 
952 xkb_led_index_t
953 xkb_keymap_num_leds(struct xkb_keymap *keymap);
954 
962 const char *
963 xkb_keymap_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx);
964 
973 xkb_led_index_t
974 xkb_keymap_led_get_index(struct xkb_keymap *keymap, const char *name);
975 
991 int
992 xkb_keymap_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t key);
993 
1012 struct xkb_state *
1013 xkb_state_new(struct xkb_keymap *keymap);
1014 
1022 struct xkb_state *
1023 xkb_state_ref(struct xkb_state *state);
1024 
1032 void
1033 xkb_state_unref(struct xkb_state *state);
1034 
1047 struct xkb_keymap *
1048 xkb_state_get_keymap(struct xkb_state *state);
1049 
1054 };
1055 
1087  XKB_STATE_LEDS = (1 << 8)
1088 };
1089 
1100 xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key,
1101  enum xkb_key_direction direction);
1102 
1126 int
1127 xkb_state_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
1128  const xkb_keysym_t **syms_out);
1129 
1144 xkb_keysym_t
1145 xkb_state_key_get_one_sym(struct xkb_state *state, xkb_keycode_t key);
1146 
1161 xkb_layout_index_t
1162 xkb_state_key_get_layout(struct xkb_state *state, xkb_keycode_t key);
1163 
1186 xkb_level_index_t
1187 xkb_state_key_get_level(struct xkb_state *state, xkb_keycode_t key,
1188  xkb_layout_index_t layout);
1189 
1204 };
1205 
1231 xkb_state_update_mask(struct xkb_state *state,
1232  xkb_mod_mask_t depressed_mods,
1233  xkb_mod_mask_t latched_mods,
1234  xkb_mod_mask_t locked_mods,
1235  xkb_layout_index_t depressed_layout,
1236  xkb_layout_index_t latched_layout,
1237  xkb_layout_index_t locked_layout);
1238 
1257 xkb_mod_mask_t
1258 xkb_state_serialize_mods(struct xkb_state *state,
1259  enum xkb_state_component components);
1260 
1279 xkb_layout_index_t
1281  enum xkb_state_component components);
1282 
1291 int
1292 xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
1293  enum xkb_state_component type);
1294 
1312 int
1314  enum xkb_state_component type,
1315  enum xkb_state_match match,
1316  ...);
1317 
1326 int
1327 xkb_state_mod_index_is_active(struct xkb_state *state, xkb_mod_index_t idx,
1328  enum xkb_state_component type);
1329 
1347 int
1349  enum xkb_state_component type,
1350  enum xkb_state_match match,
1351  ...);
1352 
1415 int
1416 xkb_state_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t key,
1417  xkb_mod_index_t idx);
1418 
1428 xkb_mod_mask_t
1429 xkb_state_mod_mask_remove_consumed(struct xkb_state *state, xkb_keycode_t key,
1430  xkb_mod_mask_t mask);
1431 
1444 int
1445 xkb_state_layout_name_is_active(struct xkb_state *state, const char *name,
1446  enum xkb_state_component type);
1447 
1457 int
1459  xkb_layout_index_t idx,
1460  enum xkb_state_component type);
1461 
1471 int
1472 xkb_state_led_name_is_active(struct xkb_state *state, const char *name);
1473 
1483 int
1484 xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx);
1485 
1488 /* Leave this include last, so it can pick up our types, etc. */
1489 #include <xkbcommon/xkbcommon-compat.h>
1490 
1491 #ifdef __cplusplus
1492 } /* extern "C" */
1493 #endif
1494 
1495 #endif /* _XKBCOMMON_H_ */