mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 13:34:20 +01:00
Add UHID_DESTROY control message
This message will be sent on gamepad disconnection. Contrary to keyboard and mouse devices, which are registered once and unregistered when scrcpy exists, each physical gamepad is mapped with its own HID id, and they can be plugged and unplugged dynamically. PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
This commit is contained in:
@@ -370,6 +370,25 @@ static void test_serialize_uhid_input(void) {
|
||||
assert(!memcmp(buf, expected, sizeof(expected)));
|
||||
}
|
||||
|
||||
static void test_serialize_uhid_destroy(void) {
|
||||
struct sc_control_msg msg = {
|
||||
.type = SC_CONTROL_MSG_TYPE_UHID_DESTROY,
|
||||
.uhid_destroy = {
|
||||
.id = 42,
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t buf[SC_CONTROL_MSG_MAX_SIZE];
|
||||
size_t size = sc_control_msg_serialize(&msg, buf);
|
||||
assert(size == 3);
|
||||
|
||||
const uint8_t expected[] = {
|
||||
SC_CONTROL_MSG_TYPE_UHID_DESTROY,
|
||||
0, 42, // id
|
||||
};
|
||||
assert(!memcmp(buf, expected, sizeof(expected)));
|
||||
}
|
||||
|
||||
static void test_serialize_open_hard_keyboard(void) {
|
||||
struct sc_control_msg msg = {
|
||||
.type = SC_CONTROL_MSG_TYPE_OPEN_HARD_KEYBOARD_SETTINGS,
|
||||
@@ -405,6 +424,7 @@ int main(int argc, char *argv[]) {
|
||||
test_serialize_rotate_device();
|
||||
test_serialize_uhid_create();
|
||||
test_serialize_uhid_input();
|
||||
test_serialize_uhid_destroy();
|
||||
test_serialize_open_hard_keyboard();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user