Skip to main content

kdeconnect_proto/packet/
mousepad.rs

1//! The MousePad plugin allows remote control of the pointer and keyboard.
2use serde::{Deserialize, Serialize};
3
4#[cfg(not(feature = "std"))]
5use alloc::string::String;
6
7/// This packet is an echo for a kdeconnect.mousepad.request packet.
8///
9/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectmousepadecho>
10#[derive(Serialize, Deserialize, Debug, Clone)]
11#[serde(rename_all = "camelCase")]
12pub struct MousepadEchoPacket {
13    /// A request to press-release a single readable character, which may be a unicode character and thus more than one byte.
14    #[serde(skip_serializing_if = "Option::is_none")]
15    #[serde(default)]
16    pub key: Option<String>,
17
18    /// A request to press-release a single non-printable character, usually a control character or function key such as Backspace or F10.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    #[serde(default)]
21    pub special_key: Option<u8>,
22
23    /// Indicates whether the Alt modifier should be applied to the associated key or specialKey.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    #[serde(default)]
26    pub alt: Option<bool>,
27
28    /// Indicates whether the Control modifier should be applied to the associated key or specialKey.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    #[serde(default)]
31    pub ctrl: Option<bool>,
32
33    /// Indicates whether the Shift modifier should be applied to the associated key or specialKey.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    #[serde(default)]
36    pub shift: Option<bool>,
37
38    /// Indicates whether the Super modifier should be applied to the associated key or specialKey.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(default)]
41    #[serde(rename = "super")]
42    pub super_: Option<bool>,
43
44    /// A single press-release of the primary pointer button.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    #[serde(default)]
47    pub singleclick: Option<bool>,
48
49    /// A double press-release of the primary pointer button.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    #[serde(default)]
52    pub doubleclick: Option<bool>,
53
54    /// A single press-release of the middle pointer button.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    #[serde(default)]
57    pub middleclick: Option<bool>,
58
59    /// A single press-release of the secondary pointer button.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    #[serde(default)]
62    pub rightclick: Option<bool>,
63
64    /// A single press of the primary pointer button.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    #[serde(default)]
67    pub singlehold: Option<bool>,
68
69    /// A single release of the primary pointer button.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    #[serde(default)]
72    pub singlerelease: Option<bool>,
73
74    /// A double precision integer indicating a relative position delta for the pointer on the X-axis.
75    #[serde(skip_serializing_if = "Option::is_none")]
76    #[serde(default)]
77    pub dx: Option<i64>,
78
79    /// A double precision integer indicating a relative position delta for the pointer on the Y-axis.
80    #[serde(skip_serializing_if = "Option::is_none")]
81    #[serde(default)]
82    pub dy: Option<i64>,
83
84    /// Whether the associated dx or dy movement is a scroll event.
85    #[serde(skip_serializing_if = "Option::is_none")]
86    #[serde(default)]
87    pub scroll: Option<bool>,
88
89    /// Indicates the packet is a confirmation of a request. Always true and always present.
90    pub is_ack: bool,
91}
92
93/// This packet is a keyboard status update.
94///
95/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectmousepadkeyboardstate>
96#[derive(Serialize, Deserialize, Debug, Clone)]
97#[serde(rename_all = "camelCase")]
98pub struct MousepadKeyboardStatePacket {
99    /// Indicates the keyboard is ready to receive keypress events.
100    pub state: bool,
101}
102
103/// This packet is a request for a pointer or keyboard event.
104///
105/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectmousepadrequest>
106#[derive(Serialize, Deserialize, Debug, Clone)]
107#[serde(rename_all = "camelCase")]
108pub struct MousepadRequestPacket {
109    /// A request to press-release a single readable character, which may be a unicode character and thus more than one byte.
110    #[serde(skip_serializing_if = "Option::is_none")]
111    #[serde(default)]
112    pub key: Option<String>,
113
114    /// A request to press-release a single non-printable character, usually a control character or function key such as Backspace or F10.
115    #[serde(skip_serializing_if = "Option::is_none")]
116    #[serde(default)]
117    pub special_key: Option<u8>,
118
119    /// Indicates whether the Alt modifier should be applied to the associated key or specialKey.
120    #[serde(skip_serializing_if = "Option::is_none")]
121    #[serde(default)]
122    pub alt: Option<bool>,
123
124    /// Indicates whether the Control modifier should be applied to the associated key or specialKey.
125    #[serde(skip_serializing_if = "Option::is_none")]
126    #[serde(default)]
127    pub ctrl: Option<bool>,
128
129    /// Indicates whether the Shift modifier should be applied to the associated key or specialKey.
130    #[serde(skip_serializing_if = "Option::is_none")]
131    #[serde(default)]
132    pub shift: Option<bool>,
133
134    /// Indicates whether the Super modifier should be applied to the associated key or specialKey.
135    #[serde(skip_serializing_if = "Option::is_none")]
136    #[serde(default)]
137    #[serde(rename = "super")]
138    pub super_: Option<bool>,
139
140    /// A single press-release of the primary pointer button.
141    #[serde(skip_serializing_if = "Option::is_none")]
142    #[serde(default)]
143    pub singleclick: Option<bool>,
144
145    /// A double press-release of the primary pointer button.
146    #[serde(skip_serializing_if = "Option::is_none")]
147    #[serde(default)]
148    pub doubleclick: Option<bool>,
149
150    /// A single press-release of the middle pointer button.
151    #[serde(skip_serializing_if = "Option::is_none")]
152    #[serde(default)]
153    pub middleclick: Option<bool>,
154
155    /// A single press-release of the secondary pointer button.
156    #[serde(skip_serializing_if = "Option::is_none")]
157    #[serde(default)]
158    pub rightclick: Option<bool>,
159
160    /// A single press of the primary pointer button.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    #[serde(default)]
163    pub singlehold: Option<bool>,
164
165    /// A single release of the primary pointer button.
166    #[serde(skip_serializing_if = "Option::is_none")]
167    #[serde(default)]
168    pub singlerelease: Option<bool>,
169
170    /// A double precision integer indicating a position delta on the X-axis.
171    #[serde(skip_serializing_if = "Option::is_none")]
172    #[serde(default)]
173    pub dx: Option<i64>,
174
175    /// A double precision integer indicating a position delta on the Y-axis.
176    #[serde(skip_serializing_if = "Option::is_none")]
177    #[serde(default)]
178    pub dy: Option<i64>,
179
180    /// Whether the associated dx or dy movement is a scroll event.
181    #[serde(skip_serializing_if = "Option::is_none")]
182    #[serde(default)]
183    pub scroll: Option<bool>,
184
185    /// Indicates that the devices wants a kdeconnect.mousepad.echo packet as confirmation of a keyboard event.
186    #[serde(skip_serializing_if = "Option::is_none")]
187    #[serde(default)]
188    pub send_ack: Option<bool>,
189}