libxkbcommon  0.2.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 
112 struct xkb_context;
113 
127 struct xkb_keymap;
128 
141 struct xkb_state;
142 
162 typedef uint32_t xkb_keycode_t;
163 
193 typedef uint32_t xkb_keysym_t;
194 
208 typedef uint32_t xkb_mod_index_t;
210 typedef uint32_t xkb_mod_mask_t;
211 
228 typedef uint32_t xkb_layout_index_t;
230 typedef uint32_t xkb_layout_mask_t;
231 
237 typedef uint32_t xkb_level_index_t;
238 
262 typedef uint32_t xkb_led_index_t;
264 typedef uint32_t xkb_led_mask_t;
265 
266 #define XKB_MOD_INVALID (0xffffffff)
267 #define XKB_LAYOUT_INVALID (0xffffffff)
268 #define XKB_KEYCODE_INVALID (0xffffffff)
269 #define XKB_LEVEL_INVALID (0xffffffff)
270 #define XKB_LED_INVALID (0xffffffff)
271 
272 #define XKB_KEYCODE_MAX (0xffffffff - 1)
273 
278 #define xkb_keycode_is_legal_ext(key) (key <= XKB_KEYCODE_MAX)
279 
284 #define xkb_keycode_is_legal_x11(key) (key >= 8 && key <= 255)
285 
297  const char *rules;
299  const char *model;
302  const char *layout;
305  const char *variant;
309  const char *options;
310 };
311 
339 int
340 xkb_keysym_get_name(xkb_keysym_t keysym, char *buffer, size_t size);
341 
346 };
347 
368 xkb_keysym_t
369 xkb_keysym_from_name(const char *name, enum xkb_keysym_flags flags);
370 
382 int
383 xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size);
384 
392 uint32_t
393 xkb_keysym_to_utf32(xkb_keysym_t keysym);
394 
411 };
412 
426 struct xkb_context *
428 
436 struct xkb_context *
437 xkb_context_ref(struct xkb_context *context);
438 
444 void
445 xkb_context_unref(struct xkb_context *context);
446 
455 void
456 xkb_context_set_user_data(struct xkb_context *context, void *user_data);
457 
469 void *
470 xkb_context_get_user_data(struct xkb_context *context);
471 
493 int
494 xkb_context_include_path_append(struct xkb_context *context, const char *path);
495 
503 int
505 
516 int
518 
524 void
526 
532 unsigned int
534 
543 const char *
544 xkb_context_include_path_get(struct xkb_context *context, unsigned int index);
545 
562 };
563 
577 void
578 xkb_context_set_log_level(struct xkb_context *context,
579  enum xkb_log_level level);
580 
586 enum xkb_log_level
587 xkb_context_get_log_level(struct xkb_context *context);
588 
608 void
609 xkb_context_set_log_verbosity(struct xkb_context *context, int verbosity);
610 
616 int
618 
639 void
640 xkb_context_set_log_fn(struct xkb_context *context,
641  void (*log_fn)(struct xkb_context *context,
642  enum xkb_log_level level,
643  const char *format, va_list args));
644 
658 };
659 
679 struct xkb_keymap *
680 xkb_keymap_new_from_names(struct xkb_context *context,
681  const struct xkb_rule_names *names,
682  enum xkb_keymap_compile_flags flags);
683 
688 };
689 
708 struct xkb_keymap *
709 xkb_keymap_new_from_file(struct xkb_context *context, FILE *file,
710  enum xkb_keymap_format format,
711  enum xkb_keymap_compile_flags flags);
712 
722 struct xkb_keymap *
723 xkb_keymap_new_from_string(struct xkb_context *context, const char *string,
724  enum xkb_keymap_format format,
725  enum xkb_keymap_compile_flags flags);
726 
734 struct xkb_keymap *
735 xkb_keymap_ref(struct xkb_keymap *keymap);
736 
742 void
743 xkb_keymap_unref(struct xkb_keymap *keymap);
744 
749 #define XKB_KEYMAP_USE_ORIGINAL_FORMAT ((enum xkb_keymap_format) -1)
750 
769 char *
770 xkb_keymap_get_as_string(struct xkb_keymap *keymap,
771  enum xkb_keymap_format format);
772 
788 xkb_mod_index_t
789 xkb_keymap_num_mods(struct xkb_keymap *keymap);
790 
799 const char *
800 xkb_keymap_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx);
801 
811 xkb_mod_index_t
812 xkb_keymap_mod_get_index(struct xkb_keymap *keymap, const char *name);
813 
820 xkb_layout_index_t
821 xkb_keymap_num_layouts(struct xkb_keymap *keymap);
822 
832 const char *
833 xkb_keymap_layout_get_name(struct xkb_keymap *keymap, xkb_layout_index_t idx);
834 
844 xkb_layout_index_t
845 xkb_keymap_layout_get_index(struct xkb_keymap *keymap, const char *name);
846 
857 xkb_layout_index_t
858 xkb_keymap_num_layouts_for_key(struct xkb_keymap *keymap, xkb_keycode_t key);
859 
866 xkb_level_index_t
867 xkb_keymap_num_levels_for_key(struct xkb_keymap *keymap, xkb_keycode_t key,
868  xkb_layout_index_t layout);
869 
900 int
902  xkb_keycode_t key,
903  xkb_layout_index_t layout,
904  xkb_level_index_t level,
905  const xkb_keysym_t **syms_out);
906 
918 xkb_led_index_t
919 xkb_keymap_num_leds(struct xkb_keymap *keymap);
920 
928 const char *
929 xkb_keymap_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx);
930 
939 xkb_led_index_t
940 xkb_keymap_led_get_index(struct xkb_keymap *keymap, const char *name);
941 
957 int
958 xkb_keymap_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t key);
959 
978 struct xkb_state *
979 xkb_state_new(struct xkb_keymap *keymap);
980 
988 struct xkb_state *
989 xkb_state_ref(struct xkb_state *state);
990 
996 void
997 xkb_state_unref(struct xkb_state *state);
998 
1011 struct xkb_keymap *
1012 xkb_state_get_keymap(struct xkb_state *state);
1013 
1018 };
1019 
1051  XKB_STATE_LEDS = (1 << 8),
1052 };
1053 
1064 xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key,
1065  enum xkb_key_direction direction);
1066 
1090 int
1091 xkb_state_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
1092  const xkb_keysym_t **syms_out);
1093 
1108 xkb_keysym_t
1109 xkb_state_key_get_one_sym(struct xkb_state *state, xkb_keycode_t key);
1110 
1125 xkb_layout_index_t
1126 xkb_state_key_get_layout(struct xkb_state *state, xkb_keycode_t key);
1127 
1150 xkb_level_index_t
1151 xkb_state_key_get_level(struct xkb_state *state, xkb_keycode_t key,
1152  xkb_layout_index_t layout);
1153 
1168 };
1169 
1193 xkb_state_update_mask(struct xkb_state *state,
1194  xkb_mod_mask_t depressed_mods,
1195  xkb_mod_mask_t latched_mods,
1196  xkb_mod_mask_t locked_mods,
1197  xkb_layout_index_t depressed_layout,
1198  xkb_layout_index_t latched_layout,
1199  xkb_layout_index_t locked_layout);
1200 
1219 xkb_mod_mask_t
1220 xkb_state_serialize_mods(struct xkb_state *state,
1221  enum xkb_state_component components);
1222 
1241 xkb_layout_index_t
1243  enum xkb_state_component components);
1244 
1253 int
1254 xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
1255  enum xkb_state_component type);
1256 
1274 int
1276  enum xkb_state_component type,
1277  enum xkb_state_match match,
1278  ...);
1279 
1288 int
1289 xkb_state_mod_index_is_active(struct xkb_state *state, xkb_mod_index_t idx,
1290  enum xkb_state_component type);
1291 
1309 int
1311  enum xkb_state_component type,
1312  enum xkb_state_match match,
1313  ...);
1314 
1336 int
1337 xkb_state_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t key,
1338  xkb_mod_index_t idx);
1339 
1349 xkb_mod_mask_t
1350 xkb_state_mod_mask_remove_consumed(struct xkb_state *state, xkb_keycode_t key,
1351  xkb_mod_mask_t mask);
1352 
1365 int
1366 xkb_state_layout_name_is_active(struct xkb_state *state, const char *name,
1367  enum xkb_state_component type);
1368 
1378 int
1380  xkb_layout_index_t idx,
1381  enum xkb_state_component type);
1382 
1392 int
1393 xkb_state_led_name_is_active(struct xkb_state *state, const char *name);
1394 
1404 int
1405 xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx);
1406 
1409 /* Leave this include last, so it can pick up our types, etc. */
1410 #include <xkbcommon/xkbcommon-compat.h>
1411 
1412 #ifdef __cplusplus
1413 } /* extern "C" */
1414 #endif
1415 
1416 #endif /* _XKBCOMMON_H_ */