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

Invert the internal/external monitor when switching #19

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kayakyakr
Copy link

@kayakyakr kayakyakr commented Mar 27, 2023

This should be operational but I'm having a couple of issues with it:

  • Invert Monitor setting gets rewritten on load. It saves to the registry but resets to 0 on launch.
  • Unfortunately, the scaling of the second monitor does not fill the phone without toggling scaling mode within nvidia control panel. This is the same issue I have when updating monitor settings manually on connect, but is not an issue when using NVStreamer1080 in resolution change mode.

The first is my unfamiliarity with C# maybe? I'm missing something somewhere.

The second may be a "lucky" side effect with standard mode. Otherwise, even when I set resolution before connecting, Moonlight does not actually ever full screen.

I believe this is the "new" API here: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdisplayconfig. There's a very interesting "mode" this can be used in that allows a temporary (non-persisted) display setting. That means, if your desktop crashes while streaming moonlight, it will restart with the new settings. Could be an upgrade.

@kayakyakr
Copy link
Author

Here's someone doing the ChangeDisplay.exe thing using dll's: https://stackoverflow.com/questions/16326932/how-to-set-primary-monitor-for-windows-7-in-c-sharp

…tDisplayConfig AND the ChangeDisplay, succeed
@kayakyakr
Copy link
Author

OK, so update: this kinda got away from me a little bit. What turned into a small feature became a full redesign. Now, in settings, you select the monitor that you want to stream to and the size you'd like. App will update the topology to have the monitor you want to use as primary and will set the resolution accordingly.

Tested using my fold 4 on:

  • physical monitor (1920x1200) streaming at 1440x1200.
  • HDMI dummy (4k) streaming at native 2176x1812.

I found that SetDisplayConfig was a fantastic way to set the topology of monitors. This doesn't have any flash, it just sets the selected monitor on and any others off. The benefit is that this will allow you to have multiple monitors in extend mode and on connect will switch to one of those or even a 3rd disconnected or dummy monitor. On disconnect, it restores whatever it was that you started with. The restoration code needs a bit more love. You would think that parroting the modes they send when you fetch data back would be enough for windows, but nooooo, it really doesn't like it.

I did manage to get it to also change the resolution, but I was desperately requesting it stretch the frame and just couldn't make it happen like the original set resolution functions do. I don't know if it's worth digging into. The benefit of using SetDisplayConfig to change the resolution is that you can do it in a temp mode and one-line reset it on disconnect. It also hardens the app to crashes as on reboot the system will pick back up the old config. Unfortunately, changing topology forces persistence anyway, so it doesn't much matter.

Added an old CCD C# wrapper because it defined all the structs so I didn't have to.

Using this build locally. LMK what you think.

SunshinePath=InSunshinePath.Text;
SunshineInit();
}
}
Copy link
Author

@kayakyakr kayakyakr Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS 2017 decided to update the line endings. That's annoying. Makes the rest of the diff worthless.

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

Successfully merging this pull request may close these issues.

1 participant