Config stuff

This commit is contained in:
Sketch 2023-07-15 19:55:22 -04:00
parent 959e331c7e
commit f43f3a0bfd
4 changed files with 24 additions and 2 deletions

View File

@ -569,6 +569,9 @@ const Info<bool> MAIN_EMULATE_INFINITY_BASE{
const Info<bool> MAIN_EMULATE_WII_SPEAK{{System::Main, "EmulatedUSBDevices", "EmulateWiiSpeak"},
false};
const Info<std::string> MAIN_WII_SPEAK_MICROPHONE{{System::Main, "General", "WiiSpeakMicrophone"},
""};
// The reason we need this function is because some memory card code
// expects to get a non-NTSC-K region even if we're emulating an NTSC-K Wii.
DiscIO::Region ToGameCubeRegion(DiscIO::Region region)

View File

@ -352,6 +352,7 @@ void SetUSBDeviceWhitelist(const std::set<std::pair<u16, u16>>& devices);
extern const Info<bool> MAIN_EMULATE_SKYLANDER_PORTAL;
extern const Info<bool> MAIN_EMULATE_INFINITY_BASE;
extern const Info<bool> MAIN_EMULATE_WII_SPEAK;
extern const Info<std::string> MAIN_WII_SPEAK_MICROPHONE;
// GameCube path utility functions

View File

@ -24,8 +24,19 @@ WiiSpeak::WiiSpeak(IOS::HLE::EmulationKernel& ios, const std::string& device_nam
m_endpoint_descriptor.emplace_back(EndpointDescriptor{0x7, 0x5, 0x3, 0x1, 0x0040, 1});
m_microphone = Microphone();
m_microphone.OpenMicrophone();
m_microphone.StartCapture();
if (m_microphone.OpenMicrophone() != 0)
{
ERROR_LOG_FMT(IOS_USB, "Error opening the microphone.");
b_is_mic_connected = false;
return;
}
if (m_microphone.StartCapture() != 0)
{
ERROR_LOG_FMT(IOS_USB, "Error starting captures.");
b_is_mic_connected = false;
return;
}
m_microphone_thread = std::thread([this] {
u64 timeout{};
@ -135,6 +146,9 @@ int WiiSpeak::SubmitTransfer(std::unique_ptr<CtrlMessage> cmd)
m_vid, m_pid, m_active_interface, cmd->request_type, cmd->request, cmd->value,
cmd->index, cmd->length);
if (!b_is_mic_connected)
return IPC_ENOENT;
switch (cmd->request_type << 8 | cmd->request)
{
case USBHDR(DIR_DEVICE2HOST, TYPE_STANDARD, REC_INTERFACE, REQUEST_GET_INTERFACE):
@ -195,6 +209,9 @@ int WiiSpeak::SubmitTransfer(std::unique_ptr<IntrMessage> cmd)
int WiiSpeak::SubmitTransfer(std::unique_ptr<IsoMessage> cmd)
{
if (!b_is_mic_connected)
return IPC_ENOENT;
auto& system = m_ios.GetSystem();
auto& memory = system.GetMemory();

View File

@ -83,6 +83,7 @@ private:
u8 m_active_interface = 0;
bool m_device_attached = false;
bool init = false;
bool b_is_mic_connected = true;
Microphone m_microphone;
DeviceDescriptor m_device_descriptor{};
std::vector<ConfigDescriptor> m_config_descriptor;