Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
104.88k stars 10.19k forks source link

Show touch #44

Open AndroidDeveloperLB opened 6 years ago

AndroidDeveloperLB commented 6 years ago

In developer options, there is an option "show taps", that whenever you touch the screen, a white circle appears. For some reason, it doesn't appear when using this app. Please let us have it. It can be useful for screenshots and screen-video capture.

rom1v commented 6 years ago

For some reason, it doesn't appear when using this app.

Yes, injecting events does not display the circle. It is probably triggered at lower level. Nothing we can do IMO. So I'm closing.

Feel free to reopen if there is a technical solution.

AndroidDeveloperLB commented 6 years ago

Why close it then? How about putting your own circle? One that shows 2 states: the mouse position, and then pressing on it. Or using those of Google's material design website: https://material.io/guidelines/patterns/gestures.html#gestures-drag-swipe-or-fling-details

Something like these videos: https://storage.googleapis.com/material-design/publish/material_v_12/assets/0Bwp7jtSjaW36RUJ4TnJjTnZ0dms/patterns-selection-item-entering1.webm https://storage.googleapis.com/material-design/publish/material_v_12/assets/0Bwp7jtSjaW36WHQ1eFc5aW44QlU/patterns-selection-item-controlling2.webm https://storage.googleapis.com/material-design/publish/material_v_12/assets/0Bwp7jtSjaW36QWo0S01faE5Sa0U/patterns-selection-item-controlling1.webm

It's even better than the simple circle.

AndroidDeveloperLB commented 6 years ago

Please re-consider

AndroidDeveloperLB commented 6 years ago

@rom1v Thank you. Here's one that shows long clicking: https://storage.googleapis.com/material-design/publish/material_v_12/assets/0B-IfCW5OG7FqU09tc3kxOGg3aTA/notifications-behavior-08-controls-xhdpi.webm

rom1v commented 6 years ago

In developer options, there is an option "show taps", that whenever you touch the screen, a white circle appears.

At least, I added an option to enable show touches while scrcpy is running: https://github.com/Genymobile/scrcpy/issues/96.

AndroidDeveloperLB commented 6 years ago

I have 1.1, and I don't see "touches" of the mouse. Only when I touch the screen myself (with the finger).

rom1v commented 6 years ago

I have 1.1, and I don't see "touches" of the mouse. Only when I touch the screen myself (with the finger).

  1. It only enable the show touches option in developer settings (so you will only see physical touches, not mouse clicks, technically it is probably implemented in some code that event injection does not trigger).
  2. it's implemented in dev (not released yet).
  3. The application must be started with scrcpy --show-touches.
AndroidDeveloperLB commented 6 years ago

Well I have it enabled anyway in the settings of the OS... But what I wrote here, is that I'd like to see the touches indications (and maybe even customize them and have new ones, like the links of material design I've shown) on the PC app itself.

rom1v commented 6 years ago

Yes, I got it.

I just notified that I added an option to automatically enable/disable the setting in developers options, because it is somehow related.

I didn't say I implemented what you requested (that's why I left the issue open).

AndroidDeveloperLB commented 6 years ago

I see. Say, is it possible to somehow be notified of new versions of this tool? Maybe a specific website URL that I can monitor via this website: https://www.changedetection.com/login.html ? I just think it's such a nice tool. I wish it would have been a part of the IDE itself.

rom1v commented 6 years ago

Say, is it possible to somehow be notified of new versions of this tool?

I don't know, maybe: https://github.com/Genymobile/scrcpy/releases.atom

In the future, I hope it will be packaged in distributions (it is already packaged for Arch Linux and Homebrew for MacOS, so the update is automatic).

AndroidDeveloperLB commented 6 years ago

I use Windows... And the website url you've provided is blocked, because it has "robots.txt" file. :(

rom1v commented 6 years ago

I use Windows...

Sorry for you :trollface:

And the website url you've provided is blocked, because it has "robots.txt" file.

The URL is an rss/atom feed, you can use any feed reader.

AndroidDeveloperLB commented 6 years ago

Haha. I like Linux only for development (and I hate the UX of MacOS), and I used it a very long time ago. But for the past years I got Windows at the office.

About rss/atom, ok.

AndroidDeveloperLB commented 6 years ago

I've now registered to this for the Atom/Rss of github: https://ifttt.com/applets/400948p-get-notifications-about-github-releases

I hope it works.

AndroidDeveloperLB commented 6 years ago

I've noticed this is possible now:

image

But when I try it , I still don't see it:

image

rom1v commented 6 years ago

This is just https://github.com/Genymobile/scrcpy/issues/44#issuecomment-377170279

AndroidDeveloperLB commented 6 years ago

@rom1v Isn't it a new feature? If not, why mention it? I can see v1.2 was out just some hours ago:

image

rom1v commented 6 years ago

Isn't it a new feature? If not, why mention it?

The feature was implemented 2 months ago in the dev branch, but it was after the last release v1.1. This is the first time it is released.

AndroidDeveloperLB commented 6 years ago

Well it doesn't work for me. In fact it disabled the touch indication I had before

rom1v commented 6 years ago

It enables it on start, and disable it on stop. If you let it enabled, just don't use the option.

When you touch the screen with your finger, it should show touches.

AndroidDeveloperLB commented 6 years ago

@rom1v I've removed the flag. Still can't see the touches using the mouse. See video:

ice_video_20180529-094117.zip

Also, almost sure it's because of this app: On first run, the mouse couldn't get to reach the taskbar of the Windows OS itself. Instead it gets hidden. On next runs, it didn't happen. Weird thing is that I didn't see it on a different PC, so not 100% sure it's because of this.

rom1v commented 6 years ago

I've removed the flag. Still can't see the touches using the mouse.

I'm not sure you understand what the feature does.

From scrcpy --help:

    -t, --show-touches
        Enable "show touches" on start, disable on quit.
        It only shows physical touches (not clicks from scrcpy).

So:

ice_video_20180529-094117.zip

(don't zip videos :wink:)

On first run, the mouse couldn't get to reach the taskbar of the Windows OS itself. Instead it gets hidden. On next runs, it didn't happen.

Weird.

AndroidDeveloperLB commented 6 years ago

So it doesn't show touches for the PC app. Only touches on the phone itself. Please add feature to show mouse "touches". Now that I re-read what I wrote here (sorry I forgot about it), it's the same as I wrote originally on this thread.

About uploading videos, Github doesn't allow to upload them directly. It can only allow specific files types.

williamfzc commented 5 years ago

+1

This feature will be very useful in automation. Without this, it's really hard to get touch position from video or picture. But it's not an easy job I think :(

minitouch is an available option (maybe).

AndroidDeveloperLB commented 2 years ago

@rom1v If it's impossible to cause the touch indicators appear on the device itself, it could be nice to show them just on the window of ScrCpy alone. Have a flag for this, as some people might not want it.

twaik commented 1 year ago

IMHO we can close this since we have -t, --show-touches option. @rom1v .

AndroidDeveloperLB commented 1 year ago

@twaik No, I already wrote about this: https://github.com/Genymobile/scrcpy/issues/44#issuecomment-392679621

allco commented 1 year ago

I always spread scrcpy among all the devs that I work with. And this is something that we really need on daily basis - like to show something on my screen during a video call or record the screen video.

Looking forward to get this function working. I would be really useful.

-t does not work for me

AndroidDeveloperLB commented 1 year ago

@allco He talks about real touches. The request I made is for "simulated" touches (by the mouse).

jinktet commented 10 months ago

Have you found a solution to your problem yet? I am also having the same problem as you.

zguig52 commented 6 months ago

Hi there, don't know if it is the right place to talk about this. It would be nice also to have the option to customize the icon used to show touch event (being on the device only, on the screen only or on both).

pshbot commented 4 months ago

Interestingly, the related option "Pointer location" in Android's Developer options does work with simulated events from scrcpy.

image

It's not pretty, and I would much prefer "Show taps" to work, but it is better than nothing.

robertkirkman commented 5 days ago

Hello, I have created a workaround for a subset of this issue. My workaround can be used on any device for which you can already successfully compile, install and boot a custom ROM.

[!CAUTION] Unfortunately, I think my method is not possible on devices that have locked bootloaders.

I have done this by editing the internal source code of the Android operating system and then recompiling and reinstalling it. This is the first Android custom ROM I have ever written.

Here is a demo recording of what my workaround does for scrcpy. Watch to the end to see the workaround in action.

redroid-dot.webm

The strategy behind my code is, since the "Show taps" backend only responds to physical touchscreen devices, but the "Pointer location", which uses an entirely different codepath, responds to both scrcpy and touchscreen, I copied and pasted the texture loading code that "Show taps" invokes to fetch its texture, into the source code that renders "Pointer location", to force it to render that same texture instead of its ugly official renderer, and as it turns out, doing that does in fact work.

Here is a full commands list to reproduce what my demo video shows. The custom ROM I forked is redroid, the Android docker container; however, the code file I edited was not previously edited by any redroid-specific changes, leading me to assume that my code should also apply cleanly and work on any Android 14 based custom ROM. I imagine it is hopefully also not too difficult for people to backport to Android 13 or older for at least any versions in which the PointerLocationView.java remains relatively similar to the one I found in Android 14.

Prerequisites to reproduce my demo

[!WARNING]
Normal Debian 12 bookworm does not provide sufficient versions of all of these by default so you would need to find ways to install a new enough version of each one into your distro. Compare your versions with the version numbers I show in my demo video if you encounter any problem.

  • amd64 host system with root and unlocked bootloader to boot custom kernel
  • up to date version of docker
  • up to date version of scrcpy
  • up to date version of repo
  • up to date version of git with a name and email set
  • up to date version of git lfs
  • up to date kernel with these build flags enabled:
    • CONFIG_DMABUF_HEAPS=y
    • CONFIG_DMABUF_HEAPS_SYSTEM=y
    • CONFIG_ANDROID_BINDER_IPC=y
    • CONFIG_ANDROID_BINDERFS=y
    • CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"
  • 250 GB free space in storage drive

Commands I used

[!WARNING] Copy and paste each command one by one instead of clicking the github "copy" button and trying to run this as a script.

git clone https://github.com/remote-android/redroid-patches.git
mkdir redroid-src
cd redroid-src
repo init -u https://android.googlesource.com/platform/manifest --git-lfs --depth=1 -b android-14.0.0_r45
git clone https://github.com/remote-android/local_manifests.git .repo/local_manifests -b 14.0.0
repo sync -c -j$(nproc)
../redroid-patches/apply-patch.sh $(pwd)
cd frameworks/base
(curl https://gist.githubusercontent.com/robertkirkman/21ae17b3aa0e1b48ca67864f7cb0c158/raw/595f739b3b260c20874dd510abdd17292affc624/pointerlocationisshowtapsclone.patch && echo) | git apply -v
cd -
wget https://raw.githubusercontent.com/remote-android/redroid-doc/master/android-builder-docker/Dockerfile
docker buildx create --use
docker buildx build --build-arg userid=$(id -u) --build-arg groupid=$(id -g) --build-arg username=$(id -un) -t redroid-builder --load .
docker run -it --privileged --rm --hostname redroid-builder --name redroid-builder -v $(pwd):/src redroid-builder
cd /src
. build/envsetup.sh
lunch redroid_x86_64_only-userdebug
m -j$(nproc)
exit
cd out/target/product/redroid_x86_64_only/
sudo mount system.img system -o ro
sudo mount vendor.img vendor -o ro
sudo tar --xattrs -c vendor -C system --exclude="./vendor" . | docker import --platform=linux/amd64 -c 'ENTRYPOINT ["/init", "qemu=1", "androidboot.hardware=redroid", "androidboot.redroid_fps=30", "androidboot.redroid_width=1280", "androidboot.redroid_height=720", "androidboot.redroid_gpu_mode=host"]' - redroid-dot
sudo umount system vendor
docker run -itd --privileged --name redroid-dot -v ~/redroid-dot-data:/data -p 8022:8022 -p 5555:5555 redroid-dot
adb connect localhost
scrcpy

Here is a direct link to the Java code patch implementation of my workaround, which applies to the Android 14 source code file frameworks/base/core/java/com/android/internal/widget/PointerLocationView.java. You can see it applied in my example commands right after I sync the Android repository and apply other vendor patches.

twaik commented 5 days ago

Probably there could be other, more universal solution. Since app is running in adb it could use SurfaceTransactions via parts of licfsurface code and draw circle in emulated tap locations.