Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 fingers tap & move: distinguish between zoom and scrolling #5317

Closed
1 task done
Hubert21 opened this issue Sep 24, 2024 · 20 comments
Closed
1 task done

2 fingers tap & move: distinguish between zoom and scrolling #5317

Hubert21 opened this issue Sep 24, 2024 · 20 comments

Comments

@Hubert21
Copy link

Hello,
That would be great if there would be a way to distinguish, for the 2 finger tap, between a gesture where two fingers are spread apart (like for zooming) and a gesture where two fingers are moved together without changing the distance between them (like for scrolling the screen)
Thanks,

Is your feature request related to a problem? Please describe.
Some software like Krita requieres zoom and scrolling, and to distinguish them (otherwise it randomly do both of them)

Describe the solution you'd like
a set of keys (like ctrl, ctrl+alt, or a letter if necessary) to distinguish them

Describe alternatives you've considered
N/A

@Hubert21 Hubert21 changed the title distinguish between zoom and scrolling 2 fingers tap & move: distinguish between zoom and scrolling Sep 24, 2024
@rom1v
Copy link
Collaborator

rom1v commented Sep 24, 2024

Scrcpy injects finger touch events to the device, how it reacts is handled by Android.

@Hubert21
Copy link
Author

thanks for you answer ; maybe if there was a way to inject positions of the the fingers movement so that the distance between them does not change ;
if it might help, this project seams to handle multi-touch https://github.com/openstf/minitouch

@rom1v
Copy link
Collaborator

rom1v commented Sep 24, 2024

@Hubert21
Copy link
Author

Thanks for the link. Indeed I do use the ctrl+click feature. Actually as with ctrl we do have the zoom/rotate, I think what is missing for me is the 2 fingers swipe

@rom1v
Copy link
Collaborator

rom1v commented Sep 24, 2024

I think what is missing for me is the 2 fingers swipe

Vertically or horizontally?

Vertically, you can use Shift+click.

@Hubert21
Copy link
Author

Thanks for pointing that out, I did not really understand that "tilt" was équivalent to a vertical 2 fingers swipe ; However on my device (samsung s10 and scrcpy 1.12.1+ds-1 on ubuntu) Shift+click does not seam to do anything.
As a side note, even if I have the version 1.12.1+ds-1 installed, scrcpy -v tells me it's version 1.24 (which introduced the tilt feature)

sudo apt install --only-upgrade scrcpy
=> scrcpy is already the newest version (1.12.1+ds-1).

scrcpy -v
=> scrcpy 1.24 https://github.com/Genymobile/scrcpy

Dependencies (compiled / linked):

  • SDL: 2.0.10 / 2.0.10
  • libavcodec: 58.54.100 / 58.54.100
  • libavformat: 58.29.100 / 58.29.100
  • libavutil: 56.31.100 / 56.31.100
  • libavdevice: 58.8.100 / 58.8.100
  • libusb: - / 1.0.23

@rom1v
Copy link
Collaborator

rom1v commented Sep 24, 2024

You probably installed several versions in different ways.

Don't use the package from your Debian/Ubuntu distribution, they are completely obsolete/outdated.

Uninstall it and install the latest version (currently 2.7):
https://github.com/Genymobile/scrcpy/blob/master/doc/linux.md#latest-version

@Hubert21
Copy link
Author

Hubert21 commented Sep 25, 2024

Thanks! shift+click now works.
My request is now limited to adding a horizontal tilt/scroll in addition to the vertical one with the Shift key.
I succeeded doing so with the ctrl+alt combination (alt alone + click is used by ubuntu to move the window):
bool alt_pressed = keymod & KMOD_ALT;
...
im->vfinger_invert_x = ( ctrl_pressed && !alt_pressed ) || shift_pressed;
im->vfinger_invert_y = ctrl_pressed || alt_pressed;

I also tried several other methods that didn't work:

  1. with the meta key
    bool gui_pressed = keymod & KMOD_GUI;
    ...
    im->vfinger_invert_x = ctrl_pressed || shift_pressed;
    im->vfinger_invert_y = ctrl_pressed || gui_pressed;

  2. with ctrl+shift
    im->vfinger_invert_x = (ctrl_pressed && !shift_pressed) || ( !ctrl_pressed && shift_pressed );
    im->vfinger_invert_y = ctrl_pressed;

@rom1v
Copy link
Collaborator

rom1v commented Sep 25, 2024

My request is now limited to adding a horizontal tilt/scroll in addition to the vertical one with the Shift key.

#4529 (comment)

@Hubert21
Copy link
Author

Thanks to your help and my hack, this is done!
If ctrl+alt+click is not planned to be used anywhere else, maybe my changes could be commited

@rom1v
Copy link
Collaborator

rom1v commented Sep 25, 2024

What is your concrete use case for horizontal "sliding"?

@Hubert21
Copy link
Author

I am using a drawing app on my phone (Krita or Simple Draw), for making schemas, take notes, grow ideas.
For all apps the phone is easier to use with scrcpy especially when using the computer for other things at the same time. It's easier for these drawing apps also.

@rom1v
Copy link
Collaborator

rom1v commented Sep 25, 2024

To add Ctrl+Shift for horizontal tilt, I think this is sufficient:

diff --git a/app/src/input_manager.c b/app/src/input_manager.c
index 3c7022b0f..879a9df3a 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -794,7 +794,7 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
     }
 
     bool change_vfinger = event->button == SDL_BUTTON_LEFT &&
-            ((down && !im->vfinger_down && (ctrl_pressed ^ shift_pressed)) ||
+            ((down && !im->vfinger_down && (ctrl_pressed || shift_pressed)) ||
              (!down && im->vfinger_down));
     bool use_finger = im->vfinger_down || change_vfinger;
 
@@ -835,7 +835,7 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
             sc_screen_convert_window_to_frame_coords(im->screen, event->x,
                                                                  event->y);
         if (down) {
-            im->vfinger_invert_x = ctrl_pressed || shift_pressed;
+            im->vfinger_invert_x = ctrl_pressed ^ shift_pressed;
             im->vfinger_invert_y = ctrl_pressed;
         }
         struct sc_point vfinger = inverse_point(mouse, im->screen->frame_size,

Could you confirm, please?

rom1v added a commit that referenced this issue Sep 25, 2024
Use Ctrl+Shift for horizontal tilt.

Refs #4529 comment <#4529 (comment)>
Fixes #5317 <#5317>
@rom1v
Copy link
Collaborator

rom1v commented Sep 25, 2024

Please review/test 7a9ea5c.

@rom1v rom1v reopened this Sep 25, 2024
@Hubert21
Copy link
Author

That works perfectly, thanks :)

@rom1v
Copy link
Collaborator

rom1v commented Sep 25, 2024

Merged into dev 🚀

@rom1v rom1v closed this as completed Sep 25, 2024
@unique-EJ
Copy link
Contributor

Merged into dev 🚀

@rom1v @Hubert21 👋 why is this in dev branch and not the master?
Please bring that over, with Ctrl+Shift for horizontal tilt referred to in the file /doc/shortcuts.md

... and sometimes vertical tilt does zoom, why is that? 🤔

@rom1v
Copy link
Collaborator

rom1v commented Nov 10, 2024

👋 why is this in dev branch and not the master?

Because it has been merged after the latest release. It will be in the next one:
https://github.com/Genymobile/scrcpy/blob/master/doc/build.md#branches

@unique-EJ
Copy link
Contributor

unique-EJ commented Nov 10, 2024

@rom1v how is tilt not 2 finger (laptop) touchpad scroll?
and I am using scrcpy (2.7) now! 🙂 Android 14 through my laptop.

@rom1v
Copy link
Collaborator

rom1v commented Nov 10, 2024

how is tilt not 2 finger (laptop) touchpad scroll?

Scrcpy sends 2 fingers at the specified location to Android. The Android system reacts as it wants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants