From ca9e1a05148d46793de0118a8cbcef62877df534 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 12 Feb 2022 12:38:40 +0100 Subject: [PATCH] Add compilation flag for USB features This allows to disable HID/OTG features on Linux to build without libusb. --- app/meson.build | 2 +- app/src/cli.c | 12 ++++++------ meson_options.txt | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/meson.build b/app/meson.build index ef7a467e..9ee38d5f 100644 --- a/app/meson.build +++ b/app/meson.build @@ -74,7 +74,7 @@ if v4l2_support src += [ 'src/v4l2_sink.c' ] endif -usb_support = host_machine.system() == 'linux' +usb_support = get_option('usb') and host_machine.system() == 'linux' if usb_support src += [ 'src/usb/aoa_hid.c', diff --git a/app/src/cli.c b/app/src/cli.c index 19e21324..63f4a4ed 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -1357,8 +1357,8 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], opts->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_HID; break; #else - LOGE("HID over AOA (-K/--hid-keyboard) is not supported on " - "this platform. It is only available on Linux."); + LOGE("HID over AOA (-K/--hid-keyboard) is disabled (or " + "unsupported on this platform)."); return false; #endif case OPT_MAX_FPS: @@ -1376,8 +1376,8 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_HID; break; #else - LOGE("HID over AOA (-M/--hid-mouse) is not supported on this" - "platform. It is only available on Linux."); + LOGE("HID over AOA (-M/--hid-mouse) is disabled (or " + "unsupported on this platform)."); return false; #endif case OPT_LOCK_VIDEO_ORIENTATION: @@ -1540,8 +1540,8 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], opts->otg = true; break; #else - LOGE("OTG mode (--otg) is not supported on this platform. It " - "is only available on Linux."); + LOGE("OTG mode (--otg) is disabled (or unsupported on this " + "platform)."); return false; #endif case OPT_V4L2_SINK: diff --git a/meson_options.txt b/meson_options.txt index 13227d8a..d1030694 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,3 +5,4 @@ option('portable', type: 'boolean', value: false, description: 'Use scrcpy-serve option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached') option('server_debugger_method', type: 'combo', choices: ['old', 'new'], value: 'new', description: 'Select the debugger method (Android < 9: "old", Android >= 9: "new")') option('v4l2', type: 'boolean', value: true, description: 'Enable V4L2 feature when supported') +option('usb', type: 'boolean', value: true, description: 'Enable HID/OTG features when supported')