You have been redirected to the Français version of the website based on your browser language preferences. If you prefer the English version, click here to go back.

Mastering Motion: The Journey to Emulate MotionPlus

Your eyes are not deceiving you, MotionPlus emulation is finally here. In a dramatic return to the project after a long hiatus, Billiard returned to the project with the goal of cleaning up emulated Wii Remotes and implementing emulated MotionPlus correctly once and for all. These efforts have greatly improved Dolphin's ability to create motions that games can recognize without the need for real Wii Remotes. The key behind these improvements was thinking about motions differently, by treating an emulated Wii Remote as a virtual object acting out these motions, Dolphin now handles a lot of the extraneous motions that swinging, tilting, and pointing a Wii Remote does that aren't immediately obvious. Mix that with reverse engineering efforts and cracking the MotionPlus's extra encryption and you can finally configure and play your favorite MotionPlus games with ease.

We take Skyward Sword and Wii Sports Resort for a spin with Emulated MotionPlus.

Nintendo's Motion Controlled Phenomenon

The Wii console isn't defined by graphics, it isn't defined by a powerful processor, impressive online, or anything like that. The Wii will be remembered for its innovative controller: the Wii Remote. When it arrived onto the scene with Wii Sports as a pack-in title, the Nintendo Wii reached audiences with its simple motion controls that anyone could wield. Along with a launch title for the hardcore crowd, The Legend of Zelda: Twilight Princess, the Wii set off at a torrid pace.

Unfortunately, many third party developers struggled to match the excellent motion controls featured in Wii Sports and Wii Play. It may be hard to believe, but the Wii Remote can't actually track its position through 3D space. Packing only an infrared camera and an accelerometer, the Wii Remote was only able to read translational motion. The Wii Remote had no way to sense rotation!

Accelerometers measure translational motion, specifically the change of velocity of an object as it travels from one point to another in space.
Gyroscopes measure rotational motion, which is the angular velocity of an object as it rotates around a point (the center of the gyro).
Both together can measure any movement within 3D space. This is know as "six degrees of freedom" and is the standard for VR controllers today.

Without a gyroscope, the Wii Remote could only detect half the possible axis of movement. Yet even with this limitation, Nintendo developers used every trick in the book to get what they could to read motions in these games. For example, New Super Mario Bros. Wii can read tilt through detecting the force of gravity to figure out its orientation. Metroid Prime 3 used the position and distance between the two infrared lights of the sensor bar to enable complex twisting and pulling actions. Throughout the library of early Wii games there are tons of small examples like this littered about with developers pushing the limits of the Wii remote. However, even with all of these clever work arounds, actions like swinging a sword in Twilight Princess never felt like much more than hitting a button.

The Birth of Modern Motion Controls

Developers at Nintendo knew that if they were ever going to be able to deliver on the promise that the Wii Remote showed in its early days, that another leap in technology was needed. Behind the scenes, they began development on a new Zelda title upon the completion of Twilight Princess. With the lackluster Motion controls being one of the chief complaints, it seemed as though developers wanted to address that problem in a big way. Unfortunately, the standard Wii Remote wasn't capable of much more... yet. At E3 in 2008, that all changed with the announcement of the Wii MotionPlus adapter. This adapter featured a 3-axis gyroscope (gyro) that finally allowed the controller to measure rotational motion in addition to the translational motion from the existing accelerometers. With full six degrees of freedom, the MotionPlus allowed Wii Remotes to perform full 3D tracking just like VR controllers do today!

Just a year later, Nintendo announced their newest edition to the Zelda series, The Legend of Zelda: Skyward Sword as a MotionPlus exclusive. For non-Nintendo developers, the announcement of the MotionPlus and MotionPlus games were not such a thrilling time. Many developers were blindsided by the announcement and didn't have time to add support.

Released in 2008, Star Wars: The Force Unleashed just missed out on MotionPlus, much to the developer's chagrin.

Regardless of third party sentiments, the Wii MotionPlus adapter laid the groundwork for modern motion controls on Nintendo consoles. While MotionPlus had a lot of sensor limitations that will be touched on later, it still represented a huge leap in motion tracking over the base Wii Remote. The MotionPlus's launch title Wii Sports Resort improved upon the original in just about every single way when it came to controls. The minigames could read more subtle movements, more complex movements, and had a greater degree of control versus the simple games present in the first game. For people that loved Wii Sports, Resort was a must own title.

Skyward Sword on the other hand, was delayed several times and didn't release until 2011. And even after its release, it was met with a rather lukewarm response. While there are plenty of arguments that can be had about game design and whether or not being designed around motion controls hurt it or helped it, there is something that must be said. Skyward Sword is a technical achievement on early motion controllers. In order to get the level of motion recognition that they did, developers had to take advantage of every single trick they could and silently recalibrate the Wii Remote since you were expected to be swinging it a lot!

Alongside Skyward Sword, Nintendo released the Wii Remote Plus, which moved the gyroscope to inside of the Wii Remote.

And this brings out one of the problems to emulating Skyward Sword. It's indelibly tied to MotionPlus technology. This isn't a game where we can sneak shake onto a button and savor the experience, Dolphin needed to be able to create complex motions and report the correct data in order for a game like this to be playable. Any MotionPlus implementation that didn't allow for playing the crowned jewel of the MotionPlus library would be a huge disappointment.

Ghosts of the Past

With a mainline Zelda title gated behind MotionPlus, emulating the feature was something wanted by both users and developers. So how exactly did Dolphin end up making it all the way to 2019 with no MotionPlus emulation whatsoever? There's actually a myriad of reasons that have shaped how things have developed. The most important thing to note is that there have been attempts at MotionPlus at the past and a lot of development time has been spent over the years trying to tackle it. In fact, there's an old fork that has let users play MotionPlus titles since the Dolphin 3.0 days! Unfortunately, anyone who wondered why it was never merged into master would very quickly see why after they actually tried to use it. It was a user interface nightmare that required extremely careful configuration, constant profile swapping, and maticulous retooling of motions to even get past the menus in a game like Skyward Sword. Imagine being greeted by this every time you needed to configure or adjust controls.

In this old fork, users had to configure this monster constantly. Each challenge a game presented required a new profile, and each profile could take hours to finesse into working. This truly was the Dark Souls of emulator configuration.

Thankfully, Dolphin could bypass the need for emulated MotionPlus because users could connect Real Wii Remotes over bluetooth. Until emulated MotionPlus was truly in a place where a majority of developers we happy, users could still play the game with real controllers! Unfortunately, MotionPlus emulation stalled and this became the only way to play these games. In fact, the addition of Bluetooth Passthrough became a way to play MotionPlus titles in Dolphin without the limitations put on by Bluetooth drivers. For perfect connection and audio, you could even hook up a real Wii Bluetooth adapter to your computer!.

This seemed like a happy enough solution, especially considering just how integral motion controls were in games like Skyward Sword and Wii Sports Resort. That isn't to say there isn't a need for emulated MotionPlus. Not everyone can use motion controls, whether it's due to disability or access to Wii Remotes. We take for granted just how common Wii Remotes still are in many areas thanks to the Wii U also using Wii Remotes as a secondary input device, but their availability isn't guaranteed forever.

So even if MotionPlus emulation can't give the same experience as using real controllers, there are still plenty of people that benefit from having access to the game through an emulated control scheme. It says a lot that some users have been willing to suffer through the flaws of the old fork just to play through some of the MotionPlus exclusive games. In order to get MotionPlus emulation into mainline builds, it would need to be rebuilt from the ground up. The first problem that needed to be solved was the fact that the MotionPlus adapter couldn't consistently connect in Dolphin.

Cracking The Code

Billiard has been building up for a run at MotionPlus emulation for quite some time. Part of this has been making Dolphin smarter with motion emulation in general so that MotionPlus wouldn't be as big of a leap. His efforts, along with those of iwubcode, have improved motion recognition across over 30 titles. While Billiard was able to get MotionPlus somewhat working right away, he had no idea how to solve the problem of getting the attachment recognized 100% of the time.

Users trying to use old forks would sometimes have to disable and enable MotionPlus many times before it'd connect.

Why exactly has connecting the MotionPlus adapter been such a pain? Well, it turns out that MotionPlus adapters have an additional cryptographic challenge compared to other accessories. The solution employed by the old fork was to replay data from a successful connection, but this would fail exactly 50% of the time. It turns out there was a second challenge that could be chosen at random after connection was started, meaning that replaying connection data would never consistently work. In order to get MotionPlus adapters connecting consistently, the cryptography needed to be solved. Once the challenge was put out, several developers answered the call.

Long time developer flacs quickly identified that MotionPlus was using the Rabin cryptosystem, which is similar to a typical RSA challenge. The game will first ask the MotionPlus adapter for a random 512 bit number. While normally sending the same number and following through with the connection procedure would work, MotionPlus connections change it up by having two challenges.

The idea of the Rabin cryptosystem is that you can generate a secure connection with just a public key. For some reason, Nintendo decided to use a 512-bit number, which was more than possible to brute force. Perhaps when they were developing the add-on 512-bit seemed safe enough, but, even in 2009 512 bit numbers were already considered possible to crack in RSA crypto challenges.

Several developers, including flacs, degasus, and Billiard came up with a solution and CrystalGamma donated their CPU time toward crunching the actual numbers. Several days later, the important factors that made up the private key were finally cracked.

p = 79346858353882639199177956883793426898254263343390015030885061293456810296567  
q = 85213910804835068776008762162103815863113854646656693711835550035527059235383

After factoring was complete, degasus provided a simplified solution that allowed Dolphin to solve the second challenge in a more simplified way based on the result for the first challenge. This value was known as Quadratic Residue sqrt(v). If this sounds complicated, here's a simplified equation showing how sqrt(v) allows us to solve challenge 2 once we have the solution to challenge 1.

y1 (challenge 2) = y0 (challenge 1) * sqrt(v)
sqrt(v) = 2233195979679411851574233784410147713188401338158936300465940806894815467091470552164630475802483462872732436570235909421331424649287229820640697259759264

While all of these numbers may mean nothing to the average user, what they mean is that Dolphin can successfully pass any encryption challenge when emulating a MotionPlus adapter.

Calibration and Motion

Unlike modern motion controllers, like Nintendo's Joycons, MotionPlus technology used rather imprecise gyroscopes that lose track of the Wii Remote's precise orientation after strenuous motions like swings. MotionPlus titles, such as Wii Sports Resort and Skyward Sword fought this by constantly using the sensor bar to recalibrate the Wii Remote on the fly. In yet another shortcoming of the old MotionPlus fork, it didn't even attempt to understand what the calibration data did and again just fed games recorded data from hardware. As a proof of concept, it saved a lot of time, but to create a perfect emulated environment, Dolphin needed to be able to generate proper calibration data.

Anyone who has played a MotionPlus title will be extremely familiar with these types of screens.

In a bit of good fortune, while developers were analyzing the calibration data, the NSA released a reverse engineering tool called "Ghidra". This tool helped Billiard more easily examine the calibration data and see how the games were using it. With Ghidra, it only took a few days to determine what all of the data meant, and give Dolphin the ability to generate perfect calibration data. This is particularly important as users may not have the ability to correct for small imperfections when configuring a Wii Remote to a keyboard or analog stick. As a bonus, it also lets players cheese bowling by just mapping the up and down axis so they can do a perfectly straight throw every time!

Making All Right Move...ments

Now that emulated MotionPlus was calibrated correctly, Dolphin needed to actually make sure the motions it was making made sense. The Wii Remote has a collection of sensors that work together to try and make sure games are able to accurately follow how the Wii Remote is moving. As such, many games will take avantage of multiple sensors in order to handle the same actions. In Rodea: The Sky Soldier, the game will actually check for multiple movements for single actions. If it sees infrared data change in certain ways, it'll assume with the Wii Remote is shaking. As such, even in Dolphin, users playing on mouse and keyboard could get by without needing any extra buttons for handling motion emulation.

While that particular case worked in Dolphin's favor with its flawed motion emulation, there were a lot more cases that actually went the opposite way. Simply feeding a game straight movements into an accelerometer without adjusting other data will cause misread movements or unwanted actions. For example, No More Heroes 2 expects there to be an arcing movement on upward swings and won't react correctly if it just reads the Wii Remote moving upward with no other adjustments.

Dolphin hasn't been very smart with this over the years. It wasn't until fairly recently that it cared at all, when iwubcode started looking into why certain games couldn't read movements from emulated Wii Remotes. Some of them were silly; back in Dolphin 5.0, if you configured a swing up, Dolphin would tell the game the Wii Remote is going straight up. That may sound fine in theory, but a swing involves a lot more than up and down movement. Games that checked for logical motion data would end up breaking because Dolphin wasn't taking into account how an arm would move a Wii Remote.

Skyward Sword makes use of every bit of data available to it. That's two 3 axis accelerometers, a 3 axis gyro, a 2 axis infrared sensor, along with a joystick and buttons that it uses all at the same time! Just mapping the raw axis and buttons to a traditional controller was infeasible.

In order to solve a problem like this and make motions like a real Wii Remote, a creative solution was needed. Some work on this had already begun, iwubcode had already started to improve motions to be more logical for non MotionPlus games. This assisted with Disaster: Day of Crisis and No More Heroes motion woes, but a more extravant solution would need to be done for a game so heavily designed around accurate motion like The Legend of Zelda: Skyward Sword. Simply forcing users to configure a monstrosity of a page with dozens upon dozens of options isn't reasonable, Dolphin needed a way to make things easier.

That's why in the latest development builds you won't see any extra configurations for Wii MotionPlus. Everything is built upon the current configuration system and simply adds gyroscope reporting on top of it. This is possible thanks to Billiard's innovation of actually applying motions to a Virtual Wii Remote! By applying actions like swinging and tilting to a physical object, and having it move realistically within virtual space, we can reflect changes across all motion data without needing the mess of complicated controls present in the older fork.

Even violent pointer movements can now move the Virtual Wii Remote enough to trigger a game's shake action.

To show how powerful the Virtual Wii Remote can be, look at a game like Super Mario Galaxy. You can actually do the spin action in this game without configuring any motions except the pointer. This is because the Virtual Wii Remote moves to reflect the changes in infrared data. If you're violently moving the pointer left and right, the virtual Wii Remote will be returning enough accelerometer force for the game to detect a shake! While it's easy enough to configure a shake in Super Mario Galaxy, this kind of behavior becomes essential in The Legend of Zelda: Skyward Sword.

Skyward Sword is designed around the Wii Remote and MotionPlus and uses every bit of data to help accurately and consistently read motions from the player. If a motion doesn't make logical sense to Skyward Sword, it won't work correctly. This is the very behavior that made the old MotionPlus fork so difficult to configure, you couldn't just feed it in a raw movement and expect it to work. An upward swing will affect infrared, accelerometer, and gyro data, and configuring each one individually just isn't workable. The Virtual Wii Remote takes into account the physics of the Wii Remote and allows these complex movements to work and it's accurate enough that we actually used real movements to help debug misread motions toward the end of development.

Waiting For Perfection

After a long wait from the original prototypes that gave users such hope, MotionPlus emulation is finally here. Most games should be playable thanks to all of the careful changes done to Wii Remote emulation in general. Despite all of this, it can't be stressed enough that these MotionPlus games heavily rely on motions for their gameplay. The Legend of Zelda: Skyward Sword and Wii Sports Resort are very different experiences when played on a standard controller or mouse and keyboard. Some parts of the game that were torturous on console can be much easier, and you're much less likely to be suffering from Wii elbow after a play session. On the other hand, some complex motions just don't map well and may require some tweaking if you want to play a particular minigame or get past a challenging motion puzzle.

So while the ability to play these games has been preserved, some of their experience has been lost in translation. But that doesn't mean this will always be the case - many modern controllers actually contain gyroscopes capable of emulating MotionPlus with near 1:1 accuracy! The main problem is that accessing these gyroscopes often takes specialized drivers or other programs running in the background, which has delayed efforts in supporting raw gyroscope input. The current plan is to use OpenXR, which has finally arrived after what seems like an eternity. One particular benefit of OpenXR is that it'll give us an open way of accessing Virtual Reality controllers... and their extremely accurate built-in motion tracking! Paired up with Dolphin, this could provide a permanent way for users to enjoy these games however they want, without the need for aging, proprietary hardware.

With that, we hope everyone enjoys trying out MotionPlus emulation and we'll be back at the end of the month with the long awaited return of the Progress Reports.

Continuez la discussion de cet article sur le topic de l'article sur le forum.

Article suivant

Article précédent

Articles similaires