Fail on unsupported HID option
If the feature is not supported on the platform, fail during command line parsing instead of using a fallback.
This commit is contained in:
parent
37124e1452
commit
ba28d817fb
2 changed files with 10 additions and 7 deletions
|
@ -1300,7 +1300,13 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||||
args->help = true;
|
args->help = true;
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
|
#ifdef HAVE_AOA_HID
|
||||||
opts->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_HID;
|
opts->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_HID;
|
||||||
|
#else
|
||||||
|
LOGE("HID over AOA (-K/--hid-keyboard) is not supported on "
|
||||||
|
"this platform. It is only available on Linux.");
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case OPT_MAX_FPS:
|
case OPT_MAX_FPS:
|
||||||
if (!parse_max_fps(optarg, &opts->max_fps)) {
|
if (!parse_max_fps(optarg, &opts->max_fps)) {
|
||||||
|
|
|
@ -534,8 +534,8 @@ scrcpy(struct scrcpy_options *options) {
|
||||||
struct sc_mouse_processor *mp = NULL;
|
struct sc_mouse_processor *mp = NULL;
|
||||||
|
|
||||||
if (options->control) {
|
if (options->control) {
|
||||||
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_HID) {
|
|
||||||
#ifdef HAVE_AOA_HID
|
#ifdef HAVE_AOA_HID
|
||||||
|
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_HID) {
|
||||||
bool aoa_hid_ok = false;
|
bool aoa_hid_ok = false;
|
||||||
|
|
||||||
bool ok = sc_aoa_init(&s->aoa, serial, acksync);
|
bool ok = sc_aoa_init(&s->aoa, serial, acksync);
|
||||||
|
@ -566,13 +566,10 @@ aoa_hid_end:
|
||||||
"(-K/--hid-keyboard ignored)");
|
"(-K/--hid-keyboard ignored)");
|
||||||
options->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_INJECT;
|
options->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_INJECT;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
LOGE("HID over AOA is not supported on this platform, "
|
|
||||||
"fallback to default keyboard injection method "
|
|
||||||
"(-K/--hid-keyboard ignored)");
|
|
||||||
options->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_INJECT;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
assert(options->keyboard_input_mode != SC_KEYBOARD_INPUT_MODE_HID);
|
||||||
|
#endif
|
||||||
|
|
||||||
// keyboard_input_mode may have been reset if HID mode failed
|
// keyboard_input_mode may have been reset if HID mode failed
|
||||||
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_INJECT) {
|
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_INJECT) {
|
||||||
|
|
Loading…
Reference in a new issue