Skip to content

Commit

Permalink
Forbid HID input without OTG on Windows
Browse files Browse the repository at this point in the history
On Windows, if the adb daemon is running, opening the USB device will
necessarily fail, so HID input is not possible.

Refs #2773 <#2773>
  • Loading branch information
rom1v committed Feb 10, 2022
1 parent db4f659 commit 51b94a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,18 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
}

#ifdef HAVE_USB

# ifdef _WIN32
if (!opts->otg && (opts->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_HID
|| opts->mouse_input_mode == SC_MOUSE_INPUT_MODE_HID)) {
LOGE("On Windows, it is not possible to open a USB device already open "
"by another process (like adb).");
LOGE("Therefore, -K/--hid-keyboard and -M/--hid-mouse may only work in "
"OTG mode (--otg).");
return false;
}
# endif

if (opts->otg) {
// OTG mode is compatible with only very few options.
// Only report obvious errors.
Expand Down

0 comments on commit 51b94a4

Please sign in to comment.