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.6 mouse issues #5162

Closed
chinagaofeng opened this issue Aug 2, 2024 · 13 comments
Closed

2.6 mouse issues #5162

chinagaofeng opened this issue Aug 2, 2024 · 13 comments

Comments

@chinagaofeng
Copy link

as 2.6 said:

By default, a simple click triggers the shortcuts, and Shift+click forwards the click to the device.

I hate this default setting! It makes very inconvenience for control than 2.5. I have to roll-back.

my cli is just "scrcpy -Sw", means I use SDK mouse

@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

I hate this default setting! It makes very inconvenience for control than 2.5. I have to roll-back.

If you just click (with a secondary button), it is the same behavior as v2.5… and earlier versions.

What changes is only when you Shift+click, there are new bindings.

@chinagaofeng
Copy link
Author

I hate this default setting! It makes very inconvenience for control than 2.5. I have to roll-back.

If you just click (with a secondary button), it is the same behavior as v2.5… and earlier versions.

What changes is only when you Shift+click, there are new bindings.

not exactly same, for example: in 2.5-, holding left button and dragging, works same as middle button scrolling; but in 2.6, holding-dragging works but mid-scrolling not works, or mid-scrolling works while holding-dragging not works, can't determine why

@vferrenq
Copy link

vferrenq commented Aug 2, 2024

I encounter also a problem with 2.6 (Ubuntu 22.04). A simple left click acts as a long press. I have also to rollback to 2.5 and everything works as expected.

@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

OK, that's a bug then. Not caused by the binding changes directly, but probably by either 6808288, 51fee79 or 6baea57.

I will bisect and investigate (hopefully tonight or tomorrow).

@vidoardes
Copy link

I am also experiencing this issue, is there an easy way to downgrade on Fedora? I tried sudo dnf downgrade scrcpy but it appears previous versions of the package has been removed

@rom1v rom1v changed the title 2.6 Mouse default Aug 2, 2024
@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

but in 2.6, holding-dragging works but mid-scrolling not works, or mid-scrolling works while holding-dragging not works

OK, so now I'm on my computer, I tried to reproduce, but I fail. For example, in the settings, I can either scroll or click & drag.

Is it "random"? Or 100% reproducible?

Could you please give more information:

  • what device model?
  • in which app does it happen?
@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

Oh, I understand, in Firefox, I can scroll using middle-scroll, but not by click&drag (because now it behaves like a mouse rather than a finger). This is definitely due to 6808288.

So I will need to restore a pointer, but that will cause other problems (for example, mouse hover needs a mouse: #5067). Will need to find something which works for all cases.

@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

Oh, using a "finger" tool type in all cases seems to be sufficient:

diff --git a/server/src/main/java/com/genymobile/scrcpy/control/Controller.java b/server/src/main/java/com/genymobile/scrcpy/control/Controller.java
index 85425113a..a5cda74cf 100644
--- a/server/src/main/java/com/genymobile/scrcpy/control/Controller.java
+++ b/server/src/main/java/com/genymobile/scrcpy/control/Controller.java
@@ -278,14 +278,16 @@ public class Controller implements AsyncProcessor {
         pointer.setPressure(pressure);
 
         int source;
+
+        // Always behave like a finger (to scroll a page via Click+drag)
+        pointerProperties[pointerIndex].toolType = MotionEvent.TOOL_TYPE_FINGER;
+
         if (pointerId == POINTER_ID_MOUSE) {
             // real mouse event
-            pointerProperties[pointerIndex].toolType = MotionEvent.TOOL_TYPE_MOUSE;
             source = InputDevice.SOURCE_MOUSE;
             pointer.setUp(buttons == 0);
         } else {
             // POINTER_ID_GENERIC_FINGER, POINTER_ID_VIRTUAL_FINGER or real touch from device
-            pointerProperties[pointerIndex].toolType = MotionEvent.TOOL_TYPE_FINGER;
             source = InputDevice.SOURCE_TOUCHSCREEN;
             // Buttons must not be set for touch events
             buttons = 0;

Please test by replacing this file in the scrcpy v2.6 release folder:

  • scrcpy-server SHA-256: 9ceb957ade7f2df9c59e8b8af8856239365687a05e4624c39bee2decff9f5e0
@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

@vidoardes you can download the scrcpy-server above and test with:

export SCRCPY_SERVER_PATH=/xxx/scrcpy-server  # adapt the path
scrcpy
@vidoardes
Copy link

@vidoardes you can download the scrcpy-server above and test with:

export SCRCPY_SERVER_PATH=/xxx/scrcpy-server  # adapt the path
scrcpy

I can confirm it fixes scrolling in Firefox, but not in all apps. Not sure what the difference is, but one example is a game call Gold & Goblins which doesn't now work (but did in 2.5)

@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

OK, thank you very much. Now I can reproduce and debug easily 👍

The the trick in #5162 (comment) is not correct: it works only if the input is a SOURCE_TOUCHSCREEN. So back to the previous comment (#5162 (comment)). Will need more thinking to make everything work with a single solution.

rom1v added a commit that referenced this issue Aug 2, 2024
Even if the pointer is a mouse, inject it as a finger unless it is
required to be a mouse, that is:
 - when it is a HOVER_MOUSE event, or
 - when a secondary button is pressed.

Some apps/games only accept events from a finger/touchscreen, so using a
mouse by default does not work for them.

For simplicity, make this change on the server side just before
event injection (so that the client does not need to know about this
hacky behavior).

Refs 6808288
Refs c7b1d0e
Fixes #5162 <#5162>
rom1v added a commit that referenced this issue Aug 2, 2024
Even if the pointer is a mouse, inject it as a finger unless it is
required to be a mouse, that is:
 - when it is a HOVER_MOUSE event, or
 - when a secondary button is pressed.

Some apps/games only accept events from a finger/touchscreen, so using a
mouse by default does not work for them.

For simplicity, make this change on the server side just before
event injection (so that the client does not need to know about this
hacky behavior).

Refs 6808288
Refs c7b1d0e
Fixes #5162 <#5162>
@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

Please test with this change (89288c9):

  • scrcpy-server SHA-256: 6a4a5f2f14a511ab64e8717e0c0c1fb173a57cad4f53cc6ad8e19aba6715de8
@rom1v rom1v closed this as completed in 773c23f Aug 2, 2024
@rom1v
Copy link
Collaborator

rom1v commented Aug 2, 2024

Fixed in scrcpy 2.6.1.

Gottox pushed a commit to Gottox/scrcpy that referenced this issue Sep 29, 2024
Even if the pointer is a mouse, inject it as a finger unless it is
required to be a mouse, that is:
 - when it is a HOVER_MOUSE event, or
 - when a secondary button is pressed.

Some apps/games only accept events from a finger/touchscreen, so using a
mouse by default does not work for them.

For simplicity, make this change on the server side just before
event injection (so that the client does not need to know about this
hacky behavior).

Refs 6808288
Refs c7b1d0e
Fixes Genymobile#5162 <Genymobile#5162>
Fixes Genymobile#5163 <Genymobile#5163>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants