-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Scrcpy interaction with OPPO Phone is not working #1518
Comments
Any hint in What happens if you focus some text area on your device, and execute |
Cant seem to find any hint in the logcat. adb shell input text hello worked |
Oh, that's very weird, then. Pressing What if you start with |
But what happens when you enter text in the scrcpy window? |
Hmmm. Somehow, typing in the keyboard worked in scrcpy. But the mouse still does not interact |
Probably similar to #1347. Does this work: #1347 (comment) |
Yea. It some how tapped my screen. |
Please test with older versions of scrcpy, if you find one which work, it will help a lot to find the cause. |
I have tried versions down to v1.4, scroll wheel and left mouse button does not work. Middle click and right click worked as well as the keyboard. |
scrcpy 1.12.1 dependencies:
same phone (F11 Pro), same situation, most keyboard, mid click & right click works except left click. |
Does it work or not? |
now running build master version scrcpy 1.14 dependencies:
the command works. but left click doesnt. |
Oh, could you test with this change, please: diff --git a/app/src/input_manager.c b/app/src/input_manager.c
index 9c22ee0a..7d500efe 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -511,7 +511,8 @@ convert_mouse_button(const SDL_MouseButtonEvent *from, struct screen *screen,
to->inject_touch_event.position.screen_size = screen->frame_size;
to->inject_touch_event.position.point =
screen_convert_window_to_frame_coords(screen, from->x, from->y);
- to->inject_touch_event.pressure = 1.f;
+ to->inject_touch_event.pressure =
+ from->type == SDL_MOUSEBUTTONDOWN ? 1.f : 0.f;
to->inject_touch_event.buttons =
convert_mouse_buttons(SDL_BUTTON(from->button));
|
no difference. |
Could you please test this change instead (or in addition), on diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java
index 71e7ec9c..1f249225 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Controller.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java
@@ -11,7 +11,7 @@ import java.io.IOException;
public class Controller {
- private static final int DEVICE_ID_VIRTUAL = -1;
+ private static final int DEVICE_ID_VIRTUAL = 0;
private final Device device;
private final DesktopConnection connection;
(I use the one from current Note: |
i got nothing (instead and in-addition). |
@GetCurious OK, just to be sure, you are building the server (you don't use the prebuilt-server)? What we have to understand is why this works ( but this does not: scrcpy/server/src/main/java/com/genymobile/scrcpy/Controller.java Lines 198 to 200 in 5fa46ad
|
anything i miss? |
Let's try to use a device id matching the input source, like they do: diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java
index 71e7ec9c..c1949f36 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Controller.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java
@@ -195,12 +195,26 @@ public class Controller {
}
}
+ int deviceId = getInputDeviceId(InputDevice.SOURCE_TOUCHSCREEN);
+ Ln.i("device id = " + deviceId);
MotionEvent event = MotionEvent
- .obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEVICE_ID_VIRTUAL, 0,
+ .obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, deviceId, 0,
InputDevice.SOURCE_TOUCHSCREEN, 0);
return device.injectEvent(event);
}
+ private static int getInputDeviceId(int inputSource) {
+ final int DEFAULT_DEVICE_ID = 0;
+ int[] devIds = InputDevice.getDeviceIds();
+ for (int devId : devIds) {
+ InputDevice inputDev = InputDevice.getDevice(devId);
+ if (inputDev.supportsSource(inputSource)) {
+ return devId;
+ }
+ }
+ return DEFAULT_DEVICE_ID;
+ }
+
private boolean injectScroll(Position position, int hScroll, int vScroll) {
long now = SystemClock.uptimeMillis();
Point point = device.getPhysicalPoint(position); |
no difference |
What's the id printed in the console when you click with this change? |
how do i do that? |
When you execute |
|
And nothing more, even when you click in the scrcpy window? EDIT: in itself:
it's a bit surprising (the device sends frame at a different resolution from what has been requested). But probably not related. |
that's right... nothing more. |
Yes, I know the FAQ and this point. The setting also exists in my phone but cannot be changed for unknown reason. |
okay, after two hours of trying i finally found out the solution. just run this command in terminal |
and for the desktop entry in linux (ubuntu) just create a file under /usr/share/applications/scrcpy.desktop |
In case this helps troubleshoot the display size issues: My Lenovo tablet has a 1920x1200 screen. scrcpy outputs 1920x1080 and the other 120 pixels are just cut off. In portrait mode, the right side of the screen is cut off. In landscape, the bottom of the screen is missing. Touch events do not work. scrcpy -m 1920 # does not help
|
i have same case.
|
@hhhaiai And also:
Ultra-old. You should upgrade to the latest version. |
ok |
@rom1v same case.
|
already update 2.4, still has same exception |
It's ok。 why not auto support general size. 3Q~~ |
Because this is a bug in the encoder: we request a size, it produces a video with a different size without notice (and we can't know that easily on the device side without parsing the encoded video stream). In general, scrcpy tries a size, then attempts a smaller size if it fails… But some encoders don't fail, but decide to produce a video with a different size instead. |
First startup, will prompt [INFO: Texture: 910x1920]
|
The actual resolution is detected on the client side, once the video stream is parsed/decoded. The server side thinks the resolution is what it requested. When then client sends a mouse events, the server detects a mismatch (which can happen in expected conditions like when the device is physically rotated between the instant an event is triggered on the client side and the time it is injected on the server side), and ignores the event (with a warning). |
How is this solution (scrcpy - m1920 *) implemented? |
That's a lot of work / round trip / guess to workaround an encoder bug which impacts only few devices. Btw, in some cases -m1920 does not fix the problem, because many encoders require both dimensions to be a multiple of 8 (for example see #1645 (comment)). And you would have to handle this encoder bug on rotation too (the encoder might accept the initial size, but after a rotation the width or height exceeds its maximum and sends a video with another size). Anyway, a good solution would be to make the encoder fail if it does not support the requested size, but that's up to the encoders implementations. Btw, you could try with another encoder. |
What you said is indeed an issue, and compatibility issues with a few devices are indeed a troublesome matter Now is a compatibility issue with some devices. As time goes on, it is expected that the number of devices with this issue will continue to increase. It may not be Replace the encoder as per your proposal $scrcpy -- list encoders
Scrcpy 2.4< https://github.com/Genymobile/scrcpy >
INFO: ADB device found:
INFO: -->(USB) PVRKRAAV8IBININ device PACM00
/Usr/local/Cellar/scrcpy/2.4/share/scrcpy/scrcpy server: 1 file pushed, 0 skipped 282.3 MB/s (69007 bytes in 0.000s)
[server] INFO: Device: [OPPO] OPPO PACM00 (Android 10)
[server] INFO: List of video encoders:
--Video code=h264-- video encoder='OMX MTK VIDEO ENCODER AVC '
--Video code=h264-- video encoder='c2. android. avc. encoder '
--Video code=h264-- video encoder='OMX. Google. h264. encoder '
[server] INFO: List of audio encoders:
--Audio code=opus -- audio encoder='c2. android. opus. encoder '
--Audio code=aac -- audio encoder='OMX. Google. aac. encoder '
--Audio code=aac -- audio encoder='c2. android. aac. encoder '
--Audio code=flac -- audio encoder='OMX. Google. flac. encoder '
--Audio code=flac -- audio encoder='c2. android. flac. encoder ' There are two decoders that can work. Can the decoders be dynamically switched during operation
Of course, this is also a suggestion |
Why that? If the encoder does not support the requested size, it should fail (as most of encoders do). Also, another problem is that the encoder produces a video at a different resolution than that requested, but we don't know how the video is scaled/cropped (some may add some black borders, other may stretch the video…), so we don't know for sure how to map input events back to thebdevice coordinates. Btw, in your case, one dimension is 910, which is not even a multiple of 8.
No, one must be explicitly selected. There is no absolute criteria to select "the best". |
ok. 3Q |
Hey man I am new to all this can you guide me through all that I have to do for this to work? |
@riotcult Read https://github.com/Genymobile/scrcpy/blob/master/doc/windows.md#run |
I have tried scrcpy and various guidelines for mirroring phones via scrcpy but it seems that the interaction with keyboard and mouse and audio does not work with my OPPO F11.
Help
The text was updated successfully, but these errors were encountered: