XBox One... kinda ;)

SLotman

Active Member
Joined
Jul 3, 2017
So, I've been thinking on a XBox One target for quite a while, specially since the WP8 target is *so* similar to the examples that exists on the devkit.

Never got to do it. But last night a light bulb turned on over my head ^_^

What about UWP, specially HTML5 UWP?

All I can say is YES, it works. I build a minimal UWP html5 app on VS2015 (an empty one), copied the index.html of my game, the main.js and all the data... and presto, I had my game running on XOne!

I had more trouble making VS2015 to upload the game to XOne than to building the game itself. So, ladies and gentlemen - if your game can run on HTML5, it can easily be ported to XBox one.

I don't know how to setup everything so monkey can auto-generate all the stuff, even compiling and uploading it to the Xbox (I don't think its even possible to upload it without opening the code on VS), but it is dead easy to make an UWP target this way :)

Right now my Xone is updating (grrr...) maybe tonight I'll upload a video of my game running.

And sorry if I'm rambling - its 8 AM and I've been up all night with this :D

Here's a small picture I took with my phone:
upload.jpg
 

SLotman

Active Member
Joined
Jul 3, 2017
ARG! I'm in update hell.

Apparently after updating my XOne, now if I ever want to upload anything to it, I must also update Visual Studio *and* the Windows SDK.

So far I can't upload my game again, keep getting errors when trying to connect to it :(
 

SLotman

Active Member
Joined
Jul 3, 2017
So far I'm stuck. I've upgraded to VS2017 and installed the latest Win10 SDK, but I can't upload anything anymore to the console :(

I'm trying to download and install the latest XDK to see if that fixes anything. If not... I'm stuck. I keep getting "DEP0100: Please ensure that target device has developer mode enabled." on deployment :(
 

SLotman

Active Member
Joined
Jul 3, 2017
Contacted Microsoft and I'm waiting for a reply from them - at first they think my devkit could have been disabled, since I never actually published anything :(

In another not so great news, I tried even VS2019 - took ages to install just for me to find out it doesn't support UWP + JS applications - so even if this works (it should), you'll need to have VS2015 or 2017 installed.
 

SLotman

Active Member
Joined
Jul 3, 2017
Yup, mine is a devkit.

The good thing about it is that whatever I run on it, I have more "processing power" available than a "regular Xbox" with dev mode enabled (those can only run UWP AFAIK while devkits can run c++/DX12 programs)
 

SLotman

Active Member
Joined
Jul 3, 2017
Well... I have some good and bad news.

The good news is that you CAN make UWP apps running JS, and the HTML5 target works fine with it.

The bad news is apparently I won't be able to test it, since my devkit only runs stuff made with XDK (so, C++ only). To run UWP I'd need a regular console converted to dev-mode. o_O

I'm still talking with Microsoft trying to understand this, since I *did* actually ran it. Just the last update that broke everything and I couldn't do anything about it :(
 

SLotman

Active Member
Joined
Jul 3, 2017
Hah!

I left "development mode", then went back to it again... and now I'm running UWP apps! Take that Microsoft! ^_^
 

SLotman

Active Member
Joined
Jul 3, 2017
A small step by step tutorial:

0. Export your game to HTML5. Make sure it runs fine on Edge.
1. Open VS2017 (I'm using the Professional version - I think all my troubles were because I was using the community edition...!)
2. Create a new Project. Select Javascript->Blank App (Universal Windows)
3. In the next window, select the target version as high as possible (I'm using 18362.0 on my test). Min version could be anything.
4. Open package.appxmanifest. On "Application", set 'start page' to ms-appx-web:///index.html
4.1 Go to "Content URLs" add ms-appx-web:///index.html as an URl, rule 'include', access 'all'.
5. In the solution explorer, create a folder called 'data'. Copy everything in your 'data' folder from Monkey/Cerberus in there.
6. Copy the html file over the solution's index.html. Alter the script src to point to js/main.js instead of plain "main.js"
7. overwrite "main.js" in the js folder with the one on your monkey/build folder.
8. Open the index.html file. Where you see the window.onload = function(e) { ... } add this:

JavaScript:
            var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView();
            view.addEventListener("resize", updateSize);
            view.tryEnterFullScreenMode();
This will make the app to run in fullscreen mode.

AND DONE!

Ok, not quite. But you can see your game running after that. If you're running on Windows, it will respond to keyboard, mouse, etc. If you're on XBox, Monkey's joystick functions will work out of the box.

The only caveat I couldn't figure out so far is the (B) button. Pressing it exits the UWP app, and I don't know how to change or block this behaviour yet.
 

SLotman

Active Member
Joined
Jul 3, 2017
And apparently that "B" button is a problem: https://github.com/Scirra/Construct-3-bugs/issues/942
They talk about some sort of fix, but I can't figure it out what it is :(

How smooth does it run?
For now I'm testing with old Monkey's HTML5 / Canvas and it runs pretty well - But it did give some slowdowns here and there. I want to tackle this 'back button' issue, and then I'll try that webgl target, which should make thinks faster :)
 

SLotman

Active Member
Joined
Jul 3, 2017
Bingo! Just added this (also on window.onload):


JavaScript:
            var systemNavigationManager = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
            var systemNavigation = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
            systemNavigationManager.addEventListener("backrequested", handleSystemNavigationEvent.bind(this));

            function handleSystemNavigationEvent(args) {
                args.handled = true;
                history.back()

            }
No more problems with the back button :)
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
Awesome. If the build and deploy process can be done via command line and a prebuild template, then you laid out the ground for a new target.
Have to test if the community version of MSVC can be used with a regular XBox One.
 

SLotman

Active Member
Joined
Jul 3, 2017
I don't know about the command line, or anything - but I just tested html5 with webgl (that 'mungo' target, I 'adapted it' to have joystick support, taking code from Monkey regular HTML5 target) and it worked BEAUTIFULLY.

Worst case scenario it could just export the project to be run from VS. On a retail XBox the community edition should work fine :)

Also, the same UWP project can be used on Windows 10 devices (PCs, tablets...), so even if you don't have a XOne, this could still be interesting :)
 
Top Bottom