Skip to content

Commit 25bb07b

Browse files
committed
Do not fallback keyboard mode if AOA fails
Initially, if AOA initialization failed, default injection method was used, in order to use the same command/shortcut when the device is connected via USB or via TCP/IP, without changing the arguments. Now that there are 3 keyboard modes, it seems unexpected to switch to another specific mode if AOA fails (and it is inconsistent). If the user explicitly requests AOA, then use AOA or fail. Refs #2632 comment <#2632 (comment)>
1 parent f9df7b2 commit 25bb07b

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

app/src/scrcpy.c

+5-28
Original file line numberDiff line numberDiff line change
@@ -570,15 +570,15 @@ scrcpy(struct scrcpy_options *options) {
570570
if (!ok) {
571571
LOGE("Failed to initialize USB");
572572
sc_acksync_destroy(&s->acksync);
573-
goto aoa_hid_end;
573+
goto end;
574574
}
575575

576576
assert(serial);
577577
struct sc_usb_device usb_device;
578578
ok = sc_usb_select_device(&s->usb, serial, &usb_device);
579579
if (!ok) {
580580
sc_usb_destroy(&s->usb);
581-
goto aoa_hid_end;
581+
goto end;
582582
}
583583

584584
LOGI("USB device: %s (%04" PRIx16 ":%04" PRIx16 ") %s %s",
@@ -591,7 +591,7 @@ scrcpy(struct scrcpy_options *options) {
591591
LOGE("Failed to connect to USB device %s", serial);
592592
sc_usb_destroy(&s->usb);
593593
sc_acksync_destroy(&s->acksync);
594-
goto aoa_hid_end;
594+
goto end;
595595
}
596596

597597
ok = sc_aoa_init(&s->aoa, &s->usb, &s->acksync);
@@ -600,7 +600,7 @@ scrcpy(struct scrcpy_options *options) {
600600
sc_usb_disconnect(&s->usb);
601601
sc_usb_destroy(&s->usb);
602602
sc_acksync_destroy(&s->acksync);
603-
goto aoa_hid_end;
603+
goto end;
604604
}
605605

606606
if (use_keyboard_aoa) {
@@ -628,41 +628,18 @@ scrcpy(struct scrcpy_options *options) {
628628
sc_usb_disconnect(&s->usb);
629629
sc_usb_destroy(&s->usb);
630630
sc_aoa_destroy(&s->aoa);
631-
goto aoa_hid_end;
631+
goto end;
632632
}
633633

634634
acksync = &s->acksync;
635635

636636
aoa_hid_initialized = true;
637-
638-
aoa_hid_end:
639-
if (!aoa_hid_initialized) {
640-
if (keyboard_aoa_initialized) {
641-
sc_keyboard_aoa_destroy(&s->keyboard_aoa);
642-
keyboard_aoa_initialized = false;
643-
}
644-
if (mouse_aoa_initialized) {
645-
sc_mouse_aoa_destroy(&s->mouse_aoa);
646-
mouse_aoa_initialized = false;
647-
}
648-
}
649-
650-
if (use_keyboard_aoa && !keyboard_aoa_initialized) {
651-
LOGE("Fallback to --keyboard=sdk (--keyboard=aoa ignored)");
652-
options->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_SDK;
653-
}
654-
655-
if (use_mouse_aoa && !mouse_aoa_initialized) {
656-
LOGE("Fallback to --keyboard=sdk (--keyboard=aoa ignored)");
657-
options->mouse_input_mode = SC_MOUSE_INPUT_MODE_SDK;
658-
}
659637
}
660638
#else
661639
assert(options->keyboard_input_mode != SC_KEYBOARD_INPUT_MODE_AOA);
662640
assert(options->mouse_input_mode != SC_MOUSE_INPUT_MODE_AOA);
663641
#endif
664642

665-
// keyboard_input_mode may have been reset if AOA mode failed
666643
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_SDK) {
667644
sc_keyboard_sdk_init(&s->keyboard_sdk, &s->controller,
668645
options->key_inject_mode,

0 commit comments

Comments
 (0)