@@ -75,11 +75,19 @@ bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
75
75
76
76
static const uint8_t buttons_to_bits[] = {0 , 7 , 7 , 10 , 10 , 13 , 13 , 16 , 16 };
77
77
static const uint8_t bits_to_bits[] = {0 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 10 , 10 , 10 , 13 , 13 , 13 , 16 , 16 , 16 };
78
- int total_bits = std::max (buttons_to_bits[this ->num_buttons ], bits_to_bits[this ->num_bits ]);
78
+ int num_bits, total_bits;
79
+ // if the mouse is in standard protocol then only send first 2 bytes
80
+ // BUGBUG: what should tablet do here?
81
+ if (this ->device_class == MOUSE && this ->dev_handler_id == 1 ) {
82
+ num_bits = total_bits = 7 ;
83
+ } else {
84
+ num_bits = this ->num_bits ;
85
+ total_bits = std::max (buttons_to_bits[this ->num_buttons ], bits_to_bits[num_bits]);
86
+ }
79
87
uint8_t buttons_state = ~this ->buttons_state ;
80
88
81
89
for (int axis = 0 ; axis < 2 ; axis++) {
82
- int bits = this -> num_bits ;
90
+ int bits = num_bits;
83
91
int32_t val = axis ? this ->device_class == TABLET ? this ->x_abs : this ->x_rel
84
92
: this ->device_class == TABLET ? this ->y_abs : this ->y_rel ;
85
93
if (val < (-1 << (bits - 1 )))
@@ -107,13 +115,6 @@ bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
107
115
this ->changed = false ;
108
116
109
117
uint8_t count = (uint8_t )(p - out_buf);
110
- // should never happen, but check just in case
111
- if (((size_t )p - (size_t )out_buf) > UINT8_MAX)
112
- count = UINT8_MAX;
113
- // if the mouse is in standard protocol then only send first 2 bytes
114
- // BUGBUG: what should tablet do here?
115
- if (this ->device_class == MOUSE && this ->dev_handler_id == 1 )
116
- count = 2 ;
117
118
this ->host_obj ->set_output_count (count);
118
119
return should_update;
119
120
}
0 commit comments