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

Manipulate scaling percentage per resolution #69

Open
ody opened this issue Jun 6, 2024 · 9 comments
Open

Manipulate scaling percentage per resolution #69

ody opened this issue Jun 6, 2024 · 9 comments

Comments

@ody
Copy link

ody commented Jun 6, 2024

I often find myself wishing I could have Windows select a specific scaling factor based on resolution. When setting desktop resolution to 2560×1440 to play games sitting at my desk I prefer 100% but when I am connected via my Steam Deck at 2560x1600, I prefer 175% and 4k connected via my 55” TV, 200%.

Could you please add some mechanism for defining a resolution to scaling factor relationship?

@Nonary
Copy link
Owner

Nonary commented Jun 7, 2024

Unfortunately there isn’t a Windows API call I am aware about that allows adjusting the monitor DPI setting. The only one I’ve found was essentially a reverse engineered call. If you happen to know the proper API calls for it I can implement it, otherwise I’d suggest getting a dummy plug and having the dummy plug set at 200%

@ody
Copy link
Author

ody commented Jun 7, 2024

That is a bummer. The request was so I could manipulate the scaling factor of my dummy plug. When I mentioned being at my desktop I am streaming to my Mac. My Windows PC is a headless dedicated streaming machine. I’ll keep my eye out for a proper API

@CrazyCoder
Copy link

There is a fork that seems to adjust scaling: main...danielmartina:ResolutionAutomation-custom:main.

@ody
Copy link
Author

ody commented Jun 7, 2024

The parameter utilized, 0x009F is documented by Microsoft as “do not use”

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa

@ody
Copy link
Author

ody commented Jun 7, 2024

Also getting the vibe this is steps above recommended, which would mean I’d need a negative number at 1440p and that isn’t possible

@Nonary
Copy link
Owner

Nonary commented Jun 8, 2024

I tried that API call earlier and it completely broke my DPI scale dropdown. I couldn't pick a setting anymore and was forced to use custom scaling. Had to do a system restore to fix it again

@ody
Copy link
Author

ody commented Jun 8, 2024

I was poking around at this again this morning and thought maybe looking for an API which applies a scaling factor is incorrect.

If you run something like this...you get the virtual resolution of the desktop after the chosen scaling factor has been applied.

[System.Windows.Forms.Screen]::AllScreens

I wonder though if when you select the factor through Display Settings it isn't actually setting a percentage anywhere, it is just taking the desired frame buffer resolution, applying a reverse percentage (so 4k becomes 1920x1080 at 200%), then setting the virtual desktop size to that resolution. I saw a similar thing when working with Special-K, if it was made DPI aware it would report my resolution as a fraction of what I had set the actual display resolution to.

Looking more through what's available from user32.dll though, I couldn't find anything which obviously provided a way to set that virtual desktop resolution. I am new to Windows API stuff so maybe I am not seeing it or not looking in the right place...

@nooblikejagger
Copy link

I have the same need, looking forward to the update.

@vaughngx4
Copy link

vaughngx4 commented Oct 25, 2024

(edited to fix mistake in code)

I have a workaround for now. Using this executable, drop SetDPI.exe in the ResolutionMatcher folder and modify ResolutionMatcher.ps1.

After OnStreamStart I have:

if ($env:SUNSHINE_CLIENT_HEIGHT -gt 1079) {
    .\SetDPI.exe 125
}

After OnStreamEnd (both of them) I have:

.\SetDPI.exe 100

So that anything 1080p or higher will get a 125% scaling. You can adjust this to your liking.

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