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

Add support for UWP and the Xbox platforms #11339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SirMangler
Copy link
Contributor

I'm incredibly excited to present this PR to introduce basic support for UWP. The current devices tested under UWP include:

  • Xbox Series S/X
  • Xbox One (X)

Currently the UWP frontend is basic, including a file picker to select games and a 'protocol' for frontends to use to launch Dolphin, including Retropass. The 'Dolphin Emulator' settings folder is stored inside LocalState in the app folders.

Changes to the overall solution include the addition of the new configurations Release UWP and Debug UWP. These exist so that we may define our own macro for UWP, as the existing ones offered by Microsoft do not allow us to easily differentiate between Xbox and Win10, and larger changes to the project would be required to account for the specific device being used on a 'windows platform'.

The differentiation is necessary to disable DInput, OpenGL and Vulkan, as well as to disable the use of Win32 handles (such as in the lib usb code).

Demonstration (Courtesy of @ReveriePass, who was an instrumental help to this project):
https://www.youtube.com/watch?v=80ko2clLz2M

Source/Core/Core/HW/GCPadEmu.cpp Show resolved Hide resolved
Source/Core/DolphinUWP/App.cpp Show resolved Hide resolved
Source/Core/DolphinUWP/App.cpp Show resolved Hide resolved
@SirMangler SirMangler force-pushed the uwp-pr branch 3 times, most recently from 62f6822 to e4c6b25 Compare December 10, 2022 22:56
Source/Core/VideoCommon/VideoBackendBase.cpp Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VideoBackendBase.cpp Outdated Show resolved Hide resolved
Source/Core/InputCommon/GCAdapter.cpp Outdated Show resolved Hide resolved
Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

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

Can you remove packages.config when theres nothing inside?

Also, the project file noise seems "meh". Not sure if collapsing those auto-generated project configurations into more terse and localized versions is something you can (or want to) do though.

Source/Core/Common/WindowSystemInfo.h Outdated Show resolved Hide resolved
Source/Core/DolphinLib.vcxproj Outdated Show resolved Hide resolved
@lioncash
Copy link
Member

Cool stuff! Is there going to be CI hooked up for these build paths? If not, then I'm hesitant to merge this further down the line, since there's nothing preventing the build types from breaking in the future.

@mediaexplorer74
Copy link

mediaexplorer74 commented Dec 12, 2022

I'm incredibly excited to present this PR to introduce basic support for UWP. The current devices tested under UWP include:
...
Changes to the overall solution include the addition of the new configurations Release UWP and Debug UWP. These exist so that we may define our own macro for UWP, as the existing ones offered by Microsoft do not allow us to easily differentiate between Xbox and Win10, and larger changes to the project would be required to account for the specific device being used on a 'windows platform'.

Cool stuff, indeed! Thank you :)
Ohhh... I can't use VS 2017 for your commit's building. The problem is SDL-UWP project (No "Debug UWP|x64", "Debug UWP|ARM64", etc.). I tried to recover (fix) this project file by manual creating (adding) configurations Release UWP and Debug UWP (both x64 and ARM64), but something went wrong (I catch message "Configuration dublicated") .

@mediaexplorer74
Copy link

mediaexplorer74 commented Dec 12, 2022

Demonstration (Courtesy of @ReveriePass, who was an instrumental help to this project): https://www.youtube.com/watch?v=80ko2clLz2M"

@SirMangler and @ReveriePass, how you "linked" SDL2 (uwp edition) to DolphinUWP "executable"? SDL-UWP configured to generate dll, not .lib, yea? On compiling via latest VS 2022 Preview, DolphinUWP tried to link .lib, but linker generates error LINK : sdl2-uwp.lib not found...
And what about linking openal32.lib? I scanned all solution and did not find this lib file or project...
I found only include-files at Externals/OpenAL folder.

@shuffle2
Copy link
Contributor

shuffle2 commented Dec 12, 2022

Please take a look at the existing msbuild code and make your PR adapt what's already there instead. >90% of these changes (to msbuild files at least) are not needed.
specifically the changes to add to ProjectConfigurations can be removed and replaced by adding the new ones to https://github.com/dolphin-emu/dolphin/blob/master/Source/VSProps/Base.Targets.props

@@ -0,0 +1,347 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

please rewrite this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cleaned out some of the VS-generated mess. I would appreciate some more direction if you think it's needed.

{D79392F7-06D6-4B4B-A39F-4D587C215D3A} = {D79392F7-06D6-4B4B-A39F-4D587C215D3A}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-UWP", "..\Externals\SDL\SDL\VisualC-WinRT\SDL-UWP.vcxproj", "{89E9B32E-A86A-47C3-A948-D2B1622925CE}"
Copy link
Contributor

@shuffle2 shuffle2 Dec 12, 2022

Choose a reason for hiding this comment

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

you should probably use our existing vcxproj (+related) and not this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the use of the SDL-UWP project or something else? We do need the UWP specific project or we will run into runtime errors (as you might expect).

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean that we should use Dolphin's existing vcxproj for SDL and just add some stuff to it as needed for UWP build (I imagine it's just setting some preprocessor macros or so?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took a look into this, unfortunately it's not as simple as just setting a macro and changing the project type to Windows Store/UWP. There's a bunch of WinRT specific files that need including, some of which conflict with existing non-WinRT files, likely part of why SDL made this seperate in the first place. It's a bit of a mess to sort out and do this cleanly.

m_buttons->SetControlExpression(2, "`C`"); // X
m_buttons->SetControlExpression(3, "`S`"); // Y
m_buttons->SetControlExpression(4, "`D`"); // Z
#if _UWP
Copy link
Contributor

@shuffle2 shuffle2 Dec 12, 2022

Choose a reason for hiding this comment

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

Is there a way to make this a runtime check? Maybe detect if the pad is xbox? (it seems useful even on non-xbox console / non-uwp). Or just detect if on xbox.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can check at runtime if this is an Xbox device, though this might not be needed. All UWP supported Xbox models see the controller as 'Xbox One Game Controller', regardless of if the app is running on a Series S/X or One (X).

@shuffle2
Copy link
Contributor

Another functionality that should probably be cut out for Xbox build is Dolphin's Updater.

@mediaexplorer74
Copy link

Another functionality that should probably be cut out for Xbox build is Dolphin's Updater.

UWP apps cannot autoupdate? Very interesting to know.. thank you

@mbc07
Copy link
Member

mbc07 commented Dec 12, 2022

UWP apps cannot autoupdate?

They can, but the process is entirely handled by the Microsoft Store. No need for the app to implement an auto-updater of its own (like our Win32/macOS versions)...

@mediaexplorer74
Copy link

mediaexplorer74 commented Dec 12, 2022

UWP apps cannot autoupdate?

They can, but the process is entirely handled by the Microsoft Store. No need for the app to implement an auto-updater of its own (like our Win32/macOS versions)...

Wow... i forgot about MSStore-side deals ) Thank you very much for smart advice. Nice to know something new about this meshanism.
Sorry for disturbing you and Dolphin engeneers. You are great men

@SirMangler SirMangler force-pushed the uwp-pr branch 2 times, most recently from 4d1a66b to 3d6b0f6 Compare December 21, 2022 22:41
@shuffle2
Copy link
Contributor

I'm working on some changes and will post it here once done.

@shuffle2
Copy link
Contributor

@SirMangler have you tried just packaging the app as msix and setting TargetDeviceFamily to Windows.Xbox?

See https://github.com/shuffle2/dolphin/commit/9df158c2d95f6edf2c446ea7407baa7e9480b4d7

Maybe it Just Works? I don't have an xbox to test.

I'm still working on cleaning up this PR as-is...

@shuffle2
Copy link
Contributor

shuffle2 commented Dec 22, 2022

@SirMangler ok I made a commit on top of this PR here: [EDIT: see later comments]

Currently it requires a patch libsdl-org/SDL#6866 to SDL to fix some warnings. In general, SDL is using C++/CX instead of C++/WinRT which is why it's so painful. I got it working as a static lib (well, at least it compiled).
EDIT: this patch has been merged, but I think we should hold off on updating the SDL submodule for now, since they are in the middle of moving to SDL3. I've updated the above commit to workaround the issue in a different way.

It takes care of all my concerns except for the signing stuff. I just haven't gotten to it yet (and I don't really have a way to test).

@shuffle2
Copy link
Contributor

btw, it is also possible to create a new Platform instead of using Configuration for this.
https://learn.microsoft.com/en-us/visualstudio/extensibility/visual-cpp-project-extensibility?view=vs-2022

for example, you can see how GDK adds Platforms (extract the VS2022PCEditionFilesV143.vsix file).

The annoying thing from Dolphin's point of view is that this typically requires adding files to the VS install directory, something we don't want to require. However, it is possible to set DisableInstalledVCTargetsUse and VCTargetsPath17 to change the path searched for Platform files. This is what DirectXTK12 does after copying the files

This would be nicer than overloading Configuration, but it adds a decent amount of cruft for a really tiny use case...

@shuffle2
Copy link
Contributor

shuffle2 commented Dec 27, 2022

I revised the PR here: https://github.com/shuffle2/dolphin/commit/2c3276ef27c081b6a6d5b91de9a57b98e27d038c
I think that's now ready for testing on xbox / review / merging.
Compared to previous iterations, I did some more cleanup, put a (test) cert in the repo, and disabled SDL (it appears you're using dolphin's native WGInput anyway, and I'd rather just avoid SDL for as long as possible here).

Notably the UWP builds generate this warning:

Package.appxmanifest(64,4): warning APPX0006: This project uses the 'runFullTrust' capability. You should use the Windows Application Packaging Project to produce the store and sideload packages. See https://go.microsoft.com/fwlink/?linkid=871803 for more information. [c:\src\dolphin\Source\Core\DolphinUWP\DolphinUWP.vcxproj]

...which I think would be resolved if you used something like the msix packaging I linked earlier. But it's not super important to solve at the moment (as long as it actually runs on xbox).

edit: thinking about this again, it would be much better to just not add any project configurations for the uwp/xbox target, and instead modify the code to fully differentiate at runtime. The only thing that actually needs to specifically target xbox is the main app project. This also prevents needing to build the entire solution twice, even though 99% of the code+options are identical. All the current instances of #ifdefs should be easy to replace, the annoying part will be dealing with disabling the dependencies dynamically (in a way which still works on xbox).

@shuffle2
Copy link
Contributor

For future reference: the enums returned by RtlGetDeviceFamilyInfoEnum seem like a good native way to detect if on xbox (don't know if there's a good UWP api for this - maybe).

@Shadowdragon2023
Copy link

Shadowdragon2023 commented Jan 26, 2023

Another functionality that should probably be cut out for Xbox build is Dolphin's Updater.

UWP apps cannot autoupdate?

They can, but the process is entirely handled by the Microsoft Store. No need for the app to implement an auto-updater of its own (like our Win32/macOS versions)...

That only applies to apps being provided through the retail store. Microsoft will never permit this to be there (just like every other emulator ever made) and the only use that the Dophin Dev team would likely officially support is Developer mode. I think it'd be better to follow RA's example with the built-in core updater and use Dolphin's update system if possible.

@mbc07
Copy link
Member

mbc07 commented Jan 26, 2023

UWP packaged apps can't overwrite themselves, so the existing updater would need a refactor. This probably is outside the scope of this PR too, as the focus now is bringing initial UWP support...

@Saladassv5
Copy link

Sorry to sound like an idiot but ive come trying to download dolphin on my xbox but have absolutely no idea what anything in the past 3 places ive looked means😂. Where do I go to download dolphin on xbox cause in that youtube link, the dolphin app was already installed?

@rsgnz
Copy link
Contributor

rsgnz commented Feb 18, 2023

Sorry to sound like an idiot but ive come trying to download dolphin on my xbox but have absolutely no idea what anything in the past 3 places ive looked meansjoy. Where do I go to download dolphin on xbox cause in that youtube link, the dolphin app was already installed?

@Saladassv5

https://github.com/SirMangler/dolphin/releases

@UltraHDR
Copy link
Contributor

Are there any plans to merge this? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.