-
-
Notifications
You must be signed in to change notification settings - Fork 674
"Hybrid ratio", new option on View menu for Hybrid screen layout #2332
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
base: master
Are you sure you want to change the base?
Conversation
|
Could add a custom mode for screen layout? Sometimes users want to display dual screen content side by side, but want the main screen to be as large as possible while maintaining integer scaling, and the secondary screen to use the remaining space while also maintaining integer scaling? In this way, the main screen can be set to 2816x2112 resolution (11x integer scaling), and the secondary screen can be set to 1024x768 (4x integer scaling) |
To do that, the user would need to set a value through the interface, and with that, the system would need to first apply a scale factor to the main screen, then use the remaining space to calculate and apply a different scale to the smaller screens. Directly setting scale factors for the screen is outside the scope of changes I made, as my focus was specifically on adjusting screen ratios. That said, it’s definitely an idea worth exploring in the future, but considering the current state of the interface, I'm not sure how to design where to put these scale factor values for the user to set. Perhaps an option in the same menu as the hybrid ratios, and then rename it to "Hybrid options". |
|
I actually skipped explaining how the screen gap value influences the hybrid view screen ratio, so since there as a comment here about tweaks regarding a ratio for 4K displays, I’ll take the opportunity to clarify that now. That said, keep in mind that this approach is just an easy solution that reuses an existing feature with a new presentation — it’s not that flexible when it comes to customizing even further the screen scaling. Further tweaking requires modifying other parts of melonDS, mainly regarding how the screen alignment works in hybrid layout. I highly recommend going over these kind of solutions instead of tweaking on this, my objective on this PR was to keep it as simple as possible. Mathematical explanationThe gap calculation for full integer scaling only works with values of the domain I've defined on the PR text, which are the values based in 192, the height of a single DS screen at 1x. In other words, only the multiples and divisors of 192. The reason for that is noticeable when you check a 1x window size after setting the screen gap: it introduces the gap of the size from input between the smaller screens, and then scales the main screen to fit the borders in a 4:3 ratio, as I've explained on the Problem section. Every scale from now on relies on what is done for the final window size we want as a result. To demonstrate that, lets take for example 7:3, which is the hybrid ratio that has a supported screen gap on the menu of the latest stable build, a screen gap of 64 px. Calculation:
This is exactly what happens in the latest stable build when you select a 64px screen gap and switch to hybrid mode with a window size of 1x. But that's not integer-scaled, so we have to do another step. Ensuring Integer ScalingTo achieve proper integer scaling, the screen gap itself must also scale proportionally. The final size of the gap must be an multiple of 192 — exactly enough to fit at least an entire 1x DS screen between the smaller screens without any gap. Continuing the 7:3 example:
With this, the main screen is scaled while maintaining a 4:3 ratio to match a height of 1344px, giving us a size of 1792x1344 and resulting in a 7:3 hybrid ratio with a final window size of |
|
After testing it for a while, I found this feature to be great. Could you port the ratio to 2-screen-emphasize? Currently, if use 2-screen-emphasize, the ratio of the two windows cannot be controlled. |
Is |




Objective
Adjust how the window works in hybrid screen layout to allow larger screen sizes for the main screen by creating a "Hybrid ratio" setting menu by extending the "Screen gap" setting, and to always display at a pixel-perfect integer scale when the "Force integer scaling" option, located in the "Screen sizing" menu, is enabled.
Disclaimer
I will refer to the DS top screen as screen 1, the DS bottom screen as screen 2, and the larger screen in hybrid layout as the main screen. This naming convention is used consistently throughout this explanation.
I will not cover behavior when "Force integer scaling" is disabled. I also will not consider a possible future implementation of flipped hybrid layout, as discussed in PR #1705; whoever implements that should simply mirror how the current hybrid layout works.
As reference, I reviewed how other emulators handle hybrid layout configurations. The libretro port of melonDS, melonDS DS, has a similar setting, but its screen gap only works in vertical mode. Since standalone melonDS offers more flexible hybrid layout options, I won't base this proposal on melonDS DS implementation — although it would be great to bring this to that version as well in the future.
Similarly, Bizhawk’s melonDS core has flexibility comparable to standalone melonDS, but for some reason its screen gap setting distorts the main screen, producing uneven pixels even at what should be a pixel-perfect aspect ratio. I’m not sure why, but since the Bizhawk core doesn’t run well on my machine (at least in the official release build), I’ve chosen to disregard it for now.
Lastly, some feature requests suggest increasing the hybrid layout screen ratio without using screen gaps, centering the smaller screens beside the main screen. That would require additional frontend positioning changes, and is outside the scope of this proposal. However, this PR is a step toward enabling that functionality in the future.
Problem
Currently, hybrid layout defaults to a 2:1 ratio, where the main screen is twice the size of screens 1 and 2. These two smaller screens are positioned to the right of the main screen in vertical layout.
However, melonDS uses a unified window system. So, a 1x hybrid layout window is treated as a single 768×384 surface — equivalent to a 3:2 ratio in DS screen units.
When the "Screen gap" setting is increased, a gap is introduced between screens 1 and 2, and the main screen is scaled to align:
while preserving its 4:3 aspect ratio.
This causes the overall screen height to grow by the gap value. Because of the unified window system, this also increases the width, stretching the main screen and breaking integer scaling.
When "Force integer scaling" is enabled, screens 1 and 2 correctly retain integer scaling. However, the main screen is scaled according to the fixed 4:3 aspect ratio and the screen gap, which causes it to render at non-integer scale values in the current implementation — even with integer scaling enabled.
Solution
I propose removing the influence of the screen gap setting while in hybrid layout and adding a hybrid ratio setting. This new configuration would appear as a selectable list of screen ratios and can be implemented by cloning the existing "Screen gap" setting, while internally mapping each option to a predefined gap value based on DS screen units (192 pixels tall at 1x).
Specifically:
Proposed ratio options:
You can test these options right now in the current build. After running the emulator once, open your
melonDS.tomlfile (located in the exe folder) and manually set theScreenGapvalue under the[Instance.Window]section. The value will be used regardless of what is displayed in the UI.Since it's just a modification in the front end, I’ve only edited the code related to the emulator window. The emulator now includes a new menu under View → Hybrid ratio, directly below the Screen gap menu. As mentioned earlier, these values override the Screen gap setting only when the Screen layout is set to Hybrid.
Note: Due to hardware limitations (I only have a 1080p display), I could not fully test the 6:1, 7:1, 7:3, and 9:4 options on my system.