Skip to content

android: Implement secondary screen support #617

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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

DavidRGriswold
Copy link
Collaborator

@DavidRGriswold DavidRGriswold commented Mar 3, 2025

Enable support for a second screen on android, either through a physical connection or using screen mirroring through Chromecast or Miracast.

What Currently Works

  • A "Secondary Screen Layout" option has been added to the Settings menu on Android where user can choose between (1) System Default (mirroring) (2) Top Screen Only (3) Bottom Screen Only (4) Side by Side.
  • A secondary window is always enabled at emulation start - either on an invisible virtual display or a physical display if it exists. If the setting is "System Default (mirroring)" the virtual display is used instead
  • It is possible to switch back and forth between the virtual display and physical display using the settings above

Issues and changes yet to be done

  • Test test test

Addresses #351

@rtiangha
Copy link
Collaborator

rtiangha commented Mar 3, 2025

I'd be interested in seeing what the lag might be while casting. Might not matter much if the second screen is mostly static or not used often.

@DavidRGriswold
Copy link
Collaborator Author

I'd be interested in seeing what the lag might be while casting. Might not matter much if the second screen is mostly static or not used often.

The issue is that the most clear use-case involves casting the top screen while keeping the bottom touchscreen on the phone so touch input works as normal. So it would usually be the more active screen getting cast. It works pretty okay in my wifi environment - I wouldn't want to play, like, shovel knight on it, but it's okay for link between worlds type stuff where a little lag is unlikely to result in death.

that said, I think the most likely long-term use for this will be a two-screen android handheld, if such a thing ever comes to be. The DNA Duo on an Ayn Odin 2 basically makes one, but I expect a retroid pocket flip 3 with a smaller bottom screen between the controller parts in a few years.

@OpenSauce04 OpenSauce04 added the enhancement New feature or request label Mar 4, 2025
@OpenSauce04 OpenSauce04 added the squash This pull request should be squashed if approved label Mar 18, 2025
@DavidRGriswold DavidRGriswold marked this pull request as ready for review March 19, 2025 16:32
@DavidRGriswold
Copy link
Collaborator Author

I am pretty sure this is ready for review or at least significant additional testing.

I have tested with vulkan pretty extensively - i have had a couple of crashes here and there but they are not consistently reproducible and I'm not even certain they can be linked to this code. That said there are almost certainly things that can be improved in the programming flow.

@OpenSauce04 OpenSauce04 added this to the 2123 milestone Mar 19, 2025
@DroidlyMobile

This comment was marked as spam.

@OpenSauce04 OpenSauce04 modified the milestones: 2123, 2122 Mar 19, 2025
@OpenSauce04 OpenSauce04 changed the title Second screen android support android: Implement secondary screen support Jun 3, 2025
@OpenSauce04 OpenSauce04 modified the milestones: 2122, 2123 Jun 7, 2025
@pull-request-size pull-request-size bot added size/L and removed size/XL labels Jun 9, 2025
@GH-Fox
Copy link

GH-Fox commented Jun 17, 2025

Feedback from testing. Both environments were cleaned up to remove settings from previous apps.

1) Android 15, OnePlus 13 (Snap 8 Elite)

  • Managed to get secondary screen working on multiple displays, and XR glasses. Played for a few hours at 3x resolution with no bugs whatsoever.
  • Works properly both on normal and (forced) desktop modes.
  • Worth noting that the second screen doesn't immediately show up when disconnecting then reconnecting a screen while a game is running. Probably a minor issue, and going to home or switching apps forces the screen to display again when going back to Azahar

2) Android 13, Ayn Odin 2 (Snap 8 Gen 2)

  • Couldn't get the second screen to display. Content is only mirrored.
  • Tried on normal and desktop modes without success
  • Drastic working properly as a comparison

3) Additional feedback

  • While niche, for use with XR glasses (or any other display that supports side by side), an option to only enable stereoscopy for only one of the two screens would be welcomed. Currently, the bottom screen is also displayed twice, which is not ideal and probably consume unnecessary ressources.

Thanks for the hard work on this PR !

@DavidRGriswold
Copy link
Collaborator Author

Feedback from testing. Both environments were cleaned up to remove settings from previous apps.

1) Android 15, OnePlus 13 (Snap 8 Elite)

  • Managed to get secondary screen working on multiple displays, and XR glasses. Played for a few hours at 3x resolution with no bugs whatsoever.
  • Works properly both on normal and (forced) desktop modes.
  • Worth noting that the second screen doesn't immediately show up when disconnecting then reconnecting a screen while a game is running. Probably a minor issue, and going to home or switching apps forces the screen to display again when going back to Azahar

2) Android 13, Ayn Odin 2 (Snap 8 Gen 2)

  • Couldn't get the second screen to display. Content is only mirrored.
  • Tried on normal and desktop modes without success
  • Drastic working properly as a comparison

3) Additional feedback

  • While niche, for use with XR glasses (or any other display that supports side by side), an option to only enable stereoscopy for only one of the two screens would be welcomed. Currently, the bottom screen is also displayed twice, which is not ideal and probably consume unnecessary ressources.

Thanks for the hard work on this PR !

Not working on an Odin is a bummer. I wish I had one for debugging.

@DavidRGriswold
Copy link
Collaborator Author

@GH-Fox could you see if MelonDS two-screen mode works on the odin 2? This is open source, unlike drastic, so if it works and we don't, I could at least look at their code to try to understand why...

@DroidlyMobile
Copy link

DroidlyMobile commented Jun 19, 2025 via email

@DroidlyMobile
Copy link

Feedback from testing. Both environments were cleaned up to remove settings from previous apps.

1) Android 15, OnePlus 13 (Snap 8 Elite)

  • Managed to get secondary screen working on multiple displays, and XR glasses. Played for a few hours at 3x resolution with no bugs whatsoever.
  • Works properly both on normal and (forced) desktop modes.
  • Worth noting that the second screen doesn't immediately show up when disconnecting then reconnecting a screen while a game is running. Probably a minor issue, and going to home or switching apps forces the screen to display again when going back to Azahar

2) Android 13, Ayn Odin 2 (Snap 8 Gen 2)

  • Couldn't get the second screen to display. Content is only mirrored.
  • Tried on normal and desktop modes without success
  • Drastic working properly as a comparison

3) Additional feedback

  • While niche, for use with XR glasses (or any other display that supports side by side), an option to only enable stereoscopy for only one of the two screens would be welcomed. Currently, the bottom screen is also displayed twice, which is not ideal and probably consume unnecessary ressources.

Thanks for the hard work on this PR !

Not working on an Odin is a bummer. I wish I had one for debugging.

The Odin 2 works fine for me, not sure why it isn't working for others but I tested the Odin 2 with your latest build of Azahar and it works fantastic.

@GH-Fox
Copy link

GH-Fox commented Jun 19, 2025

I tested this specific build of MelonDS quickly, and couldn't get anything but mirrored projection as well. I'm less familiar with the settings for this one, so I'll do more testing tomorrow.

@DroidlyMobile: I have an Odin 2 Max. Could it be that you have a different model ? For instance, I know that the OS on the Odin 2 Portal is slightly different. If that's the case, then that would help me ruling out 1 of the 3 potential reasons why it's not working on my end.

Additional "bug" that I found today on my phone: in Desktop mode, the navbar at the bottom is overlapping with the projected screen by a few pixels. This does not happen in normal mode.

@DavidRGriswold
Copy link
Collaborator Author

I will be honest, I don't even know what Desktop Mode is. I use Samsung phones which have Dex which must be disabled for the apps to detect the second screen correctly.

@DavidRGriswold
Copy link
Collaborator Author

Does Drastic require you to give permission to record the screen when you use it? That could imply they are using a different API than what this and MelonDS are using.

@DroidlyMobile
Copy link

DroidlyMobile commented Jun 19, 2025 via email

@jpdreamer
Copy link

Melonds dual screen fork apparently added doco on how it implements it's code, not sure if that helps
https://github.com/SapphireRhodonite/melonDS-android/releases/tag/0.0.4

@GH-Fox
Copy link

GH-Fox commented Jul 1, 2025

Unfortunately, I still can't get this PR to work on Odin 2 Max (firmware 1.0.0.355) other than in mirror mode.

I've been running other apps for comparison testing:

  • Drastic (r2.6.0.4a build 109) working out of the box
  • Citra MMJ (20250221) works with the following settings: Layout: Single, Screen Cast: Single Screen
  • MelonDS dual screen fork (tested from v0.0.2 to 0.0.4) is not working and only shows mirrored content

My objective is to identify why this PR of Azahar is only displaying mirrored content on my end, while it seems that others had more success. Could be a setting at OS level that I messed up, in which case I'd like to find the culprit in case this also happens to other users once merged. Although I'll only be 100% convinced if someone confirms they got it to work on an Odin 2 Base/Pro/Max (not a portal, not a mini).

Hope this helps

@GH-Fox
Copy link

GH-Fox commented Jul 2, 2025

Seems like MelonDS dual screen fork v0.0.5 is fixing the issue on Odin 2. Hopefully that will also apply to Azahar.

@DavidRGriswold
Copy link
Collaborator Author

I think I understand the bug they describe and will attempt to add something similar to this code either today or tomorrow. Thanks for your help!

@DavidRGriswold
Copy link
Collaborator Author

@GH-Fox i just pushed the odin 2 bugfix, I think, and a new build is going through CI now. It should hopefully be built soon, if you could test it sometime in the next day or two that would be great!

@DavidRGriswold DavidRGriswold force-pushed the secondscreen branch 2 times, most recently from 8a733b4 to f14675a Compare July 3, 2025 12:11
@GH-Fox
Copy link

GH-Fox commented Jul 3, 2025

Confirming that the new version fixes the issue on odin 2 Max. I can now fully enjoy a dual screen experience.

The last missing piece for a perfect 3D experience with XR glasses will be this option to turn on side by side on only one of the 2 monitors.

Thanks for the hard work ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/L squash This pull request should be squashed if approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants