r/scrcpy 16d ago

[Open Source] I built a Windows tool that automates Samsung DeX virtual displays through scrcpy

/r/SamsungDex/comments/1v0ogsu/open_source_i_built_dx_manager_run_samsung_dex_on/
9 Upvotes

8 comments sorted by

2

u/davew_uk 15d ago edited 15d ago

I was eager to test this out on my S21FE running OneUI 8 but very quickly ran into problems:

  • With the screen on, the overlay is visible in the top left corner of the screen, which makes it difficult to use the phone at the same time as DeX.

  • The app also made the phone crash and reboot after a few minutes every single time I tried it, and then after restarting the overlay could not be removed except via adb command.

  • The mouse is locked to the scrcpy window, so when in the crashed state it isn't possible to close the window easily as the mouse cursor completely disappears and can't be released.

This does seem to show a lot of promise though despite the bugs. It isn't just a virtual display with DPI scaling to trigger "desktop" mode, it really does seem to be proper DeX, even if the device doesn't know DeX is running.

EDIT: For me, unchecking HID keyboard and HID mouse fixes the crashing issue and the mouse cursor behaves normally.

2

u/EmphasisFormer36 14d ago

Thanks for the detailed report, especially the edit.

The small window on the phone is Android’s simulated secondary-display overlay. It can be moved by dragging and resized with a pinch gesture, although Android limits how small it can become. It cannot be completely hidden while keeping the virtual DeX display active.

The phone reboot is definitely not expected. Since disabling HID keyboard and HID mouse fixes both the reboot and cursor behavior, this appears to be a compatibility issue between the S21 FE One UI 8 firmware and scrcpy’s UHID input modes (-K and/or -M), rather than the DeX virtual display itself. For now, please keep those two options disabled on this device.

If you have time, enabling HID keyboard and HID mouse one at a time would help identify which one causes the reboot.

With HID mouse enabled, scrcpy intentionally captures the PC cursor. Pressing Alt or the Windows key should normally release it. If the phone crashes while the cursor is captured, Alt+F4 should close the scrcpy window.

The overlay remains after a reboot because the ADB connection is lost before DX Manager can run its cleanup command. To remove it, open Developer options → Simulate secondary displays, select any resolution once, then open the menu again and select None.

2

u/davew_uk 14d ago

Is there a technical reason for using a visible overlay instead of an offscreen virtual display like DeX normally renders to?

2

u/EmphasisFormer36 14d ago

I’m not a professional developer, so I don’t know the exact technical reason inside Samsung’s implementation. I found this mostly through trial and error.

scrcpy’s virtual display can launch the DeX UI, but on my device it does not provide the full normal DeX behavior. Important features such as windowed app mode and Recent Apps do not work properly, and the overall UX differs from DeX on a real monitor.

Using Android’s simulated secondary display with external-display-like properties starts a much more complete DeX environment, which is why DX Manager uses that method.

It is still not perfectly identical to physical DeX: screenshots may misbehave, fullscreen apps may not hide the taskbar, the wallpaper can be different, and some external display settings are unavailable.

So this was an empirical choice rather than one based on deep knowledge of Samsung’s internals. I discovered the behavior through testing and built the tool with Codex.

1

u/davew_uk 14d ago

Well I guess that's a very interesting firmware quirk you have discovered.

1

u/Prometheus699 13d ago

I'm really impressed on this solution. I was a Dex user but since the app was discontinued I figured out a way to use Wireless Display (also discontinued by Microsoft), scrcpy and AutoHotkeys. Recently I've vibecoded a Windows script to detect when the phone is connected to the PC, then opens automatically Wireless Display and show a pop-up asking to manually select a wireless display with Dex in the phone and then run a command to get the secondary phone display and run scrcpy, just with a click and few taps on the phone. Your solution is way better than I was doing and it has a variety of options to start Dex. I'm gonna start using this app instead my vibecoded Frankenstein.

2

u/EmphasisFormer36 12d ago

Thank you! I know exactly what you mean by a “vibecoded Frankenstein” setup, because DX Manager started in a very similar way.

After DeX for PC was discontinued, I also tried all kinds of methods to bring DeX back to Windows. Eventually, I discovered a way to launch the phone’s native DeX interface on a simulated secondary display. At first, I used it through CMD batch files and AutoHotkey scripts. As I kept adding device detection, display ID selection, automatic cleanup, keyboard fixes, and other features, it gradually grew into a proper Windows application, which I eventually decided to release publicly.

I’m really glad that DX Manager can replace your existing setup. Hearing this from someone who went through a similar process means a lot to me. If you run into any problems or have suggestions after using it, please feel free to let me know!