1 | #![allow (non_camel_case_types)] |
2 | |
3 | use libc::FILE; |
4 | use std::os::raw::{c_char, c_int, c_uint, c_void}; |
5 | |
6 | pub enum xkb_context {} |
7 | |
8 | pub enum xkb_keymap {} |
9 | |
10 | pub enum xkb_state {} |
11 | |
12 | pub type xkb_keycode_t = u32; |
13 | |
14 | pub type xkb_keysym_t = u32; |
15 | |
16 | pub type xkb_layout_index_t = u32; |
17 | |
18 | pub type xkb_layout_mask_t = u32; |
19 | |
20 | pub type xkb_level_index_t = u32; |
21 | |
22 | pub type xkb_mod_index_t = u32; |
23 | |
24 | pub type xkb_mod_mask_t = u32; |
25 | |
26 | pub type xkb_led_index_t = u32; |
27 | |
28 | pub type xkb_led_mask_t = u32; |
29 | |
30 | pub const XKB_KEYCODE_INVALID: u32 = 0xffff_ffff; |
31 | pub const XKB_LAYOUT_INVALID: u32 = 0xffff_ffff; |
32 | pub const XKB_LEVEL_INVALID: u32 = 0xffff_ffff; |
33 | pub const XKB_MOD_INVALID: u32 = 0xffff_ffff; |
34 | pub const XKB_LED_INVALID: u32 = 0xffff_ffff; |
35 | |
36 | pub const XKB_KEYCODE_MAX: u32 = 0xffff_fffe; |
37 | |
38 | #[must_use ] |
39 | pub fn xkb_keycode_is_legal_ext(key: u32) -> bool { |
40 | key <= XKB_KEYCODE_MAX |
41 | } |
42 | |
43 | #[must_use ] |
44 | pub fn xkb_keycode_is_legal_x11(key: u32) -> bool { |
45 | (8..=255).contains(&key) |
46 | } |
47 | |
48 | #[repr (C)] |
49 | pub struct xkb_rule_names { |
50 | pub rules: *const c_char, |
51 | pub model: *const c_char, |
52 | pub layout: *const c_char, |
53 | pub variant: *const c_char, |
54 | pub options: *const c_char, |
55 | } |
56 | |
57 | pub type xkb_keysym_flags = u32; |
58 | pub const XKB_KEYSYM_NO_FLAGS: u32 = 0; |
59 | pub const XKB_KEYSYM_CASE_INSENSITIVE: u32 = 1 << 0; |
60 | |
61 | pub type xkb_context_flags = u32; |
62 | pub const XKB_CONTEXT_NO_FLAGS: u32 = 0; |
63 | pub const XKB_CONTEXT_NO_DEFAULT_INCLUDES: u32 = 1 << 0; |
64 | pub const XKB_CONTEXT_NO_ENVIRONMENT_NAMES: u32 = 1 << 1; |
65 | |
66 | #[repr (C)] |
67 | pub enum xkb_log_level { |
68 | CRITICAL = 10, |
69 | ERROR = 20, |
70 | WARNING = 30, |
71 | INFO = 40, |
72 | DEBUG = 50, |
73 | } |
74 | |
75 | pub type xkb_keymap_compile_flags = u32; |
76 | pub const XKB_KEYMAP_COMPILE_NO_FLAGS: u32 = 0; |
77 | |
78 | pub type xkb_keymap_format = u32; |
79 | pub const XKB_KEYMAP_FORMAT_TEXT_V1: u32 = 1; |
80 | pub const XKB_KEYMAP_FORMAT_USE_ORIGINAL: u32 = 0xffff_ffff; |
81 | |
82 | #[repr (C)] |
83 | pub enum xkb_key_direction { |
84 | UP, |
85 | DOWN, |
86 | } |
87 | |
88 | pub type xkb_state_component = u32; |
89 | pub const XKB_STATE_MODS_DEPRESSED: u32 = 1 << 0; |
90 | pub const XKB_STATE_MODS_LATCHED: u32 = 1 << 1; |
91 | pub const XKB_STATE_MODS_LOCKED: u32 = 1 << 2; |
92 | pub const XKB_STATE_MODS_EFFECTIVE: u32 = 1 << 3; |
93 | pub const XKB_STATE_LAYOUT_DEPRESSED: u32 = 1 << 4; |
94 | pub const XKB_STATE_LAYOUT_LATCHED: u32 = 1 << 5; |
95 | pub const XKB_STATE_LAYOUT_LOCKED: u32 = 1 << 6; |
96 | pub const XKB_STATE_LAYOUT_EFFECTIVE: u32 = 1 << 7; |
97 | pub const XKB_STATE_LEDS: u32 = 1 << 8; |
98 | |
99 | pub type xkb_state_match = u32; |
100 | pub const XKB_STATE_MATCH_ANY: u32 = 1 << 0; |
101 | pub const XKB_STATE_MATCH_ALL: u32 = 1 << 1; |
102 | pub const XKB_STATE_MATCH_NON_EXCLUSIVE: u32 = 1 << 16; |
103 | |
104 | pub type xkb_log_fn_t = unsafe extern "C" fn( |
105 | context: *mut xkb_context, |
106 | level: xkb_log_level, |
107 | format: *const c_char, |
108 | ... |
109 | ); |
110 | |
111 | pub type xkb_keymap_key_iter_t = |
112 | unsafe extern "C" fn(keymap: *mut xkb_keymap, key: xkb_keycode_t, data: *mut c_void); |
113 | |
114 | #[link (name = "xkbcommon" )] |
115 | extern "C" { |
116 | |
117 | pub fn xkb_keysym_get_name(keysym: xkb_keysym_t, buffer: *mut c_char, size: usize) -> c_int; |
118 | |
119 | pub fn xkb_keysym_from_name(name: *const c_char, flags: xkb_keysym_flags) -> xkb_keysym_t; |
120 | |
121 | pub fn xkb_keysym_to_utf8(keysym: xkb_keysym_t, buffer: *mut c_char, size: usize) -> c_int; |
122 | |
123 | pub fn xkb_keysym_to_utf32(keysym: xkb_keysym_t) -> u32; |
124 | |
125 | pub fn xkb_utf32_to_keysym(ucs: u32) -> xkb_keysym_t; |
126 | |
127 | pub fn xkb_context_new(flags: xkb_context_flags) -> *mut xkb_context; |
128 | |
129 | pub fn xkb_context_ref(context: *mut xkb_context) -> *mut xkb_context; |
130 | |
131 | pub fn xkb_context_unref(context: *mut xkb_context); |
132 | |
133 | pub fn xkb_context_set_user_data(context: *mut xkb_context, user_data: *mut c_void); |
134 | |
135 | pub fn xkb_context_get_user_data(context: *mut xkb_context) -> *mut c_void; |
136 | |
137 | pub fn xkb_context_include_path_append(context: *mut xkb_context, path: *const c_char) |
138 | -> c_int; |
139 | |
140 | pub fn xkb_context_include_path_append_default(context: *mut xkb_context) -> c_int; |
141 | |
142 | pub fn xkb_context_include_path_reset_defaults(context: *mut xkb_context) -> c_int; |
143 | |
144 | pub fn xkb_context_include_path_clear(context: *mut xkb_context); |
145 | |
146 | pub fn xkb_context_num_include_paths(context: *mut xkb_context) -> c_uint; |
147 | |
148 | pub fn xkb_context_include_path_get(context: *mut xkb_context, index: c_uint) -> *const c_char; |
149 | |
150 | pub fn xkb_context_set_log_level(context: *mut xkb_context, level: xkb_log_level); |
151 | |
152 | pub fn xkb_context_get_log_level(context: *mut xkb_context) -> xkb_log_level; |
153 | |
154 | pub fn xkb_context_set_log_verbosity(context: *mut xkb_context, verbosity: c_int); |
155 | |
156 | pub fn xkb_context_get_log_verbosity(context: *mut xkb_context) -> c_int; |
157 | |
158 | pub fn xkb_context_set_log_fn(context: *mut xkb_context, log_fn: xkb_log_fn_t); |
159 | |
160 | pub fn xkb_keymap_new_from_names( |
161 | context: *mut xkb_context, |
162 | names: *const xkb_rule_names, |
163 | flags: xkb_keymap_compile_flags, |
164 | ) -> *mut xkb_keymap; |
165 | |
166 | pub fn xkb_keymap_new_from_file( |
167 | context: *mut xkb_context, |
168 | file: *mut FILE, |
169 | format: xkb_keymap_format, |
170 | flags: xkb_keymap_compile_flags, |
171 | ) -> *mut xkb_keymap; |
172 | |
173 | pub fn xkb_keymap_new_from_string( |
174 | context: *mut xkb_context, |
175 | s: *const c_char, |
176 | format: xkb_keymap_format, |
177 | flags: xkb_keymap_compile_flags, |
178 | ) -> *mut xkb_keymap; |
179 | |
180 | pub fn xkb_keymap_new_from_buffer( |
181 | context: *mut xkb_context, |
182 | buffer: *const c_char, |
183 | length: usize, |
184 | format: xkb_keymap_format, |
185 | flags: xkb_keymap_compile_flags, |
186 | ) -> *mut xkb_keymap; |
187 | |
188 | pub fn xkb_keymap_ref(keymap: *mut xkb_keymap) -> *mut xkb_keymap; |
189 | |
190 | pub fn xkb_keymap_unref(keymap: *mut xkb_keymap); |
191 | |
192 | pub fn xkb_keymap_get_as_string( |
193 | keymap: *mut xkb_keymap, |
194 | format: xkb_keymap_format, |
195 | ) -> *mut c_char; |
196 | |
197 | pub fn xkb_keymap_min_keycode(keymap: *mut xkb_keymap) -> xkb_keycode_t; |
198 | |
199 | pub fn xkb_keymap_max_keycode(keymap: *mut xkb_keymap) -> xkb_keycode_t; |
200 | |
201 | pub fn xkb_keymap_key_for_each( |
202 | keymap: *mut xkb_keymap, |
203 | iter: xkb_keymap_key_iter_t, |
204 | data: *mut c_void, |
205 | ); |
206 | |
207 | pub fn xkb_keymap_num_mods(keymap: *mut xkb_keymap) -> xkb_mod_index_t; |
208 | |
209 | pub fn xkb_keymap_mod_get_name(keymap: *mut xkb_keymap, idx: xkb_mod_index_t) -> *const c_char; |
210 | |
211 | pub fn xkb_keymap_mod_get_index( |
212 | keymap: *mut xkb_keymap, |
213 | name: *const c_char, |
214 | ) -> xkb_mod_index_t; |
215 | |
216 | pub fn xkb_keymap_num_layouts(keymap: *mut xkb_keymap) -> xkb_layout_index_t; |
217 | |
218 | pub fn xkb_keymap_layout_get_name( |
219 | keymap: *mut xkb_keymap, |
220 | idx: xkb_layout_index_t, |
221 | ) -> *const c_char; |
222 | |
223 | pub fn xkb_keymap_layout_get_index( |
224 | keymap: *mut xkb_keymap, |
225 | name: *const c_char, |
226 | ) -> xkb_layout_index_t; |
227 | |
228 | pub fn xkb_keymap_num_leds(keymap: *mut xkb_keymap) -> xkb_led_index_t; |
229 | |
230 | pub fn xkb_keymap_led_get_name(keymap: *mut xkb_keymap, idx: xkb_led_index_t) -> *const c_char; |
231 | |
232 | pub fn xkb_keymap_led_get_index( |
233 | keymap: *mut xkb_keymap, |
234 | name: *const c_char, |
235 | ) -> xkb_led_index_t; |
236 | |
237 | pub fn xkb_keymap_num_layouts_for_key( |
238 | keymap: *mut xkb_keymap, |
239 | key: xkb_keycode_t, |
240 | ) -> xkb_layout_index_t; |
241 | |
242 | pub fn xkb_keymap_num_levels_for_key( |
243 | keymap: *mut xkb_keymap, |
244 | key: xkb_keycode_t, |
245 | layout: xkb_layout_index_t, |
246 | ) -> xkb_level_index_t; |
247 | |
248 | pub fn xkb_keymap_key_get_syms_by_level( |
249 | keymap: *mut xkb_keymap, |
250 | key: xkb_keycode_t, |
251 | layout: xkb_layout_index_t, |
252 | level: xkb_level_index_t, |
253 | syms_out: *mut *const xkb_keysym_t, |
254 | ) -> c_int; |
255 | |
256 | pub fn xkb_keymap_key_by_name(keymap: *mut xkb_keymap, name: *const c_char) -> xkb_keycode_t; |
257 | |
258 | pub fn xkb_keymap_key_get_name(keymap: *mut xkb_keymap, key: xkb_keycode_t) -> *const c_char; |
259 | |
260 | pub fn xkb_keymap_key_repeats(keymap: *mut xkb_keymap, key: xkb_keycode_t) -> c_int; |
261 | |
262 | pub fn xkb_state_ref(state: *mut xkb_state) -> *mut xkb_state; |
263 | |
264 | pub fn xkb_state_unref(state: *mut xkb_state); |
265 | |
266 | pub fn xkb_state_new(keymap: *mut xkb_keymap) -> *mut xkb_state; |
267 | |
268 | pub fn xkb_state_get_keymap(state: *mut xkb_state) -> *mut xkb_keymap; |
269 | |
270 | pub fn xkb_state_update_key( |
271 | state: *mut xkb_state, |
272 | key: xkb_keycode_t, |
273 | direction: xkb_key_direction, |
274 | ) -> xkb_state_component; |
275 | |
276 | pub fn xkb_state_update_mask( |
277 | state: *mut xkb_state, |
278 | depressed_mods: xkb_mod_mask_t, |
279 | latched_mods: xkb_mod_mask_t, |
280 | locked_mods: xkb_mod_mask_t, |
281 | depressed_layout: xkb_layout_index_t, |
282 | latched_layout: xkb_layout_index_t, |
283 | locked_layout: xkb_layout_index_t, |
284 | ) -> xkb_state_component; |
285 | |
286 | pub fn xkb_state_key_get_syms( |
287 | state: *mut xkb_state, |
288 | key: xkb_keycode_t, |
289 | syms_out: *mut *const xkb_keysym_t, |
290 | ) -> c_int; |
291 | |
292 | pub fn xkb_state_key_get_utf8( |
293 | state: *mut xkb_state, |
294 | key: xkb_keycode_t, |
295 | buffer: *mut c_char, |
296 | size: usize, |
297 | ) -> c_int; |
298 | |
299 | pub fn xkb_state_key_get_utf32(state: *mut xkb_state, key: xkb_keycode_t) -> u32; |
300 | |
301 | pub fn xkb_state_key_get_one_sym(state: *mut xkb_state, key: xkb_keycode_t) -> xkb_keysym_t; |
302 | |
303 | pub fn xkb_state_key_get_layout( |
304 | state: *mut xkb_state, |
305 | key: xkb_keycode_t, |
306 | ) -> xkb_layout_index_t; |
307 | |
308 | pub fn xkb_state_key_get_level( |
309 | state: *mut xkb_state, |
310 | key: xkb_keycode_t, |
311 | layout: xkb_layout_index_t, |
312 | ) -> xkb_level_index_t; |
313 | |
314 | pub fn xkb_state_serialize_mods( |
315 | state: *mut xkb_state, |
316 | components: xkb_state_component, |
317 | ) -> xkb_mod_mask_t; |
318 | |
319 | pub fn xkb_state_serialize_layout( |
320 | state: *mut xkb_state, |
321 | components: xkb_state_component, |
322 | ) -> xkb_layout_index_t; |
323 | |
324 | pub fn xkb_state_mod_name_is_active( |
325 | state: *mut xkb_state, |
326 | name: *const c_char, |
327 | type_: xkb_state_component, |
328 | ) -> c_int; |
329 | |
330 | pub fn xkb_state_mod_names_are_active( |
331 | state: *mut xkb_state, |
332 | type_: xkb_state_component, |
333 | match_: xkb_state_match, |
334 | ... |
335 | ) -> c_int; |
336 | |
337 | pub fn xkb_state_mod_index_is_active( |
338 | state: *mut xkb_state, |
339 | idx: xkb_mod_index_t, |
340 | type_: xkb_state_component, |
341 | ) -> c_int; |
342 | |
343 | pub fn xkb_state_mod_index_are_active( |
344 | state: *mut xkb_state, |
345 | type_: xkb_state_component, |
346 | match_: xkb_state_match, |
347 | ... |
348 | ) -> c_int; |
349 | |
350 | pub fn xkb_state_mod_index_is_consumed( |
351 | state: *mut xkb_state, |
352 | key: xkb_keycode_t, |
353 | idx: xkb_mod_index_t, |
354 | ) -> c_int; |
355 | |
356 | pub fn xkb_state_mod_mask_remove_consumed( |
357 | state: *mut xkb_state, |
358 | key: xkb_keycode_t, |
359 | mask: xkb_mod_mask_t, |
360 | ) -> xkb_mod_mask_t; |
361 | |
362 | pub fn xkb_state_key_get_consumed_mods( |
363 | state: *mut xkb_state, |
364 | key: xkb_keycode_t, |
365 | ) -> xkb_mod_mask_t; |
366 | |
367 | pub fn xkb_state_layout_name_is_active( |
368 | state: *mut xkb_state, |
369 | name: *const c_char, |
370 | type_: xkb_state_component, |
371 | ) -> c_int; |
372 | |
373 | pub fn xkb_state_layout_index_is_active( |
374 | state: *mut xkb_state, |
375 | idx: xkb_layout_index_t, |
376 | type_: xkb_state_component, |
377 | ) -> c_int; |
378 | |
379 | pub fn xkb_state_led_name_is_active(state: *mut xkb_state, name: *const c_char) -> c_int; |
380 | |
381 | pub fn xkb_state_led_index_is_active(state: *mut xkb_state, idx: xkb_led_index_t) -> c_int; |
382 | |
383 | } |
384 | |
385 | pub mod compose { |
386 | use super::{xkb_context, xkb_keysym_t}; |
387 | use libc::{c_char, c_int, size_t, FILE}; |
388 | |
389 | pub enum xkb_compose_table {} |
390 | |
391 | pub enum xkb_compose_state {} |
392 | |
393 | pub type xkb_compose_compile_flags = u32; |
394 | |
395 | pub type xkb_compose_format = u32; |
396 | |
397 | pub type xkb_compose_state_flags = u32; |
398 | |
399 | pub type xkb_compose_status = u32; |
400 | |
401 | pub type xkb_compose_feed_result = u32; |
402 | |
403 | #[link (name = "xkbcommon" )] |
404 | extern "C" { |
405 | |
406 | pub fn xkb_compose_table_new_from_locale( |
407 | context: *mut xkb_context, |
408 | locale: *const c_char, |
409 | flags: xkb_compose_compile_flags, |
410 | ) -> *mut xkb_compose_table; |
411 | |
412 | pub fn xkb_compose_table_new_from_file( |
413 | context: *mut xkb_context, |
414 | file: *mut FILE, |
415 | locale: *const c_char, |
416 | format: xkb_compose_format, |
417 | flags: xkb_compose_compile_flags, |
418 | ) -> *mut xkb_compose_table; |
419 | |
420 | pub fn xkb_compose_table_new_from_buffer( |
421 | context: *mut xkb_context, |
422 | buffer: *const c_char, |
423 | length: size_t, |
424 | locale: *const c_char, |
425 | format: xkb_compose_format, |
426 | flags: xkb_compose_compile_flags, |
427 | ) -> *mut xkb_compose_table; |
428 | |
429 | pub fn xkb_compose_table_ref(table: *mut xkb_compose_table) -> *mut xkb_compose_table; |
430 | |
431 | pub fn xkb_compose_table_unref(table: *mut xkb_compose_table); |
432 | |
433 | pub fn xkb_compose_state_new( |
434 | table: *mut xkb_compose_table, |
435 | flags: xkb_compose_state_flags, |
436 | ) -> *mut xkb_compose_state; |
437 | |
438 | pub fn xkb_compose_state_ref(state: *mut xkb_compose_state) -> *mut xkb_compose_state; |
439 | |
440 | pub fn xkb_compose_state_unref(state: *mut xkb_compose_state); |
441 | |
442 | pub fn xkb_compose_state_get_compose_table( |
443 | state: *mut xkb_compose_state, |
444 | ) -> *mut xkb_compose_table; |
445 | |
446 | pub fn xkb_compose_state_feed( |
447 | state: *mut xkb_compose_state, |
448 | keysym: xkb_keysym_t, |
449 | ) -> xkb_compose_feed_result; |
450 | |
451 | pub fn xkb_compose_state_reset(state: *mut xkb_compose_state); |
452 | |
453 | pub fn xkb_compose_state_get_status(state: *mut xkb_compose_state) -> xkb_compose_status; |
454 | |
455 | pub fn xkb_compose_state_get_utf8( |
456 | state: *mut xkb_compose_state, |
457 | buffer: *mut c_char, |
458 | size: size_t, |
459 | ) -> c_int; |
460 | |
461 | pub fn xkb_compose_state_get_one_sym(state: *mut xkb_compose_state) -> xkb_keysym_t; |
462 | |
463 | } |
464 | } |
465 | |