Building an Unofficial Stadia Client for iOS


First, we are going to have the option to scheme a mannequin so that we are in a position to characterize the controller because the Navigator.getGamepads() feature would routinely invent.

Which you would possibly perchance safe the legit spec here

We can now scheme our custom controller script. We can read our controllers the use of GameController framework provided by Apple. We then parse that into our objects. For the reason that buttons must still be in a definite exclaim we bear it in the following system.

*We buy that we want to catch adjust over the first linked controller, we additionally handiest enhance one controller.

This code can get pleasure from some error handling ❤

In my checking out, the timestamp isn’t wanted so I left it clean. Essentially be jubilant to scheme the implementation to totally emulate the legit API. Now we have our controller knowledge prepared all that’s left is scheme a bridge of verbal substitute between our iOS app and a WKWebView that runs Stadia.

Utilizing WKWebView in iOS14, we are in a position to add an addScriptMessageHandler this permits us to talk with Javascript and return a Promise this can even lend a hand us in hijacking the Navigators.getGamepads() feature and return our custom knowledge.

Utilizing the following javascript we are in a position to emulate a fallacious controller. We hijack the system. Every time it’s accessed we name a messageHandler that will give us our controller knowledge over a Promise and override the last known say. (This draw that we are out of sync for one physique but we received’t mediate about this in-sport)

Thanks to my pal Stephan Mantel for helping me figuring it out

We are in a position to scheme a class with a draw that can perchance presumably load up a file (as String) and a draw that can perchance presumably setup a WKWebView so that it would possibly perchance most likely poke our custom code

This code can get pleasure from error handling ❤

In total what happens is at any time after we name setup(webview: WKWebView) we characteristic out the javascript we wrote earlier overriding the Navigators.getGamepads() feature. At any time when this feature is known as we now name our app code and land in the usercontentController callback where we return our newest controller say.

Voila, we must always have a fixed working controller in any WKWebView.

Yaay for controller enhance

Read More

Leave A Reply

Your email address will not be published.