ironrdp_pdu/input/
mouse_x.rs1use bitflags::bitflags;
2use ironrdp_core::{ensure_fixed_part_size, Decode, DecodeResult, Encode, EncodeResult, ReadCursor, WriteCursor};
3
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct MouseXPdu {
6 pub flags: PointerXFlags,
7 pub x_position: u16,
8 pub y_position: u16,
9}
10
11impl MouseXPdu {
12 const NAME: &'static str = "MouseXPdu";
13
14 const FIXED_PART_SIZE: usize = 2 + 2 + 2 ;
15}
16
17impl Encode for MouseXPdu {
18 fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> {
19 ensure_fixed_part_size!(in: dst);
20
21 dst.write_u16(self.flags.bits());
22 dst.write_u16(self.x_position);
23 dst.write_u16(self.y_position);
24
25 Ok(())
26 }
27
28 fn name(&self) -> &'static str {
29 Self::NAME
30 }
31
32 fn size(&self) -> usize {
33 Self::FIXED_PART_SIZE
34 }
35}
36
37impl<'de> Decode<'de> for MouseXPdu {
38 fn decode(src: &mut ReadCursor<'de>) -> DecodeResult<Self> {
39 ensure_fixed_part_size!(in: src);
40
41 let flags = PointerXFlags::from_bits_truncate(src.read_u16());
42 let x_position = src.read_u16();
43 let y_position = src.read_u16();
44
45 Ok(Self {
46 flags,
47 x_position,
48 y_position,
49 })
50 }
51}
52
53bitflags! {
54 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
55 pub struct PointerXFlags: u16 {
56 const DOWN = 0x8000;
57 const BUTTON1 = 0x0001;
58 const BUTTON2 = 0x0002;
59 }
60}