mirror of
https://github.com/Genymobile/scrcpy
synced 2025-08-31 06:15:25 +00:00
Add mouse secondary bindings
Add secondary bindings (Shift+click) for mouse buttons. In addition to: --mouse-bind=xxxx It is now possible to pass a sequence of secondary bindings: --mouse-bind=xxxx:xxxx <--> <--> primary secondary bindings bindings If the second sequence is omitted, then it is the same as the first one. By default, for SDK mouse, primary bindings trigger shortcuts and secondary bindings forward all clicks. For AOA and UHID, the default bindings are reversed: all clicks are forwarded by default, whereas pressing Shift+click trigger shortcuts. --mouse-bind=bhsn:++++ # default for SDK --mouse-bind=++++:bhsn # default for AOA and UHID Refs035d60cf5d
Refsf5e6b8092a
Fixes #5055 <https://github.com/Genymobile/scrcpy/issues/5055> PR #5076 <https://github.com/Genymobile/scrcpy/pull/5076>
This commit is contained in:
@@ -708,7 +708,7 @@ sc_input_manager_process_touch(struct sc_input_manager *im,
|
||||
}
|
||||
|
||||
static enum sc_mouse_binding
|
||||
sc_input_manager_get_binding(const struct sc_mouse_bindings *bindings,
|
||||
sc_input_manager_get_binding(const struct sc_mouse_binding_set *bindings,
|
||||
uint8_t sdl_button) {
|
||||
switch (sdl_button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
@@ -744,11 +744,18 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
|
||||
im->mouse_buttons_state &= ~button;
|
||||
}
|
||||
|
||||
SDL_Keymod keymod = SDL_GetModState();
|
||||
bool ctrl_pressed = keymod & KMOD_CTRL;
|
||||
bool shift_pressed = keymod & KMOD_SHIFT;
|
||||
|
||||
if (control && !paused) {
|
||||
enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP;
|
||||
|
||||
struct sc_mouse_binding_set *bindings = !shift_pressed
|
||||
? &im->mouse_bindings.pri
|
||||
: &im->mouse_bindings.sec;
|
||||
enum sc_mouse_binding binding =
|
||||
sc_input_manager_get_binding(&im->mouse_bindings, event->button);
|
||||
sc_input_manager_get_binding(bindings, event->button);
|
||||
assert(binding != SC_MOUSE_BINDING_AUTO);
|
||||
switch (binding) {
|
||||
case SC_MOUSE_BINDING_DISABLED:
|
||||
@@ -812,9 +819,6 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
|
||||
im->mouse_buttons_state |= button;
|
||||
}
|
||||
|
||||
SDL_Keymod keymod = SDL_GetModState();
|
||||
bool ctrl_pressed = keymod & KMOD_CTRL;
|
||||
bool shift_pressed = keymod & KMOD_SHIFT;
|
||||
bool change_vfinger = event->button == SDL_BUTTON_LEFT &&
|
||||
((down && !im->vfinger_down && (ctrl_pressed ^ shift_pressed)) ||
|
||||
(!down && im->vfinger_down));
|
||||
|
Reference in New Issue
Block a user