Cemu icon indicating copy to clipboard operation
Cemu copied to clipboard

nsyshid: Emulate Skylander Portal

Open deReeperJosh opened this issue 1 year ago • 28 comments

Carrying on from some of the work I have done on Dolphin and RPCS3, and thanks to https://github.com/cemu-project/Cemu/pull/950 being merged, I am opening this PR up with the ability to emulate the Skylander Portal on Cemu.

Currently have tested Trap Team and Swap Force as working on my Mac, but hoping to get feedback and some testers on this PR too. Hoping to add Disney Infinity in the near future, but I don't currently have access to my Wii U so can't dump the necessary erreula to test my changes have actually worked there.

Would partly close https://github.com/cemu-project/Cemu/issues/588

deReeperJosh avatar Sep 20 '23 00:09 deReeperJosh

Is this still being worked on or is it ready for review? Asking because some suggestions by @ssievert42 are still open or without comment.

Exzap avatar Oct 17 '23 01:10 Exzap

Yes sorry, just been busy with work, will fix those comments this week hopefully

deReeperJosh avatar Oct 17 '23 06:10 deReeperJosh

Just pushed up some changes, but still haven't implemented the find device across backends method, so will aim to do that before the end of the week.

deReeperJosh avatar Oct 17 '23 18:10 deReeperJosh

All those requested changes have now been made, let me know if that's what you had anticipated it looking like @ssievert42

Otherwise, I am not convinced with the performance on the Vicarious Visions games (Swap Force and Superchargers), I've had varying degrees of success because at some point the game decides to stop sending commands to the portal, presumably because the emulated portal has replied too fast or too slow. Will keep investigating the perfect timing.

deReeperJosh avatar Oct 26 '23 17:10 deReeperJosh

Had a playthrough of Swap Force and 10s might be the sweet spot for now, could be something that I can add as a custom option so that users can increase/decrease themselves to try to avoid the same issues that occur with a real portal, but for now the PR is good to go

deReeperJosh avatar Oct 27 '23 21:10 deReeperJosh

@ssievert42 more review work added - unfortunately without a proper core timing module there isn't much we can do besides sleep the thread for a bit, I have the done the same work on Dolphin and that framework (schedule the transfer to be completed at x amount of thread ticks rather than time based), but would need a major rework to Cemu's core. Even detaching/reattaching doesn't fix the issue, the game just decides to stop sending commands to the portal, go figure

deReeperJosh avatar Oct 28 '23 15:10 deReeperJosh

Welp, that's certainly a nice thing to do of the game. Putting aside the fact that I can't actually test this, because I don't own any Skylanders games, I've run out of things to complain about :)

LGTM :+1:

ssievert42 avatar Oct 30 '23 19:10 ssievert42

Hello, I just did some testing with Skylanders Giants. Cemu consistently crashes, either when the Activision logo is about to stop spinning, at various random points at the middle and end of the Vicarious Visions logo, or (my most successful attempt) a crash on "Press A". Just for kicks I tested with vanilla Cemu and it booted all the way through. I wonder if that's the timing issue with the emulated portal, but from previous talk it sounded like it didn't crash Cemu, as by then you wouldn't be able to "detach and reattach the emulated portal". Hope my testing helps, looking forward to seeing this feature in Cemu

ElBread3 avatar Nov 11 '23 21:11 ElBread3

@ElBread3 thanks for helping test, I don't have giants for the Wii U so can't confirm that but will see if I can get someone else to recreate the bug so I can try to fix it locally. I would have thought trap team would have the same issue but I guess not!

deReeperJosh avatar Nov 12 '23 13:11 deReeperJosh

Tested with a debug executable today and did not crash, though loading takes too long to daily drive, of course. Planning on testing with Disney Infinity on your infinitybase branch later once I buy it

ElBread3 avatar Nov 12 '23 23:11 ElBread3

I ended up grabbing giants and I had no crashes - might be Windows only so I will try to build on a Windows machine to see if I can replicate. Have you tried any other Skylander games @ElBread3?

deReeperJosh avatar Nov 14 '23 21:11 deReeperJosh

I have found that the crash happens when fmt::print is called, something that I still don't really understand but the error message is "Stack cookie instrumentation code detected a stack-trace buffer overrun." I have commented this out for now, but @ssievert42 if you could confirm if this is actually doing something valuable besides just being a debug statement let me know!

deReeperJosh avatar Nov 15 '23 21:11 deReeperJosh

Just made the layout of the window look a bit nicer and even

deReeperJosh avatar Nov 17 '23 20:11 deReeperJosh

OK I tested the print fix and Giants booted and is playable. To answer if I have other Skylanders games I also own Imaginators and Superchargers; The only other game that crashed when I did my first tests was Superchargers, crashing on the logo appearing, but it booted after a handful of attempts and still boots consistently. And Imaginators works fine.

ElBread3 avatar Nov 17 '23 22:11 ElBread3

@deReeperJosh That call to fmt::print can go :+1: (And shouldn't be there in the first place; If you look at the history of that _debugPrintHex function you'll notice that I managed to forget that call in there.) But I don't understand what could cause that error message either. At least in the context of _debugPrintHex we shouldn't be overwriting parts of the stack ¯\_(ツ)_/¯ Looking at recent PRs, #977 fixes a crash on Windows caused by the same fmt::print call, so I guess it's just not a good idea to use fmt to print stuff in Cemu, when there is a perfectly good function called cemuLog_logDebug to log something instead.

ssievert42 avatar Nov 21 '23 11:11 ssievert42

But I don't understand what could cause that error message either. At least in the context of debugPrintHex we shouldn't be overwriting parts of the stack ¯_(ツ)

We had some chat about it in https://discord.com/channels/286429969104764928/1017917335874572308/1155847973863964702 if removing it is ideal, then go ahead and i'll close the other pr, the logged error was basically "Bad file descriptor" while writing to fmt:: though.

Squall-Leonhart avatar Nov 21 '23 21:11 Squall-Leonhart

@deReeperJosh Just wondering do you plan to make a Lego Dimensions toy pad emulator for Cemu since you've already worked on Skylanders and Disney Infinity?

ElBread3 avatar Nov 30 '23 20:11 ElBread3

@ElBread3 haven't ever actually played lego dimensions, but if someone has done some documentation on the USB protocols for it I can try to pick it up :)

deReeperJosh avatar Jan 09 '24 14:01 deReeperJosh

@deReeperJosh Have you looked at the Disney Infinity Emulation yet?

ETE-Design avatar Jan 15 '24 23:01 ETE-Design

@ETE-Design yes, I have a branch on my repo where the portal is recognised (no character loading yet) but I don't have a Wii U and games to test with any more, so I can't get past the EULA Error screen

deReeperJosh avatar Jan 17 '24 15:01 deReeperJosh

@deReeperJosh I've had to modify the code to load the Disney Infinity base and dump sys, but I've gotten past the error. However I can't test the characters cause the game doesn't render. Do you guys want me to record the boot up with debug overlay and put it here? If so, should I record it with Vulkan or OpenGL or both?

ElBread3 avatar Jan 31 '24 02:01 ElBread3

skylanders renders just fine on current code though.....

Squall-Leonhart avatar Jan 31 '24 02:01 Squall-Leonhart

@Squall-Leonhart I was referring to Disney Infinity. An interesting note is that Disney Infinity seems to have nearly the same issue with rendering as Cars 3: Driven To Win, also developed by the same studio and therefore probably runs on the same engine. But yes, the Skylanders games work great

ElBread3 avatar Feb 01 '24 00:02 ElBread3

Not sure if there is much more left on this PR but I have become largely too busy to be able to continue working on fun side projects such as this - I will keep this PR open and continue to update with commits to main when I get the chance but won't be able to pay as much attention to it as previously

deReeperJosh avatar Feb 20 '24 15:02 deReeperJosh

@deReeperJosh Thanks for your work on this, I'm almost done playing Skylanders Giants on your fork, and it has worked very well so far. I plan on playing the following 4 entries as well, so I'll let you know about any instability or other issues. Don't worry about fixing anything until/unless you have time for it; I totally understand life getting in the way of hobbies and side projects.

iamc24 avatar Feb 21 '24 02:02 iamc24

@deReeperJosh I have an Wii U + Disney Infinity - Anything I can help with to get Disney Infinity working on CEMU?

ETE-Design avatar Mar 25 '24 12:03 ETE-Design

@ETE-Design I have a branch on my repo where I have my infinity base progress, there isn't much there yet (no loading/removing figures or anything) but it would be good if you could test getting in game, you need to dump the erreula from your console iirc to get past the menu

deReeperJosh avatar Mar 29 '24 09:03 deReeperJosh

The portal audio is underflowing, leading to the issue reported in #1146

Squall-Leonhart avatar Apr 01 '24 04:04 Squall-Leonhart

@Squall-Leonhart that is mostly an issue with the Windows HID transfers, afaik libusb doesn't have the same problem, would be ideal if windows users also had the option to use libusb in the future

deReeperJosh avatar May 14 '24 19:05 deReeperJosh

Quite possibly, i can't recall what the barrier for using it on windows is, but building with -DENABLE_NSYSHID_WINDOWS_HID=OFF hasn't demonstrated any odd behaviors in lego dimensions to date, alas i don't have skylanders to verify if the portal sounds work better with it.

Squall-Leonhart avatar May 14 '24 23:05 Squall-Leonhart