1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
mod consts;
pub mod keyboard {
pub use super::consts::Key;
use Modifiers;
use ffi;
use std::mem;
use std::slice;
pub use xkbcommon::xkb::{Keymap, Keysym, State};
pub use xkbcommon::xkb::keysyms as Keysyms;
pub fn xkb_state() -> State {
unsafe { State::from_raw_ptr(ffi::wlc_keyboard_get_xkb_state() as *mut _) }
}
pub fn xkb_keymap() -> Keymap {
unsafe { Keymap::from_raw_ptr(ffi::wlc_keyboard_get_xkb_keymap() as *mut _) }
}
pub fn current_keys<'a>() -> &'a [Key] {
let mut len = 0;
unsafe {
let ptr = ffi::wlc_keyboard_get_current_keys(&mut len as *mut _) as *const Key;
slice::from_raw_parts(ptr, len)
}
}
pub fn keysym_for_key(key: Key, modifiers: Modifiers) -> Keysym {
unsafe {
ffi::wlc_keyboard_get_keysym_for_key(key as u32,
mem::transmute::<&Modifiers,
&ffi::wlc_modifiers>(&modifiers) as
*const _)
}
}
pub fn utf32_for_key(key: Key, modifiers: Modifiers) -> u32 {
unsafe {
ffi::wlc_keyboard_get_utf32_for_key(key as u32,
mem::transmute::<&Modifiers,
&ffi::wlc_modifiers>(&modifiers) as
*const _)
}
}
}
pub mod pointer {
pub use super::consts::Button;
use Point;
use ffi;
use std::mem;
pub fn position() -> Point {
unsafe {
let mut point: ffi::wlc_point = mem::uninitialized();
ffi::wlc_pointer_get_position(&mut point as *mut _);
Point::from_ffi(&point)
}
}
pub fn set_position(position: Point) {
unsafe { ffi::wlc_pointer_set_position(&position.into_ffi() as *const _) }
}
}