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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#![deny(missing_docs)]
#![doc(html_root_url = "https://docs.rs/input-linux/0.6.0/")]
#![cfg_attr(feature = "dox", feature(doc_cfg))]
pub use input_linux_sys as sys;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize, };
#[macro_use]
mod macros;
mod kinds;
pub use crate::kinds::*;
mod time;
pub use crate::time::EventTime;
mod events;
pub use crate::events::*;
mod keys;
pub use crate::keys::Key;
pub mod evdev;
pub use crate::evdev::EvdevHandle;
pub mod uinput;
pub use crate::uinput::UInputHandle;
pub mod enum_iterator;
pub mod bitmask;
pub use crate::bitmask::Bitmask;
#[cfg(feature = "codec")]
#[cfg_attr(feature = "dox", doc(cfg(feature = "codec")))]
mod codec;
#[cfg(feature = "codec")]
pub use crate::codec::EventCodec;
#[repr(C)]
#[derive(Copy, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct InputId {
pub bustype: u16,
pub vendor: u16,
pub product: u16,
pub version: u16,
}
impl<'a> From<&'a sys::input_id> for &'a InputId {
fn from(id: &'a sys::input_id) -> Self {
let raw = id as *const _ as *const _;
unsafe { &*raw }
}
}
impl<'a> From<&'a InputId> for &'a sys::input_id {
fn from(id: &'a InputId) -> Self {
let raw = id as *const _ as *const _;
unsafe { &*raw }
}
}
impl From<sys::input_id> for InputId {
fn from(id: sys::input_id) -> Self {
*<&InputId>::from(&id)
}
}
impl From<InputId> for sys::input_id {
fn from(id: InputId) -> Self {
*<&sys::input_id>::from(&id)
}
}
#[repr(C)]
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct AbsoluteInfoSetup {
pub axis: AbsoluteAxis,
pub info: AbsoluteInfo,
}
impl<'a> From<&'a AbsoluteInfoSetup> for &'a sys::uinput_abs_setup {
fn from(info: &'a AbsoluteInfoSetup) -> Self {
let raw = info as *const _ as *const _;
unsafe { &*raw }
}
}
impl From<AbsoluteInfoSetup> for sys::uinput_abs_setup {
fn from(info: AbsoluteInfoSetup) -> Self {
use std::mem;
unsafe {
mem::transmute(info)
}
}
}
#[repr(C)]
#[derive(Copy, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct AbsoluteInfo {
pub value: i32,
pub minimum: i32,
pub maximum: i32,
pub fuzz: i32,
pub flat: i32,
pub resolution: i32,
}
impl<'a> From<&'a sys::input_absinfo> for &'a AbsoluteInfo {
fn from(info: &'a sys::input_absinfo) -> Self {
let raw = info as *const _ as *const _;
unsafe { &*raw }
}
}
impl<'a> From<&'a AbsoluteInfo> for &'a sys::input_absinfo {
fn from(info: &'a AbsoluteInfo) -> Self {
let raw = info as *const _ as *const _;
unsafe { &*raw }
}
}
impl From<sys::input_absinfo> for AbsoluteInfo {
fn from(info: sys::input_absinfo) -> Self {
*<&AbsoluteInfo>::from(&info)
}
}
impl From<AbsoluteInfo> for sys::input_absinfo {
fn from(info: AbsoluteInfo) -> Self {
*<&sys::input_absinfo>::from(&info)
}
}