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

IOS/USB: Emulate Wii Speak using cubeb #12769

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

sepalani
Copy link
Contributor

@sepalani sepalani commented May 9, 2024

This PR is based on #12567.

I don't have much knowledge regarding the technical details of the implementation. I mainly fixed the Windows support, the heisenbug due to uninitialised members and finalised the config integration.

Ready to be reviewed and tested.

@sepalani sepalani force-pushed the wii-speak branch 3 times, most recently from 388c11c to e8ce010 Compare May 10, 2024 23:15
@sepalani sepalani force-pushed the wii-speak branch 3 times, most recently from 932e093 to cf3916c Compare May 12, 2024 11:54
Based on @noahpistilli (Sketch) PR:
dolphin-emu#12567

Fixed the Windows support and the heisenbug caused by uninitialized
members.

Config system integration finalized.
The register should be 12 (i.e. 0x0c) instead of 0xc0
It seems to fix random echoes and reduce noises when nobody is speaking
@sepalani
Copy link
Contributor Author

I fixed a few more things. The Wii Speak Channel appears to work properly now (its initial test won't work though, as we don't emulate the echo reduction). I also added the Android support.

To test this PR, you'll need to enable the emulated Wii Speak under Tools > Emulated USB devices > Wii Speak and to check the two checkboxes to enable the emulation and to "connect" it. On Android, it's located under Settings > Config > Wii > Emulated USB Devices and you'll also need to enable the microphone permission for the app.

The Wii Speak Channel can be tested using a regular one (but by redirecting Nintendo domains to nothing like localhost, resulting in a skippable 20100 error) or via a Riiconnect24 patched version (AFAICT, WiiLink24 patcher doesn't seem to offer it currently, Wiimmfi WAD Patcher does). A Wii friend is required in order to be able to record Wii messages like this: https://www.youtube.com/watch?v=4kpNID36pW0

This PR can be tested on Monster Hunter 3 as well. You will need to patch the game to go online using alternative servers. You will need a friend in-game also using a Wii Speak (Dolphin or a real Wii) to be able to speak in a city.

I haven't checked this PR with other games yet, such as Animal Crossing. I'll when I'll get the time to do so. Otherwise, this PR is still ready to be reviewed & tested.

@sepalani sepalani force-pushed the wii-speak branch 2 times, most recently from 97daea9 to 3693fe5 Compare May 13, 2024 23:16
bool m_device_attached = false;
bool init = false;
std::unique_ptr<Microphone> m_microphone{};
const DeviceDescriptor m_device_descriptor{0x12, 0x1, 0x200, 0, 0, 0, 0x10,

Choose a reason for hiding this comment

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

Suggested change
const DeviceDescriptor m_device_descriptor{0x12, 0x1, 0x200, 0, 0, 0, 0x10,
const DeviceDescriptor m_device_descriptor{
.bLength = 0x12,
.bDescriptorType = 0x01,
.bcdUSB = 0x0200,
.bDeviceClass = 0x00,
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAICT, this syntax isn't used in the current codebase for similar device classes. I wouldn't mind changing it in a follow up PR.

Copy link
Member

@JosJuice JosJuice left a comment

Choose a reason for hiding this comment

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

How does the permission prompt work on Android? Does cubeb automagically make the permission prompt show up?

@@ -28,6 +28,7 @@
<uses-permission
android:name="android.permission.VIBRATE"
android:required="false"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission
android:name="android.permission.RECORD_AUDIO"
android:required="false"/>

Otherwise Google Play can prevent Dolphin from being installed on devices with no microphone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAICT, cubeb doesn't prompt anything and just fails to initialise.

Should we check this permission and ask the user the appropriate permission? If so, should it be done in the C++ code before the initialisation or in the Android code when using the settings toggle?

@@ -923,4 +923,6 @@ It can efficiently compress both junk data and encrypted Wii data.
<string name="incompatible_figure_selected">Incompatible Figure Selected</string>
<string name="select_compatible_figure">Please select a compatible figure file</string>

<string name="emulate_wii_speak">Wii Speak</string>
<string name="disconnect_wii_speak">Mute Wii Speak</string>
Copy link
Member

Choose a reason for hiding this comment

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

"Mute" doesn't match what the setting is called in the code or in DolphinQt. Is this something that was overlooked, or is it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is intended since it is presented differently on PC and Android. On PC it has its own dedicated window (similar to the emulated Infinity base):
image

Whereas on Android, it's only a toggle settings below the one enabling the Wii Speak. So to make it clearer for the end-user I decided to rename it (as the effect and purpose of disconnecting it is not to record audio). I feel that having a "Wii Speak" toggle, plus a "Disconnect Wii Speak" toggle right under it sounds strange from a UI point of view.

I'm open to better ways of presenting this option to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants