From b33e9ca3a7c1ff837a0fe63e7286ef27b20d27f9 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 1 Jan 2022 17:56:46 +0100 Subject: [PATCH] hidmousecli --- app/src/cli.c | 20 ++++++++++++++++++++ app/src/options.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/app/src/cli.c b/app/src/cli.c index fc86015a..3bf03587 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -214,6 +214,17 @@ static const struct sc_option options[] = { .text = "Limit the frame rate of screen capture (officially supported " "since Android 10, but may work on earlier versions).", }, + { + .shortopt = 'M', + .longopt = "hid-mouse", + .text = "Simulate a physical mouse by using HID over AOAv2.\n" + "In this mode, the computer mouse is captured to control the " + "device directly (relative mouse mode).\n" + "LAlt, LSuper or RSuper toggle the capture mode, to give " + "control of the mouse back to the computer.\n" + "It may only work over USB, and is currently only supported " + "on Linux.\n", + }, { .shortopt = 'm', .longopt = "max-size", @@ -1315,6 +1326,15 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], return false; } break; + case 'M': +#ifdef HAVE_AOA_HID + opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_HID; +#else + LOGE("HID over AOA (-M/--hid-mouse) is not supported on this" + "platform. It is only available on Linux."); + return false; +#endif + break; case OPT_LOCK_VIDEO_ORIENTATION: if (!parse_lock_video_orientation(optarg, &opts->lock_video_orientation)) { diff --git a/app/src/options.h b/app/src/options.h index 533f4a3b..b2c69664 100644 --- a/app/src/options.h +++ b/app/src/options.h @@ -38,6 +38,11 @@ enum sc_keyboard_input_mode { SC_KEYBOARD_INPUT_MODE_HID, }; +enum sc_mouse_input_mode { + SC_MOUSE_INPUT_MODE_INJECT, + SC_MOUSE_INPUT_MODE_HID, +}; + enum sc_key_inject_mode { // Inject special keys, letters and space as key events. // Inject numbers and punctuation as text events. @@ -90,6 +95,7 @@ struct scrcpy_options { enum sc_log_level log_level; enum sc_record_format record_format; enum sc_keyboard_input_mode keyboard_input_mode; + enum sc_mouse_input_mode mouse_input_mode; struct sc_port_range port_range; uint32_t tunnel_host; uint16_t tunnel_port;