scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

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

Open huynhtanloc2612 opened this issue 1 year ago • 22 comments

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 https://github.com/Genymobile/scrcpy/issues/1887#issuecomment-1775028321 and https://github.com/Genymobile/scrcpy/issues/1887#issuecomment-1847235527, 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 avatar Jan 19 '24 04:01 huynhtanloc2612

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 avatar Feb 03 '24 17:02 astroskyoffical

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

astroskyoffical avatar Feb 03 '24 17:02 astroskyoffical

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 avatar Feb 04 '24 00:02 huynhtanloc2612

Hi @rom1v , I am trying to find the way to fix above issue. Does below line determine which display all input events go to? https://github.com/Genymobile/scrcpy/blob/79968a0ae63179c39d5f1d4f4d97da020c9e07dd/server/src/main/java/com/genymobile/scrcpy/wrappers/InputManager.java#L75

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.

huynhtanloc2612 avatar Mar 20 '24 18:03 huynhtanloc2612

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)

rom1v avatar Mar 20 '24 20:03 rom1v

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 avatar Mar 21 '24 01:03 huynhtanloc2612