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

[WIP] Balance Board emulation #8268

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Pokechu22
Copy link
Contributor

@Pokechu22 Pokechu22 commented Jul 28, 2019

This PR adds support for balance board emulation.

This isn't completely finished, and the UI for it isn't too great. In particular, there isn't any way to specify the current weight on the main UI, only to adjust the weight in terms of percentages, though it does exist on the TAS UI. The UI also doesn't support all possible inputs, only cases where actual balance is used; this means that e.g. walking doesn't work too well (or the step game). The balance board is treated as a regular extension and can be set on any remote, and also needs to be manually set for the actual balance board. Also, games that don't support the balance board will continuously disconnect it, and dolphin will then repeatedly attempt to reconnect it. But it is perfectly usable.

One thing I haven't tested is whether this works with movies; the documentation (rev 31 specifically) mentions that a single byte is used to indicate the connected controllers, and adding a 5th pseudo-wiimote probably causes issues there. I currently have a commit that adds an excessive number of bounds-checks for movies, which ideally should be replaced with proper support.

Copy link
Member

@lioncash lioncash left a comment

Choose a reason for hiding this comment

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

Left a few preliminary comments, if any don't apply due to the WIP status, feel free to disregard them.

Source/Core/Core/HW/WiimoteEmu/Extension/BalanceBoard.cpp Outdated Show resolved Hide resolved
Source/Core/Core/HW/WiimoteEmu/Extension/BalanceBoard.cpp Outdated Show resolved Hide resolved
Source/Core/Core/HW/WiimoteEmu/Extension/BalanceBoard.cpp Outdated Show resolved Hide resolved
Source/Core/Core/HW/WiimoteEmu/Extension/BalanceBoard.cpp Outdated Show resolved Hide resolved
Source/Core/Core/HW/WiimoteEmu/Extension/BalanceBoard.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/TAS/BalanceBoardWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/TAS/BalanceBoardWidget.cpp Outdated Show resolved Hide resolved
@Pokechu22
Copy link
Contributor Author

Pokechu22 commented Jul 29, 2019

I've implemented movie support, which seems to work correctly at least when starting from a save state right before selecting a game. Wii Fit (Plus) seems to be rather annoying with synchronization though, especially with the random fitness tips on startup. (Possibly I just don't know how to work with the realtime clock or saves or something; I haven't used the movie functionality much.)

I haven't tested netplay yet, and I suspect it also has the same expectations of 4 wiimotes or gamecube controllers. I'm looking into that one now. (I don't have anything to test it on either as Wii Fit isn't really a multiplayer game and you can only use one balance board, but I should be able to make the same kinds of code changes.)

EDIT: I don't think I'll be able to handle netplay at the moment; I don't feel confident in modifying the protocol for it which I'm pretty sure would be needed to add support (especially since you'd generally have one player using both the remote and the balance board)

@Starmann
Copy link

Starmann commented Aug 4, 2019

For anyone who wants to try with Netplay, Tetris Party is a multiplayer game that supports Wii Balance board. As is Super Monkey Ball Step and Roll.

@Pokechu22 Pokechu22 force-pushed the balance-board branch 2 times, most recently from 07eacde to fcfcd2e Compare August 14, 2019 20:12
@Pokechu22
Copy link
Contributor Author

I've found my previous code that calibrated 34kg as 34000 was causing overflows when leaning far to the side and also causing underflows as one of the sensors goes negative if leaning too far. I've changed it so that the difference between 0kg and 34kg is 3400 instead and that works fine; games don't mind/like the negative value (though I haven't tested if it occurs on hardware; I've only confirmed that it makes sense math-wise).

I've also adjusted the TAS code to use 4 doubles internally instead of direct sensor values. That seems to be causing some issues (a stackoverflow sometimes) which I haven't fixed yet, but the UI looks and behaves about the way I want it to. Fixed point is probably preferable in the long run.

The only thing that I'd say is missing is a more complete UI for normal use. Everything works balance-wise, but for functions involving walking or jumping it's a bit of a mess and there's no way to directly specify a weight.

@Pokechu22
Copy link
Contributor Author

Pokechu22 commented Feb 24, 2020

Rebased again to fix conflicts from #8575 (which conflicted with 4153e1d because it also removed the Nunchuk union; I've just dropped it) and #8633 (which conflicted with 9bc5189 but was just a case of redoing the const int conversion)

@Pokechu22 Pokechu22 force-pushed the balance-board branch 2 times, most recently from 4e75aa5 to ab3da55 Compare April 28, 2020 21:27
@Pokechu22
Copy link
Contributor Author

This is unlikely to be ready for merging any time soon (due to the incomplete UI and other various bugs), but if you want to try it out, you can download a build from CI by clicking the check mark next to the most recent commit, then finding and clicking the details link for pr-win-x64, and then scrolling to the bottom where under upload there should be "pr-8268-dolphin-latest-x64.7z". This applies to any pull request.

Source/Core/Core/HW/WiimoteEmu/DesiredWiimoteState.h Outdated Show resolved Hide resolved
const ControllerEmu::Triggers::StateData weight_state = m_weight->GetState();
const auto weight = weight_state.data[0];

const double total_weight = 63.5 * weight; // kilograms
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain the number here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, I can't. I don't think it has any special meaning, other than being chosen as a default weight of some sort (because the way I implemented the controller UI, it gives a value from 0x to 2x instead of a weight in kilograms). It looks like I created a DEFAULT_WEIGHT constant in WiiTASInputWindow.cpp but just left it as a magic number here. I have no idea why I picked 63.5 though.

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've created a DEFAULT_WEIGHT constant in the header which is used both here and for TAS. It's still a bit jank though.

Source/Core/Core/Movie.cpp Outdated Show resolved Hide resolved
@Pokechu22 Pokechu22 force-pushed the balance-board branch 2 times, most recently from 1b384f6 to 78eb864 Compare March 31, 2024 22:18
This is a bad fix since it doesn't resolve using the balance board on netplay.
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.

6 participants