Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
103.68k stars 10.09k forks source link

Pinch zooming support #24

Closed paour closed 3 years ago

paour commented 6 years ago

The Android emulator uses right click and drag to simulate pinch zooming. An alternative would be ctrl-mouse wheel.

octopusknives commented 6 years ago

Pinch zooming with a touchscreen also doesn't work.

CodeAck commented 5 years ago

Pinch zooming support would be a great idea! Ctrl+← and Ctrl+→ could be used since ↓↑ are taken by volume control. Would be great for people with low/no motor ability in their hands. (I can't move from the shoulders down and greatly appreciate what you've done with scrcpy)

jknut commented 5 years ago

It would be great to have the ability to pinch zoom. Another alternative could be using the mouse wheel.

Scrcpy is really great!

Pixelstudio commented 5 years ago

Would be great if this can be added!

apiemont commented 5 years ago

another vote for this feature

ToggoStar commented 5 years ago

+1! Scrcpy is awesome and this is the only feature missing for me!

Pixelstudio commented 4 years ago

Oeh i see some references to this pr, but i cannot find if this is implemented... Any idea?

rom1v commented 4 years ago

Hi, I just implemented an experimentation, on branch virtualfinger.

While the Ctrl key is held, the first left-click adds an immobile "virtual finger" at this position.

Moving the mouse moves another cursor. The left click may be released and pressed as necessary to control the second finger.

Releasing Ctrl releases the virtual finger.

rom1v commented 4 years ago

A simpler (and maybe more intuitive) alternative could be to always put the "virtual finger" in the center of the screen, so that "unzooming" is more natural.

As a drawback, it would not be possible to zoom on a widget which takes only a portion of the screen (which is not in the center), but it may be worth it.

CodeAck commented 4 years ago

OK cool, so what do we have to do to try this virtualfinger? Upgrade anything? I'm on a Mac

srevinsaju commented 4 years ago

Literally amazing, this fixes issue https://github.com/srevinsaju/guiscrcpy/issues/2 on guiscrcpy as well

srevinsaju commented 4 years ago

@rom1v I am having problems with the virtualfinger branch,

INFO: scrcpy 1.10 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server.jar: 1 file pushed. 1.1 MB/s (22546 bytes in 0.019s)
INFO: Initial texture: 720x1280
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] WARN: Unknown event type: -1
[server] ERROR: Exception on thread Thread[Thread-1,5,main]
java.lang.IllegalStateException: Buffer full, call next() to consume
        at com.genymobile.scrcpy.ControlMessageReader.readFrom(ControlMessageReader.java:35)
        at com.genymobile.scrcpy.DesktopConnection.receiveControlMessage(DesktopConnection.java:110)
        at com.genymobile.scrcpy.Controller.handleEvent(Controller.java:82)
        at com.genymobile.scrcpy.Controller.control(Controller.java:73)
        at com.genymobile.scrcpy.Server$1.run(Server.java:45)
        at java.lang.Thread.run(Thread.java:764)

Is it due to some installation problem, or some unhandled exception. Running Ubuntu 19.04 scrcpy v1.10 virtualfinger branch. The mirroring and screen shots continue to work, but the mouse events are not passed not even single and normal click passed.

Sent from my Galaxy Note2 using FastHub

rom1v commented 4 years ago

You need to recompile the server too.

srevinsaju commented 4 years ago

Thanks, will check that way

srevinsaju commented 4 years ago

@rom1v, no hope, the same error again

What I did


meson x --buildtype release --strip -Db_lto=true
cd x
ninja
cd app
./scrcpy

Unfortunately, the same error comes up. Can't pass clicks as well

Sent from my Galaxy Note2 using FastHub

Pixelstudio commented 4 years ago

Hi, i have used the branch virtualfinger, that allowed me to simulate pinch-zoom. However that branch is falling behind compared to the master, any idea if you would implement this in the master ?

rom1v commented 4 years ago

The problem is that it is not really usable without a visual feedback (to display which locations are actually clicked), and it requires some work do implement it. So I probably won't merge it without that. :disappointed:

Pixelstudio commented 4 years ago

ah, that is to bad. scrcpy is really great and the one feature missing for me is the ability to send a pinch command. is it much to work bind for example ctrl + and ctrl - to send a simulated pinch ?

whaevr commented 4 years ago

The problem is that it is not really usable without a visual feedback (to display which locations are actually clicked)

would it be possible to hook into the same touch events that the os shows for finger inputs? For example I have the developer option "show touch location" turned on. This works for my finger but not when I click with scrcpy, can scrcpy "use" that same method of tapping the ui that would produce these visual aids people could just turn on in dev options?

Im guessing not

boorac commented 4 years ago

+1 definitely a great feature

ahmadshiddiq commented 4 years ago

i cant wait for this feature, for gaming this will be very helpful

quancayda commented 4 years ago

I'm still waiting for day by day this feature released. It's really helpful for any app/game need Zoom in/out by mouse. Any update so far for this great feature?

Voyajer commented 3 years ago

Pinch zooming seems to be the only input feature missing from scrcpy. Hopefully it gets implemented because this is very nice software.

rom1v commented 3 years ago

Hi,

I finally worked on this feature today.

The problem with my previous attempts is that I wanted to be able to zoom from any point (not only the center of the screen), but it's a UX nightmare. Therefore, I took the same approach as the Android emulator, and just scale/rotate relative to the center of the screen. That way, it's easy to zoom/unzoom.

Just hold Ctrl when you lelf-click to enable pinch-to-zoom (it is disabled when left-click is released). (I used Ctrl because that's what the Android emulator does.)

The branch is pinch_zoom.

Here is a Windows binary to test (replace in your v1.15.1 release):

rom1v commented 3 years ago

Implemented in v1.16.

elig0n commented 3 years ago

Anyone else experiencing problem with pinch-zooming maps? Currently experienced in both Google Maps and OSMand. I seem to not be able to zoom out or in very much because at a certain point the action turns into its opposite, sometimes with the map rotating around itself a full round. One must hold the mouse pointer at the very pinpoint accurate point where the pointer originally was pressed to be able to keep zooming out or in to farther lengths without turning the map around and/or reversing the zoom operation. For short-step zoom actions there is no such problem so long-step zooming can be achieved only via several, consecutive short-step zooming.

rom1v commented 3 years ago

Currently experienced in both Google Maps and OSMand. I seem to not be able to zoom out or in very much because at a certain point the action turns into its opposite, sometimes with the map rotating around itself a full round.

To zoom out, you need to start at the edges (top, bottom, left or right) and moves towards the center.

Imagine that this mode adds a finger inverted through the center:

pinch

(This is a capture from Android emulator, unfortunately scrcpy does not provide any visual feedback, hence the confusion.)

elig0n commented 3 years ago

Would you reconsider to reverse the mouse drag directions actions ? i.e to make pulling the mouse towards me zoom out and pulling away from me zoom in ? or maybe the app would need at some point an INI-style configuration file for to reconfigure all the keys.

rom1v commented 3 years ago

i.e to make pulling the mouse towards me zoom out and pulling away from me zoom in ?

What do you mean by "pulling towards" or "pulling away"? The screen is 2D and you are in another dimension :smile:

Would you reconsider to reverse the mouse drag directions actions ?

In fact, this feature does not implement "zoom in/out", nor choose any drag direction, it just injects additional touch events at a location inverted through the center of the screen. Then the Android app normally reacts to the touch events from the mouse and the virtual finger.

edulourenzo commented 3 years ago

Good afternoon. I think the issue is not the zoom of the screen. And yes, simulate the pinch movement. An easy way would be: When pressing a key (alt), two fingers are pressed, pressing the screen from a distance "R" from the mouse position captured with (x, y). And depending on the scroll of the mouse, these fingers move apart or get closer to the mouse position. I think the ideal would be diagonally as some photo editors stretch vertically or horizontally. And diagonally this would maintain the proportion. So you pass the responsibility to the application. If he has zomm the app interacts with the fake fingers. Otherwise the application does nothing. I think it would not be difficult to simulate the pinch and not the zoom, leave that to the application that is running. It probably won't work for all cases, but I think it would be a solution for most.

rom1v commented 3 years ago

@edulourenzo Isn't more or less what is implemented in v1.16? (except it does not use the mouse scroll)

edulourenzo commented 3 years ago

And what would be the command to make the zoom pinch movement

rom1v commented 3 years ago

Ctrl+click-and-move.

More details: https://github.com/Genymobile/scrcpy/releases/tag/v1.16

ChristopherH commented 3 years ago

AWESOME! been waiting for this feature for a long time, i love scrcpy but it always lacked that one major feature, thanks alot to all developers, you are doing a terrific job!

alimsk commented 2 years ago

no longer working?\ i'm on linux\ android 10

rom1v commented 2 years ago

Yes, it is working: https://github.com/Genymobile/scrcpy#pinch-to-zoom

Which version of scrcpy do you use?

alimsk commented 2 years ago

i use

$ scrcpy --version
scrcpy 1.12.1

dependencies:
 - SDL 2.0.10
 - libavcodec 58.54.100
 - libavformat 58.29.100
 - libavutil 56.31.100
alimsk commented 2 years ago

i rebuild scrcpy from source code and it suddenly worked :confused:

rom1v commented 2 years ago

scrcpy 1.12.1

It's a very old version, pinch zoom has been implemented in 1.16.

alimsk commented 2 years ago

i installed it with apt install scrcpy.\ anyways thank you