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
use bitfield::bitfield;
#[repr(u8)]
#[allow(unused)]
#[derive(Copy, Debug, Clone, Eq, PartialEq)]
pub enum GlobalItemKind {
UsagePage = 0,
LogicalMin = 1,
LogicalMax = 2,
PhysicalMin = 3,
PhysicalMax = 4,
UnitExponent = 5,
Unit = 6,
ReportSize = 7,
ReportID = 8,
ReportCount = 9,
}
impl Into<u8> for GlobalItemKind {
fn into(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
#[repr(u8)]
#[allow(unused)]
#[derive(Copy, Debug, Clone, Eq, PartialEq)]
pub enum MainItemKind {
Input = 0b1000,
Output = 0b1001,
Feature = 0b1011,
Collection = 0b1010,
EndCollection = 0b1100,
}
impl Into<u8> for MainItemKind {
fn into(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl Default for MainItemKind {
fn default() -> Self { MainItemKind::Input }
}
impl Into<MainItemKind> for String {
fn into(self) -> MainItemKind {
match self.as_str() {
"feature" => MainItemKind::Feature,
"output" => MainItemKind::Output,
"collection" => MainItemKind::Collection,
"ecollection" => MainItemKind::EndCollection,
"input" => MainItemKind::Input,
_ => MainItemKind::Input,
}
}
}
#[repr(u8)]
#[allow(unused)]
#[derive(Copy, Debug, Clone, Eq, PartialEq)]
pub enum ItemType {
Main = 0,
Global = 1,
Local = 2,
}
impl Into<u8> for ItemType {
fn into(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl Default for ItemType {
fn default() -> Self { ItemType::Main }
}
bitfield! {
pub struct MainItemSetting(u8);
impl Debug;
pub is_constant, set_constant: 0;
pub is_variable, set_variable: 1;
pub is_relative, set_relative: 2;
pub is_wrap, set_wrap: 3;
pub is_linear, set_linear: 4;
pub has_preferred_state, set_has_preferred_state: 5;
pub has_null_state, set_has_null_state: 6;
pub volatile, set_volatile: 7;
}
bitfield! {
pub struct ItemPrefix(u8);
impl Debug;
pub byte_count, set_byte_count: 1, 0;
pub typ, set_type: 3, 2;
pub tag, set_tag: 7, 4;
}