@@ -53,17 +53,18 @@ enum MouseEvent {
5353 MiddleClick ,
5454 Cursor ( Direction ) ,
5555 Scroll ( Direction ) ,
56- SetSpeed ( u8 ) ,
56+ /// (cursor, scroll) speeds
57+ SetSpeed ( ( i8 , i8 ) ) ,
5758}
5859struct MouseReportBuilder {
5960 cursor : ( i8 , i8 ) ,
6061 buttons : [ bool ; 3 ] ,
6162 scroll_keys : [ ScrollKey ; 4 ] ,
6263 scroll_key_state : [ bool ; 4 ] ,
63- speed : i8 ,
64+ speed : ( i8 , i8 ) ,
6465}
6566impl MouseReportBuilder {
66- const DEFAULT_SPEED : i8 = 10 ;
67+ const DEFAULT_SPEED : ( i8 , i8 ) = ( 10 , 1 ) ;
6768
6869 const fn new ( ) -> Self {
6970 Self {
@@ -93,7 +94,7 @@ impl MouseReportBuilder {
9394 Left => self . scroll_key_state [ 2 ] = true ,
9495 Right => self . scroll_key_state [ 3 ] = true ,
9596 } ,
96- MouseEvent :: SetSpeed ( val) => self . speed = val as i8 ,
97+ MouseEvent :: SetSpeed ( val) => self . speed = val,
9798 }
9899 }
99100
@@ -109,7 +110,7 @@ impl MouseReportBuilder {
109110 . map ( |( i, pressed) | * pressed as u8 * ( 1 << i) )
110111 . sum :: < u8 > ( ) ;
111112 //Divide by sqrt(2) if the cursor speed is two dimensional
112- let mut cursor_speed = self . speed ;
113+ let ( mut cursor_speed, scroll_speed ) = self . speed ;
113114 if self . cursor . 0 != 0 && self . cursor . 1 != 0 {
114115 cursor_speed = cursor_speed. saturating_mul ( 10 ) ;
115116 cursor_speed /= 14 ;
@@ -118,9 +119,9 @@ impl MouseReportBuilder {
118119 }
119120 }
120121 let vertical_wheel =
121- ( self . scroll_key_state [ 0 ] as i8 - self . scroll_key_state [ 1 ] as i8 ) * self . speed ;
122+ ( self . scroll_key_state [ 0 ] as i8 - self . scroll_key_state [ 1 ] as i8 ) * scroll_speed ;
122123 let horizontal_wheel =
123- ( self . scroll_key_state [ 3 ] as i8 - self . scroll_key_state [ 2 ] as i8 ) * self . speed ;
124+ ( self . scroll_key_state [ 3 ] as i8 - self . scroll_key_state [ 2 ] as i8 ) * scroll_speed ;
124125 let report = WheelMouseReport {
125126 buttons,
126127 x : self . cursor . 0 * cursor_speed,
0 commit comments