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
extern crate libc;
#[macro_use]
extern crate ioctl;
mod events;
pub use events::*;
use libc::{c_char, c_int, c_uint, uint16_t, int32_t, uint32_t};
pub const UINPUT_MAX_NAME_SIZE: c_int = 80;
#[repr(C)]
pub struct input_id {
pub bustype: uint16_t,
pub vendor: uint16_t,
pub product: uint16_t,
pub version: uint16_t,
}
#[repr(C)]
pub struct uinput_user_dev {
pub name: [c_char; UINPUT_MAX_NAME_SIZE as usize],
pub id: input_id,
pub ff_effects_max: uint32_t,
pub absmax: [int32_t; ABS_CNT as usize],
pub absmin: [int32_t; ABS_CNT as usize],
pub absfuzz: [int32_t; ABS_CNT as usize],
pub absflat: [int32_t; ABS_CNT as usize],
}
ioctl!(none ui_dev_create with b'U', 1);
ioctl!(none ui_dev_destroy with b'U', 2);
ioctl!(write ui_set_evbit with b'U', 100; c_int);
ioctl!(write ui_set_keybit with b'U', 101; c_int);
ioctl!(write ui_set_absbit with b'U', 102; c_int);
ioctl!(write ui_set_relbit with b'U', 103; c_int);
ioctl!(write ui_set_mscbit with b'U', 104; c_int);
ioctl!(write ui_set_ledbit with b'U', 105; c_int);
ioctl!(write ui_set_sndbit with b'U', 106; c_int);
ioctl!(write ui_set_ffbit with b'U', 107; c_int);
ioctl!(write ui_set_phys with b'U', 108; *const c_char);
ioctl!(write ui_set_swbit with b'U', 109; c_int);
ioctl!(write ui_set_propbit with b'U', 110; c_int);
ioctl!(read ui_get_version with b'U', 45; c_uint);