Make HID keyboard and mouse optional in OTG mode
Allow to only enable HID keyboard or HID mouse:
scrcpy --otg -K # keyboard only
scrcpy --otg -M # mouse only
scrcpy --otg -KM # keyboard and mouse
scrcpy --otg # keyboard and mouse
PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974>
This commit is contained in:
@@ -134,17 +134,32 @@ scrcpy_otg(struct scrcpy_options *options) {
|
||||
}
|
||||
aoa_initialized = true;
|
||||
|
||||
ok = sc_hid_keyboard_init(&s->keyboard, &s->aoa);
|
||||
if (!ok) {
|
||||
goto end;
|
||||
}
|
||||
keyboard = &s->keyboard;
|
||||
bool enable_keyboard =
|
||||
options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_HID;
|
||||
bool enable_mouse =
|
||||
options->mouse_input_mode == SC_MOUSE_INPUT_MODE_HID;
|
||||
|
||||
ok = sc_hid_mouse_init(&s->mouse, &s->aoa);
|
||||
if (!ok) {
|
||||
goto end;
|
||||
// If neither --hid-keyboard or --hid-mouse is passed, enable both
|
||||
if (!enable_keyboard && !enable_mouse) {
|
||||
enable_keyboard = true;
|
||||
enable_mouse = true;
|
||||
}
|
||||
|
||||
if (enable_keyboard) {
|
||||
ok = sc_hid_keyboard_init(&s->keyboard, &s->aoa);
|
||||
if (!ok) {
|
||||
goto end;
|
||||
}
|
||||
keyboard = &s->keyboard;
|
||||
}
|
||||
|
||||
if (enable_mouse) {
|
||||
ok = sc_hid_mouse_init(&s->mouse, &s->aoa);
|
||||
if (!ok) {
|
||||
goto end;
|
||||
}
|
||||
mouse = &s->mouse;
|
||||
}
|
||||
mouse = &s->mouse;
|
||||
|
||||
ok = sc_aoa_start(&s->aoa);
|
||||
if (!ok) {
|
||||
|
||||
Reference in New Issue
Block a user