adbmouse: Use parameter for buttons state.

- Rename the parameter from buttons_state to buttons so it is not
  confused with the class data member.

- AdbAppleJack triggers should affect mouse button state in register 0.
  That means AdbMouse::get_register_0 needs to use the buttons parameter
  instead of the buttons_state class data member.
This commit is contained in:
joevt
2026-02-05 03:37:42 -08:00
committed by dingusdev
parent 626497bdc0
commit ff3e66ecd7
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -66,7 +66,7 @@ void AdbMouse::reset() {
this->changed = false;
}
bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
bool AdbMouse::get_register_0(uint8_t buttons, bool force) {
bool should_update = this->x_rel || this->y_rel || this->changed || force;
if (should_update) {
@@ -84,7 +84,7 @@ bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
num_bits = this->num_bits;
total_bits = std::max(buttons_to_bits[this->num_buttons], bits_to_bits[num_bits]);
}
uint8_t buttons_state = ~this->buttons_state;
buttons = ~buttons;
for (int axis = 0; axis < 2; axis++) {
int bits = num_bits;
@@ -100,7 +100,7 @@ bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
bits = 7;
while (bits_remaining > 0) {
*p = (val & ((1 << bits) - 1)) | (((buttons_state >> button) & 1) << bits) | (*p << (bits + 1));
*p = uint8_t((val & ((1 << bits) - 1)) | (((buttons >> button) & 1) << bits) | (*p << (bits + 1)));
val >>= bits;
bits_remaining -= bits;
p = bits == 7 ? &out_buf[2] : p + 1;
+1 -1
View File
@@ -70,7 +70,7 @@ enum DeviceClass {
void set_register_3() override;
protected:
bool get_register_0(uint8_t buttons_state, bool force);
bool get_register_0(uint8_t buttons, bool force);
uint8_t get_buttons_state() const;
private: