Merge pull request #75 from mihaip/upstream-extended-adb

Add basic support for the extended ADB mouse protocol.
This commit is contained in:
dingusdev 2023-12-15 18:02:56 -07:00 committed by GitHub
commit a14fbe865f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -88,6 +88,22 @@ bool AdbMouse::get_register_0() {
return false;
}
bool AdbMouse::get_register_1() {
uint8_t* out_buf = this->host_obj->get_output_buf();
// Identifier
out_buf[0] = 'a';
out_buf[1] = 'p';
out_buf[2] = 'p';
out_buf[3] = 'l';
// Slightly higher resolution of 300 units per inch
out_buf[4] = 300 >> 8;
out_buf[5] = 300 & 0xFF;
out_buf[6] = 1; // mouse
out_buf[7] = 1; // 1 button
this->host_obj->set_output_count(8);
return true;
}
void AdbMouse::set_register_3() {
if (this->host_obj->get_input_count() < 2) // ensure we got enough data
return;
@ -101,10 +117,9 @@ void AdbMouse::set_register_3() {
break;
case 1:
case 2:
case 4: // switch over to extended mouse protocol
this->dev_handler_id = in_data[1];
break;
case 4: // extended mouse protocol isn't supported yet
break;
case 0xFE: // move to a new address if there was no collision
if (!this->got_collision) {
this->my_addr = in_data[0] & 0xF;

View File

@ -45,6 +45,7 @@ public:
void event_handler(const MouseEvent& event);
bool get_register_0() override;
bool get_register_1() override;
void set_register_3() override;
private: