@@ -12,15 +12,31 @@ const GET_STATUS_BYTE: u8 = 0x20;
12
12
const SET_STATUS_BYTE : u8 = 0x60 ;
13
13
14
14
bitflags ! {
15
+ /// Represents the flags currently set for the mouse.
15
16
#[ derive( Default ) ]
16
17
pub struct MouseFlags : u8 {
18
+ /// Whether or not the left mouse button is pressed.
17
19
const LEFT_BUTTON = 0b0000_0001 ;
20
+
21
+ /// Whether or not the right mouse button is pressed.
18
22
const RIGHT_BUTTON = 0b0000_0010 ;
23
+
24
+ /// Whether or not the middle mouse button is pressed.
19
25
const MIDDLE_BUTTON = 0b0000_0100 ;
26
+
27
+ /// Whether or not the packet is valid or not.
20
28
const ALWAYS_ONE = 0b0000_1000 ;
29
+
30
+ /// Whether or not the x delta is negative.
21
31
const X_SIGN = 0b0001_0000 ;
32
+
33
+ /// Whether or not the y delta is negative.
22
34
const Y_SIGN = 0b0010_0000 ;
35
+
36
+ /// Whether or not the x delta overflowed.
23
37
const X_OVERFLOW = 0b0100_0000 ;
38
+
39
+ /// Whether or not the y delta overflowed.
24
40
const Y_OVERFLOW = 0b1000_0000 ;
25
41
}
26
42
}
@@ -42,6 +58,12 @@ pub struct Mouse {
42
58
on_complete : Option < fn ( MouseState ) > ,
43
59
}
44
60
61
+ impl Default for Mouse {
62
+ fn default ( ) -> Mouse {
63
+ Mouse :: new ( )
64
+ }
65
+ }
66
+
45
67
/// A snapshot of the mouse flags, x delta and y delta.
46
68
#[ derive( Debug , Copy , Clone , Default ) ]
47
69
pub struct MouseState {
0 commit comments