mirror of
https://github.com/Genymobile/scrcpy
synced 2024-11-11 01:10:32 +00:00
Forward all clicks by default for UHID/AOA
By default, only the left click is forwarded to the device, and secondary clicks trigger shortcuts (the behavior can be configured by --mouse-bind=xxxx). But when the mouse mode is relative (AOA and UHID modes), forward all clicks by default. This makes more sense since the cursor is handled on the device side, the user expects all mouse buttons to be forwarded. Refs <https://github.com/Genymobile/scrcpy/issues/4727#issuecomment-2069869750> PR #5022 <https://github.com/Genymobile/scrcpy/pull/5022>
This commit is contained in:
parent
035d60cf5d
commit
f5e6b8092a
@ -272,7 +272,7 @@ Each character must be one of the following:
|
|||||||
- 's': trigger shortcut APP_SWITCH
|
- 's': trigger shortcut APP_SWITCH
|
||||||
- 'n': trigger shortcut "expand notification panel"
|
- 'n': trigger shortcut "expand notification panel"
|
||||||
|
|
||||||
Default is 'bhsn'.
|
Default is 'bhsn' for SDK mouse, and '++++' for AOA and UHID.
|
||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
@ -504,7 +504,7 @@ static const struct sc_option options[] = {
|
|||||||
" 'h': trigger shortcut HOME\n"
|
" 'h': trigger shortcut HOME\n"
|
||||||
" 's': trigger shortcut APP_SWITCH\n"
|
" 's': trigger shortcut APP_SWITCH\n"
|
||||||
" 'n': trigger shortcut \"expand notification panel\"\n"
|
" 'n': trigger shortcut \"expand notification panel\"\n"
|
||||||
"Default is 'bhsn'.",
|
"Default is 'bhsn' for SDK mouse, and '++++' for AOA and UHID.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.shortopt = 'n',
|
.shortopt = 'n',
|
||||||
@ -2690,6 +2690,30 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If mouse bindings are not explictly set, configure default bindings
|
||||||
|
if (opts->mouse_bindings.right_click == SC_MOUSE_BINDING_AUTO) {
|
||||||
|
assert(opts->mouse_bindings.middle_click == SC_MOUSE_BINDING_AUTO);
|
||||||
|
assert(opts->mouse_bindings.click4 == SC_MOUSE_BINDING_AUTO);
|
||||||
|
assert(opts->mouse_bindings.click5 == SC_MOUSE_BINDING_AUTO);
|
||||||
|
|
||||||
|
// By default, forward all clicks only for UHID and AOA
|
||||||
|
if (opts->mouse_input_mode == SC_MOUSE_INPUT_MODE_SDK) {
|
||||||
|
opts->mouse_bindings = (struct sc_mouse_bindings) {
|
||||||
|
.right_click = SC_MOUSE_BINDING_BACK,
|
||||||
|
.middle_click = SC_MOUSE_BINDING_HOME,
|
||||||
|
.click4 = SC_MOUSE_BINDING_APP_SWITCH,
|
||||||
|
.click5 = SC_MOUSE_BINDING_EXPAND_NOTIFICATION_PANEL,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
opts->mouse_bindings = (struct sc_mouse_bindings) {
|
||||||
|
.right_click = SC_MOUSE_BINDING_CLICK,
|
||||||
|
.middle_click = SC_MOUSE_BINDING_CLICK,
|
||||||
|
.click4 = SC_MOUSE_BINDING_CLICK,
|
||||||
|
.click5 = SC_MOUSE_BINDING_CLICK,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (otg) {
|
if (otg) {
|
||||||
if (!opts->control) {
|
if (!opts->control) {
|
||||||
LOGE("--no-control is not allowed in OTG mode");
|
LOGE("--no-control is not allowed in OTG mode");
|
||||||
|
@ -753,6 +753,7 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
|
|||||||
|
|
||||||
enum sc_mouse_binding binding =
|
enum sc_mouse_binding binding =
|
||||||
sc_input_manager_get_binding(&im->mouse_bindings, event->button);
|
sc_input_manager_get_binding(&im->mouse_bindings, event->button);
|
||||||
|
assert(binding != SC_MOUSE_BINDING_AUTO);
|
||||||
switch (binding) {
|
switch (binding) {
|
||||||
case SC_MOUSE_BINDING_DISABLED:
|
case SC_MOUSE_BINDING_DISABLED:
|
||||||
// ignore click
|
// ignore click
|
||||||
|
@ -24,10 +24,10 @@ const struct scrcpy_options scrcpy_options_default = {
|
|||||||
.keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_AUTO,
|
.keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_AUTO,
|
||||||
.mouse_input_mode = SC_MOUSE_INPUT_MODE_AUTO,
|
.mouse_input_mode = SC_MOUSE_INPUT_MODE_AUTO,
|
||||||
.mouse_bindings = {
|
.mouse_bindings = {
|
||||||
.right_click = SC_MOUSE_BINDING_BACK,
|
.right_click = SC_MOUSE_BINDING_AUTO,
|
||||||
.middle_click = SC_MOUSE_BINDING_HOME,
|
.middle_click = SC_MOUSE_BINDING_AUTO,
|
||||||
.click4 = SC_MOUSE_BINDING_APP_SWITCH,
|
.click4 = SC_MOUSE_BINDING_AUTO,
|
||||||
.click5 = SC_MOUSE_BINDING_EXPAND_NOTIFICATION_PANEL,
|
.click5 = SC_MOUSE_BINDING_AUTO,
|
||||||
},
|
},
|
||||||
.camera_facing = SC_CAMERA_FACING_ANY,
|
.camera_facing = SC_CAMERA_FACING_ANY,
|
||||||
.port_range = {
|
.port_range = {
|
||||||
|
@ -156,6 +156,7 @@ enum sc_mouse_input_mode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum sc_mouse_binding {
|
enum sc_mouse_binding {
|
||||||
|
SC_MOUSE_BINDING_AUTO,
|
||||||
SC_MOUSE_BINDING_DISABLED,
|
SC_MOUSE_BINDING_DISABLED,
|
||||||
SC_MOUSE_BINDING_CLICK,
|
SC_MOUSE_BINDING_CLICK,
|
||||||
SC_MOUSE_BINDING_BACK,
|
SC_MOUSE_BINDING_BACK,
|
||||||
|
16
doc/mouse.md
16
doc/mouse.md
@ -72,12 +72,14 @@ process like the _adb daemon_).
|
|||||||
|
|
||||||
## Mouse bindings
|
## Mouse bindings
|
||||||
|
|
||||||
By default, right-click triggers BACK (or POWER on) and middle-click triggers
|
By default, with SDK mouse, right-click triggers BACK (or POWER on) and
|
||||||
HOME. In addition, the 4th click triggers APP_SWITCH and the 5th click expands
|
middle-click triggers HOME. In addition, the 4th click triggers APP_SWITCH and
|
||||||
the notification panel.
|
the 5th click expands the notification panel.
|
||||||
|
|
||||||
The shortcuts can be configured using `--mouse-bind=xxxx`. The argument must be
|
In AOA and UHID mouse modes, all clicks are forwarded by default.
|
||||||
exactly 4 characters, one for each secondary click:
|
|
||||||
|
The shortcuts can be configured using `--mouse-bind=xxxx` for any mouse mode.
|
||||||
|
The argument must be exactly 4 characters, one for each secondary click:
|
||||||
|
|
||||||
```
|
```
|
||||||
--mouse-bind=xxxx
|
--mouse-bind=xxxx
|
||||||
@ -101,8 +103,8 @@ Each character must be one of the following:
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
scrcpy --mouse-bind=bhsn # the default mode
|
scrcpy --mouse-bind=bhsn # the default mode with SDK mouse
|
||||||
scrcpy --mouse-bind=++++ # forward all clicks
|
scrcpy --mouse-bind=++++ # forward all clicks (default for AOA/UHID)
|
||||||
scrcpy --mouse-bind=++bh # forward right and middle clicks,
|
scrcpy --mouse-bind=++bh # forward right and middle clicks,
|
||||||
# use 4th and 5th for BACK and HOME
|
# use 4th and 5th for BACK and HOME
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user