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

The Ctrl+V function of version 1.15.1 has no effect on some devices. #1658

Closed
Helaer opened this issue Aug 10, 2020 · 20 comments
Closed

The Ctrl+V function of version 1.15.1 has no effect on some devices. #1658

Helaer opened this issue Aug 10, 2020 · 20 comments

Comments

@Helaer
Copy link

Helaer commented Aug 10, 2020

Hello, I found that when some of my Android 7.1.2 phones use version 1.15.1, the Ctrl+V key combination does not have any effect.

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

When I use Ctrl+Shift+V on version 1.14, it can be pasted.

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Ctrl+V key combination does not have any effect.

In which apps? What if you copy some text from the device (either with Ctrl+c or with long-press, then COPY) instead of from the computer, then Ctrl+v?

Since v1.15, Ctrl+v does 2 things:

  • it copies the computer clipboard to the device clipboard
  • it injects Ctrl+v on the device (which is handled by Android/the app).

The changes between v1.14 and v1.15 could be confusing. There are 3 ways to paste:

  1. injecting Ctrl+v (not possible in v1.14, Ctrl+v in v1.15)
  2. injecting PASTE (Ctrl+Shift+v in v1.14, MOD+v in v1.15) (only works on Android >= 7)
  3. injecting the clipboard content as a sequence of key events (Ctrl+v in v1.14, MOD+Shift+v in v1.15) (see 7ad47df)

See https://github.com/Genymobile/scrcpy#copy-paste

When I use Ctrl+Shift+V on version 1.14

Does MOD+v work in v1.15?

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

I tested MOD + V, but there is no response on these Android 7.1.2 devices, but it can be pasted in version 1.14.

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

By the way, not all mobile phones will be like this, this problem only occurs on some Android 7.1.2 devices.

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Using one of these Android 7.1.2 devices, copy some text on the computer (with Ctrl+c), copy some text on the device (long-press, COPY).

Then could you describe the result for each case:

On v1.14:

  • Ctrl+v: ?
  • Ctrl+Shift+v: ?

On v1.15.1:

  • MOD+v: ?
  • Ctrl+v: ?
  • Ctrl+Shift+v MOD+Shift+v: ?

With adb:

  • adb shell input keyevent PASTE: ?

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

On v1.14:
Ctrl+v: Cannot paste non-ASCII characters
Ctrl+Shift+v: Can paste non-ASCII characters

On v1.15.1:
MOD+v: No response, the clipboard is not synchronized.
Ctrl+v: No response, the clipboard is not synchronized.
Ctrl+Shift+v: No response, the clipboard is not synchronized.

With adb:
adb shell input keyevent PASTE: Can paste non-ASCII characters

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Ctrl+Shift+v: No response, the clipboard is not synchronized.

Sorry, I meant MOD+Shift+v.

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

MOD+Shift+v,cmd returns information:
[server] WARN: Could not inject char u+5378
[server] WARN: Could not inject char u+8f7d
[server] WARN: Could not inject char u+65e7
[server] WARN: Could not inject char u+7248

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Without pasting any ASCII characters?

@rom1v rom1v added the bug label Aug 10, 2020
@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

MOD+Shift+V can paste ASCII characters.

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Could you please retest MOD+v and Ctrl+v on v1.15.1 + some more logs:

diff --git a/app/src/input_manager.c b/app/src/input_manager.c
index 1d73980c..14fe73d6 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -177,6 +177,7 @@ collapse_notification_panel(struct controller *controller) {
 static void
 set_device_clipboard(struct controller *controller, bool paste) {
     char *text = SDL_GetClipboardText();
+    LOGI("Computer clipboard: \"%s\"", text);
     if (!text) {
         LOGW("Could not get clipboard text: %s", SDL_GetError());
         return;
diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java
index 9100a9db..af3fe86a 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Controller.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java
@@ -117,6 +117,7 @@ public class Controller {
                 }
                 break;
             case ControlMessage.TYPE_SET_CLIPBOARD:
+                Ln.i("Set device clipboard (" + msg.getPaste() + "): \"" + msg.getText() + "\"");
                 setClipboard(msg.getText(), msg.getPaste());
                 break;
             case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
@@ -263,6 +264,7 @@ public class Controller {
 
         // On Android >= 7, also press the PASTE key if requested
         if (paste && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && device.supportsInputEvents()) {
+            Ln.i("Injecting PASTE");
             device.injectKeycode(KeyEvent.KEYCODE_PASTE);
         }
 
diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java
index de551f35..73a38296 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Device.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Device.java
@@ -224,6 +224,7 @@ public final class Device {
 
         String currentClipboard = getClipboardText();
         if (currentClipboard == null || currentClipboard.equals(text)) {
+            Ln.i("Clipboard already set, ignoring");
             // The clipboard already contains the requested text.
             // Since pasting text from the computer involves setting the device clipboard, it could be set twice on a copy-paste. This would cause
             // the clipboard listeners to be notified twice, and that would flood the Android keyboard clipboard history. To workaround this

Here is a binary (replace it in you v1.15.1 release):

  • scrcpy-server
    SHA256: 7ce7dbd7a23895308c284f047ea4c0dd529700e28d1b3b5f1a0abc873c0b94dc

(if you are comfortable in applying diff and build to test, please tell me, it would avoid to generate a binary next time)

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

Ctrl+V:
[server] INFO: Device: ZUK Z2 Plus (Android 7.1.2)
INFO: Renderer: direct3d
INFO: Initial texture: 1080x1920
[server] INFO: Set device clipboard (false): "1276425564@&^%$155"
[server] INFO: Clipboard already set, ignoring

MOD+V
[server] INFO: Device: ZUK Z2 Plus (Android 7.1.2)
INFO: Renderer: direct3d
INFO: Initial texture: 1080x1920
[server] INFO: Set device clipboard (true): "1276425564@&^%$155"
[server] INFO: Clipboard already set, ignoring
[server] INFO: Injecting PASTE

Neither method can paste this character into the device.

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

In fact, I really look forward to your perfect implementation of the Ctrl+V paste method.

rom1v added a commit that referenced this issue Aug 10, 2020
To avoid possible copy-paste loops between the computer and the device,
the device clipboard is not set if it already contains the expected
content.

But the condition was wrong: it was not set also if it was empty.

Refs 1223a72
Fixes #1658 <#1658>
@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Oh, got it! The condition was incorrect: 80a240c

Could you please confirm that it fixes your problem?

  • scrcpy-server
    SHA256: 4b5378ccfa4219415dc745d8224941ed65de331179cc0c5f551ef2f214bba3f7

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

Thanks, it can be pasted normally!

@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

Thank you so much, you can publish a fixed version!

rom1v added a commit that referenced this issue Aug 10, 2020
To avoid possible copy-paste loops between the computer and the device,
the device clipboard is not set if it already contains the expected
content.

But the condition was wrong: it was not set also if it was empty.

Refs 1223a72
Fixes #1658 <#1658>
@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Thank you for your report and tests 👍

Merged in dev: 95f1ea0

you can publish a fixed version!

Yes, the bug could require to publish v1.15.2, but I think that if everything is ok with the pinch-to-zoom implementation (#24 (comment)), I will probably just publish v1.16 soon.

@rom1v rom1v closed this as completed Aug 10, 2020
@Helaer
Copy link
Author

Helaer commented Aug 10, 2020

Very good, I am looking forward to it!

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

(If you have time, I'm interested in tests/feedbacks for the pinch-to-zoom feature 😉)

@rom1v
Copy link
Collaborator

rom1v commented Aug 10, 2020

Fixed in v1.16.

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

No branches or pull requests

2 participants