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

Android 14: Samsung phones - mouse actions (left click/scroll) stop working on virtual display #4598

Closed
huynhtanloc2612 opened this issue Jan 19, 2024 · 22 comments

Comments

@huynhtanloc2612
Copy link

Hi developers.
I am facing an issue when using scrcpy (v2.3.1) after updating my Samsung S22 ultra phone (SM-S908E) from Android 13 to 14.
An other display is automatically created when scrcpy connects with the phone.

Display id numbers before starting scrcpy

  mDisplayId=: 0 -> primary display (phone screen)
  mDisplayId=: 2 -> for Samsung DeX display

Display id numbers after starting scrcpy

  mDisplayId=: 0 -> primary display (phone screen)
  mDisplayId=: 2 -> for Samsung DeX display
  mDisplayId=: 80 -> a new display id is created

A new display (id=80) is created. But there is no issue with this if I want to mirror the phone screen. Everything works perfectly.

Similarly, when I want to mirror virtual display with option (--display-id 90) as some ways mentioned in #1887 (comment) and #1887 (comment), an new display is also created with id=91

  mDisplayId=: 0 -> primary display (phone screen)
  mDisplayId=: 2 -> for Samsung DeX display
  mDisplayId=:90 -> virtual display id
  mDisplayId=:91 -> a new display id is created

scrcpy can show the virtual display (id=90), input text from keyboard works but click action does not work.
I try to perform input events by using adb and found that virtual display can receive inputs via display with id=91 instead of id=90

adb shell input -d 90 tap 100 800 -> not work
adb shell input -d 91 tap 100 800 -> work

-> I think the created display (id=91) is used for receiving the tap/click events. In order to prove that I start another scrcpy with --display-id=91 option. Another scrcpy can show the virtual display content and all click events work (they are injected to display with id=91).
I think this may be the intention of Samsung for Samsung DeX mode or something else.

Can you help give adivces on this case? Thanks,

@huynhtanloc2612 huynhtanloc2612 changed the title An other display is automatically created when scrcpy connect with Android 14/Samsung phones Android 14: Samsung phones - mouse actions (left click/scroll) stop working on virtual display Jan 23, 2024
@astroskyoffical
Copy link

Hi developers. I am facing an issue when using scrcpy (v2.3.1) after updating my Samsung S22 ultra phone (SM-S908E) from Android 13 to 14. An other display is automatically created when scrcpy connects with the phone.

Display id numbers before starting scrcpy

  mDisplayId=: 0 -> primary display (phone screen)
  mDisplayId=: 2 -> for Samsung DeX display

Display id numbers after starting scrcpy

  mDisplayId=: 0 -> primary display (phone screen)
  mDisplayId=: 2 -> for Samsung DeX display
  mDisplayId=: 80 -> a new display id is created

A new display (id=80) is created. But there is no issue with this if I want to mirror the phone screen. Everything works perfectly.

Similarly, when I want to mirror virtual display with option (--display-id 90) as some ways mentioned in #1887 (comment) and #1887 (comment), an new display is also created with id=91

  mDisplayId=: 0 -> primary display (phone screen)
  mDisplayId=: 2 -> for Samsung DeX display
  mDisplayId=:90 -> virtual display id
  mDisplayId=:91 -> a new display id is created

scrcpy can show the virtual display (id=90), input text from keyboard works but click action does not work. I try to perform input events by using adb and found that virtual display can receive inputs via display with id=91 instead of id=90

adb shell input -d 90 tap 100 800 -> not work
adb shell input -d 91 tap 100 800 -> work

-> I think the created display (id=91) is used for receiving the tap/click events. In order to prove that I start another scrcpy with --display-id=91 option. Another scrcpy can show the virtual display content and all click events work (they are injected to display with id=91). I think this may be the intention of Samsung for Samsung DeX mode or something else.

Can you help give adivces on this case? Thanks,

got the same issue on oneplus 8t android 14 custom rom. your right it makes another display and click events pass to it. but on the other display nothing however my attempt is to use the PER APP screen share app called ag displays. any display it shares no input can pass. not even controllers connected to the android device itself for gaming purposes. not sure how to work around this. so far the only thing that works for me is desktop mode and dealing with the ugly bar at the top even if freeform is disabled., really not sure what is going on,.

@astroskyoffical
Copy link

don't think this is an intended behaviour as some people this works just fine, I sure hope someone can come in and help us out. iv been trying to fix this for awhile myself

@huynhtanloc2612
Copy link
Author

so far the only thing that works for me is desktop mode

For Samsung phones, the same issue even with desktop mode.
My current workaround is to open two scrcpy windows at the same time for a virtual display: one with ---display-id=90 is for keyboard events... the other with --display-id=91 is for click events.
However, above workaround is inconvenient. So hope scrcpy developers have a look for the solution (e.g: add the display id for click events like ---click-event-display-id=91 option...). Thanks.

@huynhtanloc2612
Copy link
Author

Hi @rom1v ,
I am trying to find the way to fix above issue.
Does below line determine which display all input events go to?

If yes, I think we can fix above issue by adding addtional call for Samsung devices with Android 14 version
method.invoke(inputEvent, displayId + 1);

Please correct me if I am wrong. Thank you for your time.

@rom1v
Copy link
Collaborator

rom1v commented Mar 20, 2024

It might solve the problem in specific cases, but why is the display id for events is different from the display id for display? Is it always +1? On which devices? (because on many devices it's the same)

@huynhtanloc2612
Copy link
Author

huynhtanloc2612 commented Mar 21, 2024

Thanks @rom1v for your reply.

but why is the display id for events is different from the display id for display?

I actually don't know the exact reason. But I think this for something relating to Samsung Dex because I could see similiar things before Android 14 when I tried to mirror the activated Dex display (display-id=2) by scrcpy tool, a new display with display-id=3 for example was also created then. I could see the content of display-id=2 but there was no thing but black window with display-id=3 (I guess it was used for receiving events from PC Dex app). Mirroring virtual display (not Dex display) in Samsung devices before Android 14 did not create a new display-id. This just happened from Android 14. In addition, I could see Dex mode had obvious enhancement in Android 14, it now has similar experience like virtual display rather than independent system app. I think Samsung aligned/adapted Dex mode with virtual display/desktop experience.

Is it always +1?

For general cases, it should be a new added ID number in display list.
E.g: Assuming a device has some below display IDs

mDisplayId=: 0 -> primary display (phone screen)
mDisplayId=: 2 -> for Samsung DeX display
mDisplayId=: 3 -> virtual display id
mDisplayId=: 4 -> virtual display id

If I mirror the display with display-id=3, a new display with display-id=5 is created to receive left mouse click and scroll actions only (right mouse click actions, texts from keyboard... still works on display-id=3)

On which devices? (because on many devices it's the same)

About this, I think we should have a switch/option like --click-event-display-id=5 for only the device which is facing above issue.
E.g: scrcpy --display-id=3 --click-event-display-id=5

Please tell me your opinion?
Thanks.

@huynhtanloc2612
Copy link
Author

huynhtanloc2612 commented Aug 31, 2024

Hi @rom1v
As mentioned in #4598 (comment) , I am trying to make some fixes in scrcpy server code.
I am seeing that below line can be modified to choose the display id for a input event.

if (displayId != 0 && !InputManager.setDisplayId(inputEvent, displayId)) {

I wonder if there is any way to determine action type from the input event so that I can set all left mouse click/scroll actions with a special display id (clickDisplayId) and other actions (right click, keyboard...) with (displayId). I have been doing some research on the internet but I have not found out the way.

if ( "a left mouse or scroll action") {
    InputManager.setDisplayId(inputEvent, clickDisplayId)
} else {
    InputManager.setDisplayId(inputEvent, displayId)
}

Do you have any idea?
Thanks.

@huynhtanloc2612
Copy link
Author

huynhtanloc2612 commented Sep 1, 2024

Hi @rom1v
I have found out another way to implement additional display ID for click/scroll actions.
I added additional option which is --add-display-id to specify an display ID for click/scroll actions and modified Controller.java file accordingly with the new option as shown below

...
//From line 320 of Controller.java
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && source == InputDevice.SOURCE_MOUSE) {
            if (action == MotionEvent.ACTION_DOWN) {
                if (actionButton == buttons) {
                    // First button pressed: ACTION_DOWN
                    MotionEvent downEvent = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_DOWN, pointerCount, pointerProperties,
                            pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source, 0);
               //     if (!device.injectEvent(downEvent, Device.INJECT_MODE_ASYNC)) {
               //         return false;
               //     }
                    //Comment out above original code
                    if (addDisplayId > 0) {
                        if (!device.injectEvent(downEvent, addDisplayId, Device.INJECT_MODE_ASYNC)) {
                                return false;
                        }
                    } else {
                        if (!device.injectEvent(downEvent, Device.INJECT_MODE_ASYNC)) {
                                return false;
                        }
                    }
                    //Add above code
                }

                // Any button pressed: ACTION_BUTTON_PRESS
                MotionEvent pressEvent = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_BUTTON_PRESS, pointerCount, pointerProperties,
                        pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source, 0);
                if (!InputManager.setActionButton(pressEvent, actionButton)) {
                    return false;
                }
                //if (!device.injectEvent(pressEvent, Device.INJECT_MODE_ASYNC)) {
                //    return false;
                //}
                //Comment out above original code
                if (addDisplayId > 0) {
                    if (!device.injectEvent(pressEvent, addDisplayId, Device.INJECT_MODE_ASYNC)) {
                                return false;
                    }
                } else {
                    if (!device.injectEvent(pressEvent, Device.INJECT_MODE_ASYNC)) {
                                return false;
                    }
                }
                //Add above code
                return true;
            }
           if (action == MotionEvent.ACTION_UP) {
                // Any button released: ACTION_BUTTON_RELEASE
                MotionEvent releaseEvent = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_BUTTON_RELEASE, pointerCount, pointerProperties,
                        pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source, 0);
                if (!InputManager.setActionButton(releaseEvent, actionButton)) {
                    return false;
                }
                //if (!device.injectEvent(releaseEvent, Device.INJECT_MODE_ASYNC)) {
                //    return false;
                //}
                //Comment out above original code
                if (addDisplayId > 0) {
                    if (!device.injectEvent(releaseEvent, addDisplayId, Device.INJECT_MODE_ASYNC)) {
                                return false;
                    }
                } else {
                    if (!device.injectEvent(releaseEvent, Device.INJECT_MODE_ASYNC)) {
                                return false;
                    }
                }
                //Add above code
                if (buttons == 0) {
                    // Last button released: ACTION_UP
                    MotionEvent upEvent = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_UP, pointerCount, pointerProperties,
                            pointerCoords, 0, buttons, 1f, 1f, DEFAULT_DEVICE_ID, 0, source, 0);
                    //if (!device.injectEvent(upEvent, Device.INJECT_MODE_ASYNC)) {
                    //    return false;
                    //}
                    //Comment out above original code
                    if (addDisplayId > 0) {
                        if (!device.injectEvent(upEvent, addDisplayId, Device.INJECT_MODE_ASYNC)) {
                                return false;
                        }
                    } else {
                        if (!device.injectEvent(upEvent, Device.INJECT_MODE_ASYNC)) {
                                return false;
                        }
                    }
                    //Add above code
                }

                return true;
            }
        }
        MotionEvent event = MotionEvent.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f,
                DEFAULT_DEVICE_ID, 0, source, 0);
        //return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
        //Comment out above original code
        if (addDisplayId > 0) {
            return device.injectEvent(event, addDisplayId, Device.INJECT_MODE_ASYNC);
        } else {
            return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
        }
        //Add above code
    }

    private boolean injectScroll(Position position, float hScroll, float vScroll, int buttons) {
        long now = SystemClock.uptimeMillis();
        Point point = device.getPhysicalPoint(position);
        if (point == null) {
            // ignore event
            return false;
        }

        MotionEvent.PointerProperties props = pointerProperties[0];
        props.id = 0;

        MotionEvent.PointerCoords coords = pointerCoords[0];
        coords.x = point.getX();
        coords.y = point.getY();
        coords.setAxisValue(MotionEvent.AXIS_HSCROLL, hScroll);
        coords.setAxisValue(MotionEvent.AXIS_VSCROLL, vScroll);

        MotionEvent event = MotionEvent.obtain(lastTouchDown, now, MotionEvent.ACTION_SCROLL, 1, pointerProperties, pointerCoords, 0, buttons, 1f, 1f,
                DEFAULT_DEVICE_ID, 0, InputDevice.SOURCE_MOUSE, 0);
        //return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
        //Comment out above original code
        if (addDisplayId > 0) {
            return device.injectEvent(event, addDisplayId, Device.INJECT_MODE_ASYNC);
        } else {
            return device.injectEvent(event, Device.INJECT_MODE_ASYNC);
        }
        //Add above code
   ...

With above modification, scrcpy works as expected (all actions including click/scroll,... works on virtual display of Android 14 devices)
Run command: scrcpy --display-id=<virtual_display_id> --add-display-id=<additional-display-id-for-click-and-scroll-actions>
Do you have any comment?
Thanks,

@rom1v
Copy link
Collaborator

rom1v commented Sep 1, 2024

@huynhtanloc2612 I will check when I work on #5175, but I have to finish my work on gamepads beforehand (#5175 (review)).

@huynhtanloc2612
Copy link
Author

Thanks @rom1v
I am trying to create releases for testing on Windows. I follows https://github.com/Genymobile/scrcpy/blob/master/doc/build.md#windows but looks there is error of mingw-w64 as mentioned in libsdl-org/SDL#8324
My logs:

./gradlew clean

BUILD SUCCESSFUL in 713ms
1 actionable task: 1 executed
rm -rf "dist" "build-test" "build-server" \
        "build-win32" "build-win64"
[ -d "build-test" ] || ( mkdir "build-test" && \
	meson setup "build-test" -Db_sanitize=address )
The Meson build system
Version: 0.61.5
Source dir: /home/loc/Downloads/scrcpy
Build dir: /home/loc/Downloads/scrcpy/build-test
Build type: native build
Project name: scrcpy
Project version: 2.6.1
C compiler for the host machine: cc (gcc 7.5.0 "cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0")
C linker for the host machine: cc ld.bfd 2.30
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Run-time dependency libavformat found: YES 57.83.100
Run-time dependency libavcodec found: YES 57.107.100
Run-time dependency libavutil found: YES 55.78.100
Run-time dependency libswresample found: YES 2.9.100
Run-time dependency sdl2 found: YES 2.0.8
Run-time dependency libavdevice found: YES 57.10.100
Run-time dependency libusb-1.0 found: YES 1.0.21
Checking for function "strdup" : YES 
Checking for function "asprintf" : YES 
Checking for function "vasprintf" : YES 
Checking for function "nrand48" : YES 
Checking for function "jrand48" : YES 
Checking for function "reallocarray" : YES 
Header <sys/socket.h> has symbol "SOCK_CLOEXEC" : YES 
Configuring config.h using configuration
Program ./scripts/build-wrapper.sh found: YES (/home/loc/Downloads/scrcpy/server/./scripts/build-wrapper.sh)
Build targets in project: 13

scrcpy 2.6.1

  User defined options
    b_sanitize: address

Found ninja-1.8.2 at /usr/bin/ninja
NOTICE: You are using Python 3.6 which is EOL. Starting with v0.62.0, Meson will require Python 3.7 or newer
ninja -C "build-test"
ninja: Entering directory `build-test'
[111/124] Generating server/scrcpy-server with a custom command

BUILD SUCCESSFUL in 1s
33 actionable tasks: 33 executed
[123/124] Linking target app/test_vector
./gradlew -p server check

> Task :server:lintReportDebug
Wrote HTML report to file:///home/loc/Downloads/scrcpy/server/build/reports/lint-results-debug.html

> Task :server:checkstyle
[ant:checkstyle] [ERROR] /home/loc/Downloads/scrcpy/server/src/main/java/com/genymobile/scrcpy/Options.java:38:29: ';' is not followed by whitespace. [WhitespaceAfter]
[ant:checkstyle] [INFO] /home/loc/Downloads/scrcpy/server/src/main/java/com/genymobile/scrcpy/Options.java:140: Line has trailing spaces. [RegexpSingleline]
[ant:checkstyle] [ERROR] /home/loc/Downloads/scrcpy/server/src/main/java/com/genymobile/scrcpy/Options.java:140:16: File contains tab characters (this is the first instance). [FileTabCharacter]
[ant:checkstyle] [ERROR] /home/loc/Downloads/scrcpy/server/src/main/java/com/genymobile/scrcpy/control/Controller.java:48:29: ';' is not followed by whitespace. [WhitespaceAfter]
[ant:checkstyle] [ERROR] /home/loc/Downloads/scrcpy/server/src/main/java/com/genymobile/scrcpy/control/Controller.java:61:1: File contains tab characters (this is the first instance). [FileTabCharacter]
[ant:checkstyle] [ERROR] /home/loc/Downloads/scrcpy/server/src/main/java/com/genymobile/scrcpy/control/Controller.java:264:5: Method injectTouch length is 157 lines (max allowed is 150). [MethodLength]
Checkstyle rule violations were found. See the report at: file:///home/loc/Downloads/scrcpy/server/build/reports/checkstyle/checkstyle.html
Checkstyle files with violations: 2
Checkstyle violations by severity: [error:5, info:1]


BUILD SUCCESSFUL in 6s
55 actionable tasks: 38 executed, 17 up-to-date
[ -d "build-server" ] || ( mkdir "build-server" && \
        meson setup "build-server" --buildtype release -Dcompile_app=false )
The Meson build system
Version: 0.61.5
Source dir: /home/loc/Downloads/scrcpy
Build dir: /home/loc/Downloads/scrcpy/build-server
Build type: native build
Project name: scrcpy
Project version: 2.6.1
C compiler for the host machine: cc (gcc 7.5.0 "cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0")
C linker for the host machine: cc ld.bfd 2.30
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program ./scripts/build-wrapper.sh found: YES (/home/loc/Downloads/scrcpy/server/./scripts/build-wrapper.sh)
Build targets in project: 1

scrcpy 2.6.1

  User defined options
    buildtype  : release
    compile_app: false

Found ninja-1.8.2 at /usr/bin/ninja
NOTICE: You are using Python 3.6 which is EOL. Starting with v0.62.0, Meson will require Python 3.7 or newer
ninja -C "build-server"
ninja: Entering directory `build-server'
[0/1] Generating server/scrcpy-server with a custom command

BUILD SUCCESSFUL in 3s
43 actionable tasks: 24 executed, 19 up-to-date
++ dirname app/deps/adb.sh
+ DEPS_DIR=app/deps
+ cd app/deps
+ . common
++ [[ 1 != 1 ]]
++ HOST=win32
++ [[ win32 = win32 ]]
++ HOST_TRIPLET=i686-w64-mingw32
+++ dirname common
++ DEPS_DIR=.
++ cd .
++ PATCHES_DIR=/home/loc/Downloads/scrcpy/app/deps/patches
++ WORK_DIR=/home/loc/Downloads/scrcpy/app/deps/work
++ SOURCES_DIR=/home/loc/Downloads/scrcpy/app/deps/work/sources
++ BUILD_DIR=/home/loc/Downloads/scrcpy/app/deps/work/build
++ INSTALL_DIR=/home/loc/Downloads/scrcpy/app/deps/work/install
++ mkdir -p /home/loc/Downloads/scrcpy/app/deps/work/install /home/loc/Downloads/scrcpy/app/deps/work/sources /home/loc/Downloads/scrcpy/app/deps/work
+ VERSION=35.0.0
+ FILENAME=platform-tools_r35.0.0-windows.zip
+ PROJECT_DIR=platform-tools-35.0.0
+ SHA256SUM=7ab78a8f8b305ae4d0de647d99c43599744de61a0838d3a47bda0cdffefee87e
+ cd /home/loc/Downloads/scrcpy/app/deps/work/sources
+ [[ -d platform-tools-35.0.0 ]]
+ echo /home/loc/Downloads/scrcpy/app/deps/work/sources/platform-tools-35.0.0 found
/home/loc/Downloads/scrcpy/app/deps/work/sources/platform-tools-35.0.0 found
+ mkdir -p /home/loc/Downloads/scrcpy/app/deps/work/install/win32/bin
+ cd /home/loc/Downloads/scrcpy/app/deps/work/install/win32/bin
+ cp -r /home/loc/Downloads/scrcpy/app/deps/work/sources/platform-tools-35.0.0/. /home/loc/Downloads/scrcpy/app/deps/work/install/win32/bin/
++ dirname app/deps/sdl.sh
+ DEPS_DIR=app/deps
+ cd app/deps
+ . common
++ [[ 1 != 1 ]]
++ HOST=win32
++ [[ win32 = win32 ]]
++ HOST_TRIPLET=i686-w64-mingw32
+++ dirname common
++ DEPS_DIR=.
++ cd .
++ PATCHES_DIR=/home/loc/Downloads/scrcpy/app/deps/patches
++ WORK_DIR=/home/loc/Downloads/scrcpy/app/deps/work
++ SOURCES_DIR=/home/loc/Downloads/scrcpy/app/deps/work/sources
++ BUILD_DIR=/home/loc/Downloads/scrcpy/app/deps/work/build
++ INSTALL_DIR=/home/loc/Downloads/scrcpy/app/deps/work/install
++ mkdir -p /home/loc/Downloads/scrcpy/app/deps/work/install /home/loc/Downloads/scrcpy/app/deps/work/sources /home/loc/Downloads/scrcpy/app/deps/work
+ VERSION=2.30.5
+ FILENAME=SDL-2.30.5.tar.gz
+ PROJECT_DIR=SDL-release-2.30.5
+ SHA256SUM=be3ca88f8c362704627a0bc5406edb2cd6cc6ba463596d81ebb7c2f18763d3bf
+ cd /home/loc/Downloads/scrcpy/app/deps/work/sources
+ [[ -d SDL-release-2.30.5 ]]
+ echo /home/loc/Downloads/scrcpy/app/deps/work/sources/SDL-release-2.30.5 found
/home/loc/Downloads/scrcpy/app/deps/work/sources/SDL-release-2.30.5 found
+ mkdir -p /home/loc/Downloads/scrcpy/app/deps/work/build/SDL-release-2.30.5
+ cd /home/loc/Downloads/scrcpy/app/deps/work/build/SDL-release-2.30.5
+ export CFLAGS=-O2
+ CFLAGS=-O2
+ export CXXFLAGS=-O2
+ CXXFLAGS=-O2
+ [[ -d win32 ]]
+ echo ''\''/home/loc/Downloads/scrcpy/app/deps/work/build/SDL-release-2.30.5/win32'\'' already exists, not reconfigured'
'/home/loc/Downloads/scrcpy/app/deps/work/build/SDL-release-2.30.5/win32' already exists, not reconfigured
+ cd win32
+ make -j
make[1]: Entering directory '/home/loc/Downloads/scrcpy/app/deps/work/build/SDL-release-2.30.5/win32'
/bin/bash /home/loc/Downloads/scrcpy/app/deps/work/sources/SDL-release-2.30.5/build-scripts//updaterev.sh --vendor ""
  CC     build/SDL_hidapi.lo
In file included from /usr/share/mingw-w64/include/oledlg.h:25:0,
                 from /usr/share/mingw-w64/include/setupapi.h:27,
                 from /home/loc/Downloads/scrcpy/app/deps/work/sources/SDL-release-2.30.5/src/hidapi/windows/hid.c:69,
                 from /home/loc/Downloads/scrcpy/app/deps/work/sources/SDL-release-2.30.5/src/hidapi/SDL_hidapi.c:589:
/usr/share/mingw-w64/include/commdlg.h:621:5: error: unknown type name ‘LPUNKNOWN’
     LPUNKNOWN lpCallback;
     ^~~~~~~~~
/usr/share/mingw-w64/include/commdlg.h:645:5: error: unknown type name ‘LPUNKNOWN’
     LPUNKNOWN lpCallback;
     ^~~~~~~~~
Makefile:374: recipe for target 'build/SDL_hidapi.lo' failed
make[1]: *** [build/SDL_hidapi.lo] Error 1
make[1]: Leaving directory '/home/loc/Downloads/scrcpy/app/deps/work/build/SDL-release-2.30.5/win32'
release.mk:66: recipe for target 'prepare-deps-win32' failed
make: *** [prepare-deps-win32] Error 2

I wonder if there is any other way to create Windows release?
Thanks

@huynhtanloc2612
Copy link
Author

huynhtanloc2612 commented Sep 1, 2024

Hi @rom1v ,
I could fix above issue by editing the file /urs/share/mingw-w64/include/setupapi.h as mentioned in libsdl-org/SDL#8324 .
I tested and confirmed that it could work on both Ubuntu and Windows.
I'd like to attached the releases for test purposes on Windows for who interests in the meantime.
scrcpy-win64-v2.6.1-2-g21e2e260.zip
scrcpy-win32-v2.6.1-2-g21e2e260.zip

Run command: scrcpy --display-id=<virtual_display_id> --add-display-id=<additional-display-id-for-click-and-scroll-actions>
E.g: scrcpy --display-id=8 --add-display-id=9

In order to create an virtual displays, you can refer to this video https://youtu.be/ysv5OL3IL1w?si=UI23s580cuACOaRr

@vaddisrinivas
Copy link

This is a very useful PR, can we please get this merged?

@rom1v
Copy link
Collaborator

rom1v commented Oct 12, 2024

Please test #5370.

@huynhtanloc2612
Copy link
Author

Please test #5370.

Thanks @rom1v
It works perfectly on my Galaxy S22 Ultra phones with Android 14.

@huynhtanloc2612
Copy link
Author

@rom1v
There is a minor bug which is that the screen does not turn on again after closing scrcpy tool (something like when using with the option --no-cleanup)

@rom1v
Copy link
Collaborator

rom1v commented Oct 12, 2024

Please post on #5730 about this (so that all issues related to the PR are at the same place).

Please indicate if you're mirroring the main display or a new display (and the exact command line you execute).

@huynhtanloc2612
Copy link
Author

Please post on #5730 about this (so that all issues related to the PR are at the same place).

Please indicate if you're mirroring the main display or a new display (and the exact command line you execute).

Got it. I posted on #5370 . Thanks

@rom1v
Copy link
Collaborator

rom1v commented Oct 12, 2024

@huynhtanloc2612

It works perfectly on my Galaxy S22 Ultra phones with Android 14.

Just to be sure, does #5370 fixes this specific issue (#4598), that is without using the --new-display feature?

@huynhtanloc2612
Copy link
Author

@huynhtanloc2612

It works perfectly on my Galaxy S22 Ultra phones with Android 14.

Just to be sure, does #5370 fixes this specific issue (#4598), that is without using the --new-display feature?

Yes, it fixed this issue as well. All left mouse and scroll... actions works like expected.
Command: scrcpy --display-id=<virtual-display-id>

@vaddisrinivas
Copy link

Please test #5370.

Thanks @rom1v It works perfectly on my Galaxy S22 Ultra phones with Android 14.

@huynhtanloc2612 - were you able to get SamsungDex working? whats the command you used?

@huynhtanloc2612
Copy link
Author

Please test #5370.

Thanks @rom1v It works perfectly on my Galaxy S22 Ultra phones with Android 14.

@huynhtanloc2612 - were you able to get SamsungDex working? whats the command you used?

@vaddisrinivas I have not tested DeX with this scrcpy version yet. However, AFAIK, DeX does not start with virtual display. It requires real external display to start.

@4nric
Copy link

4nric commented Oct 15, 2024

DeX does not start with virtual display

Agree with this. @vaddisrinivas you need to start DeX somehow, either through dummy HDMI (scrcpy need to connect wirelessly then), wireless DeX (to miracast device). or though DeX on PC. Only benefit of this compared to navigating from TV wirelessly or DeX on PC either wired or wireless, is that you get lesser latency. Cumbersome to setup in the end

rom1v added a commit that referenced this issue Oct 27, 2024
Mouse and touch events must be sent to the virtual display id (used for
mirroring), other events (like key events) must be sent to the original
display id.

Fixes #4598 <#4598>
Fixes #5137 <#5137>
PR #5370 <#5370>

Co-authored-by: nightmare <mengyanshou@gmail.com>
@rom1v rom1v closed this as completed in d193967 Nov 24, 2024
rom1v added a commit that referenced this issue Dec 5, 2024
When mirroring a secondary display, touch and scroll events must be sent
to the mirroring virtual display id (with coordinates relative to the
virtual display size), rather than to the original display (with
coordinates relative to the original display size).

This behavior, introduced by d193967,
was also applied for the main display for consistency.

However, this mechanism has been found to cause some UI elements to
become unclickable.

To minimize inconveniences, restore the previous behavior when mirroring
the main display: send all events to the original display id (0) with
coordinates relative to the original display size.

Fixes #5545 <#5545>
Fixes #5605 <#5605>
Refs #4598 <#4598>
Refs #5137 <#5137>
Refs #5370 <#5370>
rom1v added a commit that referenced this issue Dec 5, 2024
When mirroring a secondary display, touch and scroll events must be sent
to the mirroring virtual display id (with coordinates relative to the
virtual display size), rather than to the original display (with
coordinates relative to the original display size).

This behavior, introduced by d193967,
was also applied for the main display for consistency. However, it has
been found to cause some UI elements to become unclickable.

To minimize inconveniences, restore the previous behavior when mirroring
the main display: send all events to the original display id (0) with
coordinates relative to the original display size.

Fixes #5545 <#5545>
Fixes #5605 <#5605>
Refs #4598 <#4598>
Refs #5137 <#5137>
Refs #5370 <#5370>
rom1v added a commit that referenced this issue Dec 7, 2024
When mirroring a secondary display, touch and scroll events must be sent
to the mirroring virtual display id (with coordinates relative to the
virtual display size), rather than to the original display (with
coordinates relative to the original display size).

This behavior, introduced by d193967,
was also applied for the main display for consistency. However, it
causes some UI elements to become unclickable.

To minimize inconveniences, restore the previous behavior when mirroring
the main display: send all events to the original display id (0) with
coordinates relative to the original display size.

Fixes #5545 <#5545>
Fixes #5605 <#5605>
Fixes #5616 <#5616>
Refs #4598 <#4598>
Refs #5137 <#5137>
Refs #5370 <#5370>
PR #5614 <#5614>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants