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

Left mouse click doesn't work in LibGDX #480

Closed
kolicoola opened this issue Mar 27, 2019 · 3 comments
Closed

Left mouse click doesn't work in LibGDX #480

kolicoola opened this issue Mar 27, 2019 · 3 comments

Comments

@kolicoola
Copy link

kolicoola commented Mar 27, 2019

Hi,
First thanks vary much for this utility - it works great on several phones.
I have encountered an issue using left mouse click inside LibGDX over android (For example on using an S6 device ).
The left mouse click only doesn't work under this framework.
After some investigations I think I have pinpointed the issue to the publication of MotionEvent.
This the event published using scrcpy (log taken from adb dumpsys input) :

MotionEvent(deviceId=0, source=0x00001002, action=0, actionButton=0x00000000, flags=0x00000000, metaState=0x00000000, buttonState=0x00000011, edgeFlags=0x00000000, xPrecision=1.0, yPrecision=1.0, displayId=0, pointers=[0: (644.0, 1942.0)]), policyFlags=0x6b000000, age=4630.1ms

And this is the event recorded from real touch screen :

MotionEvent(deviceId=0, source=0x00001002, action=0, actionButton=0x00000000, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, edgeFlags=0x00000000, xPrecision=1.0, yPrecision=1.0, displayId=0, pointers=[0: (639.0, 1952.0)]), policyFlags=0x6b000000, age=4790.0ms

The different is in the buttonState.
It seems that LibGDX is using this state (you can see relevant code in url)

I'm using following version :
scrcpy 1.8

dependencies:

  • SDL 2.0.9
  • libavcodec 58.35.100
  • libavformat 58.20.100
  • libavutil 56.22.100

Thanks

@rom1v
Copy link
Collaborator

rom1v commented Mar 27, 2019

0x11 is BUTTON_PRIMARY | BUTTON_FORWARD.

What happens if you explicitly pass 0x11:

diff --git a/server/src/main/java/com/genymobile/scrcpy/EventController.java b/server/src/main/java/com/genymobile/scrcpy/EventController.java
index 5fa2cab..9cc4316 100644
--- a/server/src/main/java/com/genymobile/scrcpy/EventController.java
+++ b/server/src/main/java/com/genymobile/scrcpy/EventController.java
@@ -139,7 +139,7 @@ public class EventController {
         }
         setPointerCoords(point);
         setScroll(hScroll, vScroll);
-        MotionEvent event = MotionEvent.obtain(lastMouseDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, 0, 1f, 1f, 0,
+        MotionEvent event = MotionEvent.obtain(lastMouseDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, 0x11, 1f, 1f, 0,
                 0, InputDevice.SOURCE_MOUSE, 0);
         return injectEvent(event);
     }

?

@kolicoola
Copy link
Author

kolicoola commented Mar 30, 2019

Hi,
passing 0x11 is the option that doesn't work. 0x00 should work (at least this what is passed when touching the screen directly)
I can't test it since I have only a pre-built version.
Thanks,

@rom1v
Copy link
Collaborator

rom1v commented Oct 25, 2019

I just fixed it for #635.

Your PR gave all the information I needed to explain the problem, but I didn't understand at the time :(

Fixed on master by 17d53be.

@rom1v rom1v closed this as completed Oct 25, 2019
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