mirror of https://github.com/Genymobile/scrcpy
Make -K -M and -G use AOA in OTG mode
For convenience, short options were added to select UHID input modes: - -K for --keyboard=uhid - -M for --mouse=uhid - -G for --gamepad=uhid In OTG mode, UHID is not available, so the short options should select AOA instead. PR #5270 <https://github.com/Genymobile/scrcpy/pull/5270>
This commit is contained in:
parent
f9d1a333a0
commit
c4febd55eb
|
@ -33,10 +33,10 @@ arguments=(
|
||||||
{-e,--select-tcpip}'[Use TCP/IP device]'
|
{-e,--select-tcpip}'[Use TCP/IP device]'
|
||||||
{-f,--fullscreen}'[Start in fullscreen]'
|
{-f,--fullscreen}'[Start in fullscreen]'
|
||||||
'--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]'
|
'--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]'
|
||||||
'-G[Use UHID gamepad (same as --gamepad=uhid)]'
|
'-G[Use UHID/AOA gamepad (same as --gamepad=uhid or --gamepad=aoa, depending on OTG mode)]'
|
||||||
'--gamepad=[Set the gamepad input mode]:mode:(disabled uhid aoa)'
|
'--gamepad=[Set the gamepad input mode]:mode:(disabled uhid aoa)'
|
||||||
{-h,--help}'[Print the help]'
|
{-h,--help}'[Print the help]'
|
||||||
'-K[Use UHID keyboard (same as --keyboard=uhid)]'
|
'-K[Use UHID/AOA keyboard (same as --keyboard=uhid or --keyboard=aoa, depending on OTG mode)]'
|
||||||
'--keyboard=[Set the keyboard input mode]:mode:(disabled sdk uhid aoa)'
|
'--keyboard=[Set the keyboard input mode]:mode:(disabled sdk uhid aoa)'
|
||||||
'--kill-adb-on-close[Kill adb when scrcpy terminates]'
|
'--kill-adb-on-close[Kill adb when scrcpy terminates]'
|
||||||
'--legacy-paste[Inject computer clipboard text as a sequence of key events on Ctrl+v]'
|
'--legacy-paste[Inject computer clipboard text as a sequence of key events on Ctrl+v]'
|
||||||
|
@ -46,7 +46,7 @@ arguments=(
|
||||||
'--list-encoders[List video and audio encoders available on the device]'
|
'--list-encoders[List video and audio encoders available on the device]'
|
||||||
'--lock-video-orientation=[Lock video orientation]:orientation:(unlocked initial 0 90 180 270)'
|
'--lock-video-orientation=[Lock video orientation]:orientation:(unlocked initial 0 90 180 270)'
|
||||||
{-m,--max-size=}'[Limit both the width and height of the video to value]'
|
{-m,--max-size=}'[Limit both the width and height of the video to value]'
|
||||||
'-M[Use UHID mouse (same as --mouse=uhid)]'
|
'-M[Use UHID/AOA mouse (same as --mouse=uhid or --mouse=aoa, depending on OTG mode)]'
|
||||||
'--max-fps=[Limit the frame rate of screen capture]'
|
'--max-fps=[Limit the frame rate of screen capture]'
|
||||||
'--mouse=[Set the mouse input mode]:mode:(disabled sdk uhid aoa)'
|
'--mouse=[Set the mouse input mode]:mode:(disabled sdk uhid aoa)'
|
||||||
'--mouse-bind=[Configure bindings of secondary clicks]'
|
'--mouse-bind=[Configure bindings of secondary clicks]'
|
||||||
|
|
|
@ -176,8 +176,8 @@ Start in fullscreen.
|
||||||
Do not attempt to use "adb reverse" to connect to the device.
|
Do not attempt to use "adb reverse" to connect to the device.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-K
|
.B \-G
|
||||||
Same as \fB\-\-gamepad=uhid\fR.
|
Same as \fB\-\-gamepad=uhid\fR, or \fB\-\-keyboard=aoa\fR if \fB\-\-otg\fR is set.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-gamepad " mode
|
.BI "\-\-gamepad " mode
|
||||||
|
@ -196,7 +196,7 @@ Print this help.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-K
|
.B \-K
|
||||||
Same as \fB\-\-keyboard=uhid\fR.
|
Same as \fB\-\-keyboard=uhid\fR, or \fB\-\-keyboard=aoa\fR if \fB\-\-otg\fR is set.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-keyboard " mode
|
.BI "\-\-keyboard " mode
|
||||||
|
@ -261,7 +261,7 @@ Default is 0 (unlimited).
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-M
|
.B \-M
|
||||||
Same as \fB\-\-mouse=uhid\fR.
|
Same as \fB\-\-mouse=uhid\fR, or \fB\-\-mouse=aoa\fR if \fB\-\-otg\fR is set.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-max\-fps " value
|
.BI "\-\-max\-fps " value
|
||||||
|
|
|
@ -375,7 +375,7 @@ static const struct sc_option options[] = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.shortopt = 'G',
|
.shortopt = 'G',
|
||||||
.text = "Same as --gamepad=uhid.",
|
.text = "Same as --gamepad=uhid, or --gamepad=aoa if --otg is set.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.longopt_id = OPT_GAMEPAD,
|
.longopt_id = OPT_GAMEPAD,
|
||||||
|
@ -397,7 +397,7 @@ static const struct sc_option options[] = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.shortopt = 'K',
|
.shortopt = 'K',
|
||||||
.text = "Same as --keyboard=uhid.",
|
.text = "Same as --keyboard=uhid, or --keyboard=aoa if --otg is set.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.longopt_id = OPT_KEYBOARD,
|
.longopt_id = OPT_KEYBOARD,
|
||||||
|
@ -493,7 +493,7 @@ static const struct sc_option options[] = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.shortopt = 'M',
|
.shortopt = 'M',
|
||||||
.text = "Same as --mouse=uhid.",
|
.text = "Same as --mouse=uhid, or --mouse=aoa if --otg is set.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.longopt_id = OPT_MAX_FPS,
|
.longopt_id = OPT_MAX_FPS,
|
||||||
|
@ -2252,7 +2252,7 @@ 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':
|
||||||
opts->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_UHID;
|
opts->keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_UHID_OR_AOA;
|
||||||
break;
|
break;
|
||||||
case OPT_KEYBOARD:
|
case OPT_KEYBOARD:
|
||||||
if (!parse_keyboard(optarg, &opts->keyboard_input_mode)) {
|
if (!parse_keyboard(optarg, &opts->keyboard_input_mode)) {
|
||||||
|
@ -2272,7 +2272,7 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_UHID;
|
opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_UHID_OR_AOA;
|
||||||
break;
|
break;
|
||||||
case OPT_MOUSE:
|
case OPT_MOUSE:
|
||||||
if (!parse_mouse(optarg, &opts->mouse_input_mode)) {
|
if (!parse_mouse(optarg, &opts->mouse_input_mode)) {
|
||||||
|
@ -2657,7 +2657,7 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||||
opts->audio_dup = true;
|
opts->audio_dup = true;
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
opts->gamepad_input_mode = SC_GAMEPAD_INPUT_MODE_UHID;
|
opts->gamepad_input_mode = SC_GAMEPAD_INPUT_MODE_UHID_OR_AOA;
|
||||||
break;
|
break;
|
||||||
case OPT_GAMEPAD:
|
case OPT_GAMEPAD:
|
||||||
if (!parse_gamepad(optarg, &opts->gamepad_input_mode)) {
|
if (!parse_gamepad(optarg, &opts->gamepad_input_mode)) {
|
||||||
|
@ -2781,7 +2781,12 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||||
if (opts->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_AUTO) {
|
if (opts->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_AUTO) {
|
||||||
opts->keyboard_input_mode = otg ? SC_KEYBOARD_INPUT_MODE_AOA
|
opts->keyboard_input_mode = otg ? SC_KEYBOARD_INPUT_MODE_AOA
|
||||||
: SC_KEYBOARD_INPUT_MODE_SDK;
|
: SC_KEYBOARD_INPUT_MODE_SDK;
|
||||||
|
} else if (opts->keyboard_input_mode
|
||||||
|
== SC_KEYBOARD_INPUT_MODE_UHID_OR_AOA) {
|
||||||
|
opts->keyboard_input_mode = otg ? SC_KEYBOARD_INPUT_MODE_AOA
|
||||||
|
: SC_KEYBOARD_INPUT_MODE_UHID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->mouse_input_mode == SC_MOUSE_INPUT_MODE_AUTO) {
|
if (opts->mouse_input_mode == SC_MOUSE_INPUT_MODE_AUTO) {
|
||||||
if (otg) {
|
if (otg) {
|
||||||
opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_AOA;
|
opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_AOA;
|
||||||
|
@ -2791,11 +2796,18 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||||
} else {
|
} else {
|
||||||
opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_SDK;
|
opts->mouse_input_mode = SC_MOUSE_INPUT_MODE_SDK;
|
||||||
}
|
}
|
||||||
|
} else if (opts->mouse_input_mode == SC_MOUSE_INPUT_MODE_UHID_OR_AOA) {
|
||||||
|
opts->mouse_input_mode = otg ? SC_MOUSE_INPUT_MODE_AOA
|
||||||
|
: SC_MOUSE_INPUT_MODE_UHID;
|
||||||
} else if (opts->mouse_input_mode == SC_MOUSE_INPUT_MODE_SDK
|
} else if (opts->mouse_input_mode == SC_MOUSE_INPUT_MODE_SDK
|
||||||
&& !opts->video_playback) {
|
&& !opts->video_playback) {
|
||||||
LOGE("SDK mouse mode requires video playback. Try --mouse=uhid.");
|
LOGE("SDK mouse mode requires video playback. Try --mouse=uhid.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (opts->gamepad_input_mode == SC_GAMEPAD_INPUT_MODE_UHID_OR_AOA) {
|
||||||
|
opts->gamepad_input_mode = otg ? SC_GAMEPAD_INPUT_MODE_AOA
|
||||||
|
: SC_GAMEPAD_INPUT_MODE_UHID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If mouse bindings are not explicitly set, configure default bindings
|
// If mouse bindings are not explicitly set, configure default bindings
|
||||||
|
|
|
@ -142,6 +142,7 @@ enum sc_lock_video_orientation {
|
||||||
|
|
||||||
enum sc_keyboard_input_mode {
|
enum sc_keyboard_input_mode {
|
||||||
SC_KEYBOARD_INPUT_MODE_AUTO,
|
SC_KEYBOARD_INPUT_MODE_AUTO,
|
||||||
|
SC_KEYBOARD_INPUT_MODE_UHID_OR_AOA, // normal vs otg mode
|
||||||
SC_KEYBOARD_INPUT_MODE_DISABLED,
|
SC_KEYBOARD_INPUT_MODE_DISABLED,
|
||||||
SC_KEYBOARD_INPUT_MODE_SDK,
|
SC_KEYBOARD_INPUT_MODE_SDK,
|
||||||
SC_KEYBOARD_INPUT_MODE_UHID,
|
SC_KEYBOARD_INPUT_MODE_UHID,
|
||||||
|
@ -150,6 +151,7 @@ enum sc_keyboard_input_mode {
|
||||||
|
|
||||||
enum sc_mouse_input_mode {
|
enum sc_mouse_input_mode {
|
||||||
SC_MOUSE_INPUT_MODE_AUTO,
|
SC_MOUSE_INPUT_MODE_AUTO,
|
||||||
|
SC_MOUSE_INPUT_MODE_UHID_OR_AOA, // normal vs otg mode
|
||||||
SC_MOUSE_INPUT_MODE_DISABLED,
|
SC_MOUSE_INPUT_MODE_DISABLED,
|
||||||
SC_MOUSE_INPUT_MODE_SDK,
|
SC_MOUSE_INPUT_MODE_SDK,
|
||||||
SC_MOUSE_INPUT_MODE_UHID,
|
SC_MOUSE_INPUT_MODE_UHID,
|
||||||
|
@ -158,6 +160,7 @@ enum sc_mouse_input_mode {
|
||||||
|
|
||||||
enum sc_gamepad_input_mode {
|
enum sc_gamepad_input_mode {
|
||||||
SC_GAMEPAD_INPUT_MODE_DISABLED,
|
SC_GAMEPAD_INPUT_MODE_DISABLED,
|
||||||
|
SC_GAMEPAD_INPUT_MODE_UHID_OR_AOA, // normal vs otg mode
|
||||||
SC_GAMEPAD_INPUT_MODE_UHID,
|
SC_GAMEPAD_INPUT_MODE_UHID,
|
||||||
SC_GAMEPAD_INPUT_MODE_AOA,
|
SC_GAMEPAD_INPUT_MODE_AOA,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue